News:

When registered with our forums, feel free to send a "here I am" post here to differ human beings from SPAM bots.

Main Menu

Windows DLL Template is wrong

Started by ninja9578, March 11, 2010, 12:27:13 AM

Previous topic - Next topic

ninja9578

The template with 8.02 declares DLLMain incorrectly.

in the template, DLLMain's 2nd argument is a DWORD, but Windows expects it to be a WORD.  I was wondering why the entry point was never getting called.  Hopefully this will be fixed in the next iteration :)

stahta01

#1
Please report problem to Microsoft.
After they fix their documentation; then I will agree with you.
I have no idea what is correct; but, I think microsoft docs is likely right.

From http://msdn.microsoft.com/en-us/library/ms682583%28VS.85%29.aspx

BOOL WINAPI DllMain(
 __in  HINSTANCE hinstDLL,
 __in  DWORD fdwReason,
 __in  LPVOID lpvReserved
);


Tim S.
C Programmer working to learn more about C++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]

ninja9578

#2
MSDN is full of incorrect information.  This is one of those cases, you can try the code if you'd like, make a dll from the template, put some debug in the DllMain, and load the library dynamically, it will never get called the way that it is.  I'm reporting it to microsoft now.

Sowaco

Take a short look into MFC-Implementation:

extern "C"
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID)
....

So,

The template with 8.02 declares DLLMain CORRECTLY.

Regards
  Andreas