Added DllMain() to the Windows code.

This commit is contained in:
Pietro Gagliardi 2015-05-01 10:19:44 -04:00
parent 5094f08994
commit effb919176
1 changed files with 13 additions and 6 deletions

View File

@ -1,8 +1,6 @@
// 6 april 2015 // 6 april 2015
#include "uipriv_windows.h" #include "uipriv_windows.h"
// TODO DllMain()
HINSTANCE hInstance; HINSTANCE hInstance;
int nCmdShow; int nCmdShow;
@ -66,10 +64,6 @@ const char *uiInit(uiInitOptions *o)
options = *o; options = *o;
hInstance = GetModuleHandle(NULL);
if (hInstance == NULL)
return loadLastError("getting program HINSTANCE");
nCmdShow = SW_SHOWDEFAULT; nCmdShow = SW_SHOWDEFAULT;
GetStartupInfoW(&si); GetStartupInfoW(&si);
if ((si.dwFlags & STARTF_USESHOWWINDOW) != 0) if ((si.dwFlags & STARTF_USESHOWWINDOW) != 0)
@ -112,3 +106,16 @@ void uiFreeInitError(const char *err)
{ {
uiFree((void *) err); uiFree((void *) err);
} }
// TODO consider DisableThreadLibraryCalls() (will require removing ALL C runtime calls)
// TODO make sure this is the correct name for C runtime initialization (CHECK MSDN OR THE HEADERS)
// TODO can hinstDLL ever change?
// TODO handle DLL_PROCESS_DETACH?
// TODO __declspec(dllexport)?
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
if (fdwReason == DLL_PROCESS_ATTACH)
hInstance = hinstDLL;
// TODO provide a cleanup function
return TRUE;
}