blob: 0bf04f1bf3d791feacb76000ff58e0940ecc7f93 [file] [log] [blame]
Guido van Rossum6dbd1901996-08-21 15:03:37 +00001/*
2
3Entry point for the Windows NT DLL.
4
5About the only reason for having this, is so initall() can automatically
Antoine Pitrouf95a1b32010-05-09 15:52:27 +00006be called, removing that burden (and possible source of frustration if
Guido van Rossum6dbd1901996-08-21 15:03:37 +00007forgotten) from the programmer.
8
9*/
Guido van Rossum6dbd1901996-08-21 15:03:37 +000010
Guido van Rossuma1ebdbd1997-05-05 22:18:50 +000011#include "Python.h"
Guido van Rossume7ba4952007-06-06 23:52:48 +000012#include "windows.h"
Guido van Rossum6dbd1901996-08-21 15:03:37 +000013
Christian Heimesd59c64c2007-11-30 19:27:20 +000014#ifdef Py_ENABLE_SHARED
Steve Dower25879522015-01-15 09:10:16 -080015#ifdef MS_DLL_ID
16// The string is available at build, so fill the buffer immediately
17char dllVersionBuffer[16] = MS_DLL_ID;
18#else
Guido van Rossumec680921997-09-29 23:37:12 +000019char dllVersionBuffer[16] = ""; // a private buffer
Steve Dower25879522015-01-15 09:10:16 -080020#endif
Guido van Rossumec680921997-09-29 23:37:12 +000021
22// Python Globals
Guido van Rossum6dbd1901996-08-21 15:03:37 +000023HMODULE PyWin_DLLhModule = NULL;
Guido van Rossumec680921997-09-29 23:37:12 +000024const char *PyWin_DLLVersionString = dllVersionBuffer;
25
Antoine Pitrouf95a1b32010-05-09 15:52:27 +000026BOOL WINAPI DllMain (HANDLE hInst,
27 ULONG ul_reason_for_call,
28 LPVOID lpReserved)
Guido van Rossum6dbd1901996-08-21 15:03:37 +000029{
Antoine Pitrouf95a1b32010-05-09 15:52:27 +000030 switch (ul_reason_for_call)
31 {
32 case DLL_PROCESS_ATTACH:
33 PyWin_DLLhModule = hInst;
Steve Dower25879522015-01-15 09:10:16 -080034#ifndef MS_DLL_ID
35 // If we have MS_DLL_ID, we don't need to load the string.
Antoine Pitrouf95a1b32010-05-09 15:52:27 +000036 // 1000 is a magic number I picked out of the air. Could do with a #define, I spose...
37 LoadString(hInst, 1000, dllVersionBuffer, sizeof(dllVersionBuffer));
Steve Dower25879522015-01-15 09:10:16 -080038#endif
Antoine Pitrouf95a1b32010-05-09 15:52:27 +000039 break;
Mark Hammond9844a1f2009-01-27 23:46:57 +000040
Antoine Pitrouf95a1b32010-05-09 15:52:27 +000041 case DLL_PROCESS_DETACH:
Antoine Pitrouf95a1b32010-05-09 15:52:27 +000042 break;
43 }
44 return TRUE;
Guido van Rossum6dbd1901996-08-21 15:03:37 +000045}
Christian Heimesd59c64c2007-11-30 19:27:20 +000046
47#endif /* Py_ENABLE_SHARED */