AndyHollywood
Programmer
I am working on a dll at the mo which needs to be adapted from the original 16 bit version. Now from what i have read i understand that LibMain would only have been called once, where as dllmain is called for each new process, which gets its own memory address space! So to get round this i added a variable that would toggle once the dll had been entered the first time, and therefore avoid being repeated every new process:
#pragma data_seg("SHARDATA"
static HWND hwndMain = NULL;
static int nLineHeight = 0;
int calledonce = 0;
#pragma data_seg()
calledonce would then be used as follows:
case DLL_PROCESS_ATTACH:
// Initialize once for each new process.
// Return FALSE to fail DLL load.
if (calledonce == 0)
{
hInstance = hModule;
calledonce = 1;
MessageBox(NULL, "incremented", " DLL Main", MB_OK);
}
HOw ever this dosent work....am i setting the shared data segment incorrectly or have o got the wrong end of the stick with regard to the shared data! The libmain version only had hInstance = hModule; in it and this is all i wish to achieve with the new version.
Can anybody tell me why my code won't work?! and wether it will solve the random painting problem with my app!?
the code is here if your interested or need to look at it to solve the prob or shed any light on it.
Cheers in advance
Andy
#pragma data_seg("SHARDATA"
static HWND hwndMain = NULL;
static int nLineHeight = 0;
int calledonce = 0;
#pragma data_seg()
calledonce would then be used as follows:
case DLL_PROCESS_ATTACH:
// Initialize once for each new process.
// Return FALSE to fail DLL load.
if (calledonce == 0)
{
hInstance = hModule;
calledonce = 1;
MessageBox(NULL, "incremented", " DLL Main", MB_OK);
}
HOw ever this dosent work....am i setting the shared data segment incorrectly or have o got the wrong end of the stick with regard to the shared data! The libmain version only had hInstance = hModule; in it and this is all i wish to achieve with the new version.
Can anybody tell me why my code won't work?! and wether it will solve the random painting problem with my app!?
the code is here if your interested or need to look at it to solve the prob or shed any light on it.
Cheers in advance
Andy