Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Shared Data Between EXE and DLL

Status
Not open for further replies.

sweep123

Technical User
May 1, 2003
185
GB
I am trying to have an MFC application that shares data with a DLL.
The DLL is loaded via a batch file in a C-Scripting environment.

I have included the following lines of code in both the EXE and DLL

#pragma data_seg(".CSL_DATA")

int volatile abortFlag = 0; /* The flag to abort the test */
int volatile contiuneFlag = 1; /* The flag to schedule the test to continue */
int volatile enterFlag = 0; /* The flag to schedule data entry the test */

#pragma data_seg()
#pragma comment(linker, "/SECTION:.CSL_DATA,RWS")

On the C-Scripting side of things the batch file loads the DLL as follows:-

#loadlibrary 'WHLLIB'

However any changes in the data (abortFlag say) is not reflected in the other side.

Basically all I want is the 3 variables to be visible by the libray and the application.

Am I doing it wrong?!?
 
maybe you should declare like this:
#pragma...
__declspec(dllexport) int volatile abortFlag = 0;
...


Ion Filipski
1c.bmp
 
Tried it, it only works for instances of the same application. Not for two differently named applications.

Do I need to use Mailslots or memory mapped files just to share this small amount of data.
 
In this case you should create this section in the exe

Ion Filipski
1c.bmp
 
Dont think thats a solution.

The DLL needs to be the server and use CreateMailslot to create the Mailslot. But how do you start this running (i.e. to check the Mailslot for messages). Dont have an Entrypoint for the DLL.

To recap all I want is the ability to share 3 integer value between the DLL and a application.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top