Details
-
Bug
-
Resolution: Done
-
Not Evaluated
-
4.7.4
-
None
-
Windows 7
Description
1/ If there is a dll been loaded, I want to unload it. I have to write code like below:
QLibrary lib(path);
if (lib.load())
lib.unload();
I don't know why I should load it first.
2/ the dll does not unload immediately
3/ User can't handle load reasons like thread attach or detach
this solution works correctly on windows
on the place you want to load:
HMODULE pHnd = LoadLibraryW((wchar_t*)QDir::toNativeSeparators(path).utf16());
if (!pHnd)
DisableThreadLibraryCalls(pHnd);
on the place you want to unload:
FreeLibrary((HMODULE)pHnd);