- // 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 )