Sharing a data segment in a DLL
-
Hi, I wrote a small dll which should be the link between two application (allow communication between them). Each application can use the dll, but the data is not shared. I had a look at the article "How to share a data segment in a DLL" by Phil McGahan to implement a shared data segment. Unfortunately this didn't work. Also the compiler always says: LINK : warning LNK4039: section "SHARED" specified with /SECTION option does not exist My dll looks basically like this: #pragma data_seg("SHARED") int counter; #pragma data_seg() #pragma comment(linker, "/section:SHARED,RWS") extern "C" __declspec(dllexport) void test() { AFX_MANAGE_STATE(AfxGetStaticModuleState()); counter++; CString tmp; tmp.Format("Counter=%i",counter); AfxMessageBox(tmp,MB_OK|MB_ICONSTOP|MB_APPLMODAL); } What am I doing wrong :confused: :confused: Can someone help :confused: :confused: Thanks :) :)
-
Hi, I wrote a small dll which should be the link between two application (allow communication between them). Each application can use the dll, but the data is not shared. I had a look at the article "How to share a data segment in a DLL" by Phil McGahan to implement a shared data segment. Unfortunately this didn't work. Also the compiler always says: LINK : warning LNK4039: section "SHARED" specified with /SECTION option does not exist My dll looks basically like this: #pragma data_seg("SHARED") int counter; #pragma data_seg() #pragma comment(linker, "/section:SHARED,RWS") extern "C" __declspec(dllexport) void test() { AFX_MANAGE_STATE(AfxGetStaticModuleState()); counter++; CString tmp; tmp.Format("Counter=%i",counter); AfxMessageBox(tmp,MB_OK|MB_ICONSTOP|MB_APPLMODAL); } What am I doing wrong :confused: :confused: Can someone help :confused: :confused: Thanks :) :)
You have to initialize
counter
(add the underlined part below):#pragma data_seg("SHARED") int counter = 0; #pragma data_seg()
--Mike-- http://home.inreach.com/mdunn/ "....." -- Silent Bob :love: your :bob: with :vegemite: and :beer: -
You have to initialize
counter
(add the underlined part below):#pragma data_seg("SHARED") int counter = 0; #pragma data_seg()
--Mike-- http://home.inreach.com/mdunn/ "....." -- Silent Bob :love: your :bob: with :vegemite: and :beer: