"Go" VC uses DLL sharing interval to share data between processes and broadcast messages between processes

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.