implement wxLoadedDLL, a safer alternative to wxDL_GET_LOADED (closes #10208)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@57405 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -80,7 +80,9 @@ enum wxDLFlags
|
|||||||
|
|
||||||
wxDL_QUIET = 0x00000020, // don't log an error if failed to load
|
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
|
// this flag is dangerous, for internal use of wxMSW only, don't use at all
|
||||||
|
// and especially don't use directly, use wxLoadedDLL instead if you really
|
||||||
|
// do need it
|
||||||
wxDL_GET_LOADED = 0x00000040, // Win32 only: return handle of already
|
wxDL_GET_LOADED = 0x00000040, // Win32 only: return handle of already
|
||||||
// loaded DLL or NULL otherwise; Unload()
|
// loaded DLL or NULL otherwise; Unload()
|
||||||
// should not be called so don't forget to
|
// should not be called so don't forget to
|
||||||
@@ -376,6 +378,28 @@ protected:
|
|||||||
DECLARE_NO_COPY_CLASS(wxDynamicLibrary)
|
DECLARE_NO_COPY_CLASS(wxDynamicLibrary)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef __WXMSW__
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// wxLoadedDLL is a MSW-only internal helper class allowing to dynamically bind
|
||||||
|
// to a DLL already loaded into the project address space
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class wxLoadedDLL : public wxDynamicLibrary
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
wxLoadedDLL(const wxString& dllname)
|
||||||
|
: wxDynamicLibrary(dllname, wxDL_GET_LOADED | wxDL_VERBATIM | wxDL_QUIET)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
~wxLoadedDLL()
|
||||||
|
{
|
||||||
|
Detach();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // __WXMSW__
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// Interesting defines
|
// Interesting defines
|
||||||
|
@@ -917,10 +917,7 @@ int wxApp::GetComCtl32Version()
|
|||||||
// depending on the OS version and the presence of the manifest, it can
|
// 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
|
// be either v5 or v6 and instead of trying to guess it just get the
|
||||||
// handle of the already loaded version
|
// handle of the already loaded version
|
||||||
wxDynamicLibrary dllComCtl32(_T("comctl32.dll"),
|
wxLoadedDLL dllComCtl32(_T("comctl32.dll"));
|
||||||
wxDL_VERBATIM |
|
|
||||||
wxDL_QUIET |
|
|
||||||
wxDL_GET_LOADED);
|
|
||||||
if ( !dllComCtl32.IsLoaded() )
|
if ( !dllComCtl32.IsLoaded() )
|
||||||
{
|
{
|
||||||
s_verComCtl32 = 0;
|
s_verComCtl32 = 0;
|
||||||
@@ -958,9 +955,6 @@ int wxApp::GetComCtl32Version()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// we shouldn't unload it here as we didn't really load it above
|
|
||||||
dllComCtl32.Detach();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return s_verComCtl32;
|
return s_verComCtl32;
|
||||||
|
@@ -68,12 +68,8 @@ bool wxMSWDateControls::CheckInitialization()
|
|||||||
icex.dwICC = ICC_DATE_CLASSES;
|
icex.dwICC = ICC_DATE_CLASSES;
|
||||||
|
|
||||||
// see comment in wxApp::GetComCtl32Version() explaining the
|
// see comment in wxApp::GetComCtl32Version() explaining the
|
||||||
// use of wxDL_GET_LOADED
|
// use of wxLoadedDLL
|
||||||
wxDynamicLibrary dllComCtl32(_T("comctl32.dll"),
|
wxLoadedDLL dllComCtl32(_T("comctl32.dll"));
|
||||||
wxDL_VERBATIM |
|
|
||||||
wxDL_QUIET |
|
|
||||||
wxDL_GET_LOADED);
|
|
||||||
|
|
||||||
if ( dllComCtl32.IsLoaded() )
|
if ( dllComCtl32.IsLoaded() )
|
||||||
{
|
{
|
||||||
wxLogNull noLog;
|
wxLogNull noLog;
|
||||||
@@ -81,8 +77,6 @@ bool wxMSWDateControls::CheckInitialization()
|
|||||||
typedef BOOL (WINAPI *ICCEx_t)(INITCOMMONCONTROLSEX *);
|
typedef BOOL (WINAPI *ICCEx_t)(INITCOMMONCONTROLSEX *);
|
||||||
wxDYNLIB_FUNCTION( ICCEx_t, InitCommonControlsEx, dllComCtl32 );
|
wxDYNLIB_FUNCTION( ICCEx_t, InitCommonControlsEx, dllComCtl32 );
|
||||||
|
|
||||||
dllComCtl32.Detach();
|
|
||||||
|
|
||||||
if ( pfnInitCommonControlsEx )
|
if ( pfnInitCommonControlsEx )
|
||||||
{
|
{
|
||||||
s_initResult = (*pfnInitCommonControlsEx)(&icex);
|
s_initResult = (*pfnInitCommonControlsEx)(&icex);
|
||||||
|
@@ -5289,11 +5289,8 @@ bool wxWindowMSW::HandleMouseMove(int x, int y, WXUINT flags)
|
|||||||
if ( !s_initDone )
|
if ( !s_initDone )
|
||||||
{
|
{
|
||||||
// see comment in wxApp::GetComCtl32Version() explaining the
|
// see comment in wxApp::GetComCtl32Version() explaining the
|
||||||
// use of wxDL_GET_LOADED
|
// use of wxLoadedDLL
|
||||||
wxDynamicLibrary dllComCtl32(_T("comctl32.dll"),
|
wxLoadedDLL dllComCtl32(_T("comctl32.dll"));
|
||||||
wxDL_VERBATIM |
|
|
||||||
wxDL_QUIET |
|
|
||||||
wxDL_GET_LOADED);
|
|
||||||
if ( dllComCtl32.IsLoaded() )
|
if ( dllComCtl32.IsLoaded() )
|
||||||
{
|
{
|
||||||
s_pfn_TrackMouseEvent = (_TrackMouseEvent_t)
|
s_pfn_TrackMouseEvent = (_TrackMouseEvent_t)
|
||||||
@@ -5301,10 +5298,6 @@ bool wxWindowMSW::HandleMouseMove(int x, int y, WXUINT flags)
|
|||||||
}
|
}
|
||||||
|
|
||||||
s_initDone = true;
|
s_initDone = true;
|
||||||
|
|
||||||
// we shouldn't unload comctl32.dll here as we didn't really
|
|
||||||
// load it above
|
|
||||||
dllComCtl32.Detach();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( s_pfn_TrackMouseEvent )
|
if ( s_pfn_TrackMouseEvent )
|
||||||
|
Reference in New Issue
Block a user