Author Topic: Windows DLL Template is wrong  (Read 3579 times)

Offline ninja9578

  • Multiple posting newcomer
  • *
  • Posts: 11
Windows DLL Template is wrong
« on: March 11, 2010, 12:27:13 am »
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 :)

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7591
    • My Best Post
Re: Windows DLL Template is wrong
« Reply #1 on: March 11, 2010, 12:34:24 am »
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
Code
BOOL WINAPI DllMain(
  __in  HINSTANCE hinstDLL,
  __in  DWORD fdwReason,
  __in  LPVOID lpvReserved
);

Tim S.
« Last Edit: March 11, 2010, 01:06:42 am by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline ninja9578

  • Multiple posting newcomer
  • *
  • Posts: 11
Re: Windows DLL Template is wrong
« Reply #2 on: April 16, 2010, 08:22:39 pm »
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.
« Last Edit: April 16, 2010, 08:24:42 pm by ninja9578 »

Offline Sowaco

  • Single posting newcomer
  • *
  • Posts: 4
Re: Windows DLL Template is wrong
« Reply #3 on: April 17, 2010, 11:28:40 am »
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