Add semi-public wxDynamicLibrary::MSWGetModuleHandle().

Rename old private wxGetModuleHandle() function to wxDynamicLibrary::
MSWGetModuleHandle() to allow its use in the dll sample.

This fixes the sample compilation with VC6 which lacks GetModuleHandleEx()-
related declarations.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62801 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2009-12-07 03:04:33 +00:00
parent 0530434efc
commit c118a47691
3 changed files with 67 additions and 58 deletions

View File

@@ -27,6 +27,7 @@
#endif
#include "wx/app.h"
#include "wx/dynlib.h"
#include "wx/frame.h"
#include "wx/panel.h"
#include "wx/sizer.h"
@@ -192,16 +193,15 @@ unsigned wxSTDCALL MyAppLauncher(void* event)
// at this point and won't release it until we signal it.
// We need to pass correct HINSTANCE to wxEntry() and the right value is
// HINSTANCE of this DLL, not of the main .exe.
//
// This method of obtaining DLL's instance handle requires at least
// Windows XP/2003. We could also implement DllMain() and remember it from
// there, that would work on older systems too.
HINSTANCE hInstance;
int ret = GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS,
(LPCTSTR)&MyAppLauncher,
&hInstance);
if ( ret == 0 )
// HINSTANCE of this DLL, not of the main .exe, use this MSW-specific wx
// function to get it. Notice that under Windows XP and later the name is
// not needed/used as we retrieve the DLL handle from an address inside it
// but you do need to use the correct name for this code to work with older
// systems as well.
const HINSTANCE
hInstance = wxDynamicLibrary::MSWGetModuleHandle("my_dll",
&gs_wxMainThread);
if ( !hInstance )
return 0; // failed to get DLL's handle
// IMPLEMENT_WXWIN_MAIN does this as the first thing