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
#include "uipriv_windows.h"
// TODO DllMain()
HINSTANCE hInstance;
int nCmdShow;
@ -66,10 +64,6 @@ const char *uiInit(uiInitOptions *o)
options = *o;
hInstance = GetModuleHandle(NULL);
if (hInstance == NULL)
return loadLastError("getting program HINSTANCE");
nCmdShow = SW_SHOWDEFAULT;
GetStartupInfoW(&si);
if ((si.dwFlags & STARTF_USESHOWWINDOW) != 0)
@ -112,3 +106,16 @@ void uiFreeInitError(const char *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;
}