Remove erroneous use of FreeLibrary(_hUser32) after _hUser32 = ::GetModuleHandle(TEXT("User32")). According to MSDN FreeLibrary() reduces the reference count for the module but GetModuleHandle() doesn't increase it in the first place.