1, http://blog.csdn.net/morewindows/article/details/6702342
There are many ways to share data between processes, such as clipboard, mapping files, etc., here we introduce the shared interval of the DLL to share data between processes, and the timely feedback to the relevant processes when the shared data changes.
A Setting a shared interval in a DLL
In the DLL is to use data segment to achieve shared interval, with this sharing interval, each process can easily share data.
1. First Use #pragma data_seg (name) to set the data segment named name.
2. Then use #pragma comment (linker, "/SECTION:NAME,RWS") to set the data segment property named name. /section is expressed as this is a data range, R--read read, w--write write, S--share shared.
Such as:
const int maxstringlen = 1000;
#pragma data_seg ("Sharedata")
int itotal = 0;
Char Szstring[maxstringlen] = {'} '};
#pragma data_seg ()
#pragma COMMENT (linker, "/SECTION:SHAREDATA,RWS")
Be aware that the data must be initialized first, otherwise it will be invalid. then write the DLL's export function to manipulate the data such as adding characters, get a string or directly get a string pointer.
You can use Dumpbin/summary test001.dll to view the newly created Sharedata area. Such as:
Note that the name of the paragraph is truncated , and then enter Dumpbin/section:sharedat test001.dll to view the details of the segment, such as:
2.
3.
4.
5.
"Go" VC uses DLL sharing interval to share data between processes and broadcast messages between processes