+ case DLL_PROCESS_ATTACH:
+ ghInst = NULL;
+ break;
You meant to make it 'ghInst = hinstDLL;', right?
I'd suggest to get rid of ghInst altogether until there is a real need for it.
And please add a DisableThreadLibraryCalls( hinstDLL ); call.
--
Dmitry.