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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DllMain vs LibMain

Status
Not open for further replies.

AndyHollywood

Programmer
Oct 7, 2001
30
GB
The program I am trying to adapt was first writen using a dll with the entry point as LibMain, I am now trying to use DllMain, but don't really understand where the equivilant parts in both are?!

The old usd to be:
BOOL CALLBACK LibMain(HANDLE hModule, DWORD dwReason, LPVOID lpReserved)
{
hInstance = hModule;
return 1;
}

I want to use DllMain (for no particular reason I was just told it was the new standard!) but am unsure where to put the code so it will act the same?!

BOOL WINAPI DllMain(HINSTANCE hinstDLL,DWORD fdwReason, LPVOID lpReserved)
{
switch( fdwReason )
{
case DLL_PROCESS_ATTACH:
break;
case DLL_THREAD_ATTACH:
break;
case DLL_THREAD_DETACH:
break;
case DLL_PROCESS_DETACH:
break;
}

return TRUE;
}

would it go into process attach or thread attach? or should it be somewhere completly different?!

Also what are the benefits of dllmain over libmain?!

Cheers in advance

Andy
 
LibMain() is from 16 Bit Windows; you should use DllMain()under Win32. See the MSDN article Q125688 for porting Win16 DLLs to Win32.

:) Hope that this helped! :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top