don't load comctl32.dll, just get the handle of the already loaded instance of it instead, this avoids accidentally loading 2 different versions of this DLL in the same process (see #10203)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@56863 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
59730a00a6
commit
e2d4ce7d36
@ -73,11 +73,19 @@ enum wxDLFlags
|
||||
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
|
||||
};
|
||||
|
||||
|
@ -966,8 +966,14 @@ int wxApp::GetComCtl32Version()
|
||||
// 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;
|
||||
@ -1005,6 +1011,9 @@ int wxApp::GetComCtl32Version()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// we shouldn't unload it here as we didn't really load it above
|
||||
dllComCtl32.Detach();
|
||||
}
|
||||
|
||||
return s_verComCtl32;
|
||||
|
@ -67,10 +67,17 @@ bool wxMSWDateControls::CheckInitialization()
|
||||
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 );
|
||||
|
||||
|
@ -282,9 +282,11 @@ wxDllType wxDynamicLibrary::GetProgramHandle()
|
||||
|
||||
/* 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 */
|
||||
|
@ -5306,20 +5306,23 @@ bool wxWindowMSW::HandleMouseMove(int x, int y, WXUINT flags)
|
||||
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 )
|
||||
|
Loading…
Reference in New Issue
Block a user