wxDL_VERBATIM = 0x00000008, // attempt to load the supplied library
// name without appending the usual dll
// filename extension.
+
+ // this flag is obsolete, don't use
wxDL_NOSHARE = 0x00000010, // load new DLL, don't reuse already loaded
// (only for wxPluginManager)
wxDL_QUIET = 0x00000020, // don't log an error if failed to load
+ // this flag is dangerous, for internal use of wxMSW only, don't use
+ wxDL_GET_LOADED = 0x00000040, // Win32 only: return handle of already
+ // loaded DLL or NULL otherwise; Unload()
+ // should not be called so don't forget to
+ // Detach() if you use this function
+
wxDL_DEFAULT = wxDL_NOW // default flags correspond to Win32
};
// we're prepared to handle the errors
wxLogNull noLog;
- // the DLL should really be available
- wxDynamicLibrary dllComCtl32(_T("comctl32.dll"), wxDL_VERBATIM);
+ // we don't want to load comctl32.dll, it should be already loaded but,
+ // depending on the OS version and the presence of the manifest, it can
+ // be either v5 or v6 and instead of trying to guess it just get the
+ // handle of the already loaded version
+ wxDynamicLibrary dllComCtl32(_T("comctl32.dll"),
+ wxDL_VERBATIM |
+ wxDL_QUIET |
+ wxDL_GET_LOADED);
if ( !dllComCtl32.IsLoaded() )
{
s_verComCtl32 = 0;
}
}
}
+
+ // we shouldn't unload it here as we didn't really load it above
+ dllComCtl32.Detach();
}
return s_verComCtl32;
icex.dwSize = sizeof(icex);
icex.dwICC = ICC_DATE_CLASSES;
- wxDynamicLibrary dllComCtl32(_T("comctl32.dll") , wxDL_VERBATIM);
+ // see comment in wxApp::GetComCtl32Version() explaining the
+ // use of wxDL_GET_LOADED
+ wxDynamicLibrary dllComCtl32(_T("comctl32.dll"),
+ wxDL_VERBATIM |
+ wxDL_QUIET |
+ wxDL_GET_LOADED);
if ( dllComCtl32.IsLoaded() )
{
+ wxLogNull noLog;
+
typedef BOOL (WINAPI *ICCEx_t)(INITCOMMONCONTROLSEX *);
wxDYNLIB_FUNCTION( ICCEx_t, InitCommonControlsEx, dllComCtl32 );
/* static */
wxDllType
-wxDynamicLibrary::RawLoad(const wxString& libname, int WXUNUSED(flags))
+wxDynamicLibrary::RawLoad(const wxString& libname, int flags)
{
- return ::LoadLibrary(libname.t_str());
+ return flags & wxDL_GET_LOADED
+ ? ::GetModuleHandle(libname.t_str())
+ : ::LoadLibrary(libname.t_str());
}
/* static */
static bool s_initDone = false;
if ( !s_initDone )
{
- wxLogNull noLog;
-
- wxDynamicLibrary dllComCtl32(_T("comctl32.dll"), wxDL_VERBATIM);
+ // see comment in wxApp::GetComCtl32Version() explaining the
+ // use of wxDL_GET_LOADED
+ wxDynamicLibrary dllComCtl32(_T("comctl32.dll"),
+ wxDL_VERBATIM |
+ wxDL_QUIET |
+ wxDL_GET_LOADED);
if ( dllComCtl32.IsLoaded() )
{
s_pfn_TrackMouseEvent = (_TrackMouseEvent_t)
- dllComCtl32.GetSymbol(_T("_TrackMouseEvent"));
+ dllComCtl32.RawGetSymbol(_T("_TrackMouseEvent"));
}
s_initDone = true;
- // notice that it's ok to unload comctl32.dll here as it won't
- // be really unloaded, being still in use because we link to it
- // statically too
+ // we shouldn't unload comctl32.dll here as we didn't really
+ // load it above
+ dllComCtl32.Detach();
}
if ( s_pfn_TrackMouseEvent )