/* static */ int wxApp::GetShell32Version() { static int s_verShell32 = -1; if ( s_verShell32 == -1 ) { // we're prepared to handle the errors wxLogNull noLog; wxDynamicLibrary dllShell32(wxT("shell32.dll"), wxDL_VERBATIM); if ( dllShell32.IsLoaded() ) { s_verShell32 = CallDllGetVersion(dllShell32); if ( !s_verShell32 ) { // there doesn't seem to be any way to distinguish between 4.00 // and 4.70 (starting from 4.71 we have DllGetVersion()) so // just assume it is 4.0 s_verShell32 = 400; } } else // failed load the DLL? { s_verShell32 = 0; } } return s_verShell32; }
/* static */ int wxApp::GetComCtl32Version() { // cache the result // // NB: this is MT-ok as in the worst case we'd compute s_verComCtl32 twice, // but as its value should be the same both times it doesn't matter static int s_verComCtl32 = -1; if ( s_verComCtl32 == -1 ) { // we're prepared to handle the errors wxLogNull noLog; // 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 wxLoadedDLL dllComCtl32(wxT("comctl32.dll")); if ( !dllComCtl32.IsLoaded() ) { s_verComCtl32 = 0; return 0; } // try DllGetVersion() for recent DLLs s_verComCtl32 = CallDllGetVersion(dllComCtl32); // if DllGetVersion() is unavailable either during compile or // run-time, try to guess the version otherwise if ( !s_verComCtl32 ) { // InitCommonControlsEx is unique to 4.70 and later void *pfn = dllComCtl32.GetSymbol(wxT("InitCommonControlsEx")); if ( !pfn ) { // not found, must be 4.00 s_verComCtl32 = 400; } else // 4.70+ { // many symbols appeared in comctl32 4.71, could use any of // them except may be DllInstall() pfn = dllComCtl32.GetSymbol(wxT("InitializeFlatSB")); if ( !pfn ) { // not found, must be 4.70 s_verComCtl32 = 470; } else { // found, must be 4.71 or later s_verComCtl32 = 471; } } } } return s_verComCtl32; }