cache the result of wxGetOsVersion() (heavily modified patch 1783198)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@48621 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
1d9473d33b
commit
5bc3ef05b8
@ -1198,33 +1198,65 @@ bool wxIsPlatform64Bit()
|
||||
}
|
||||
|
||||
wxOperatingSystemId wxGetOsVersion(int *verMaj, int *verMin)
|
||||
{
|
||||
static struct
|
||||
{
|
||||
// this may be false, true or -1 if we tried to initialize but failed
|
||||
int initialized;
|
||||
|
||||
wxOperatingSystemId os;
|
||||
|
||||
int verMaj,
|
||||
verMin;
|
||||
} s_version;
|
||||
|
||||
// query the OS info only once as it's not supposed to change
|
||||
if ( !s_version.initialized )
|
||||
{
|
||||
OSVERSIONINFO info;
|
||||
wxZeroMemory(info);
|
||||
|
||||
info.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
|
||||
info.dwOSVersionInfoSize = sizeof(info);
|
||||
if ( ::GetVersionEx(&info) )
|
||||
{
|
||||
if (verMaj) *verMaj = info.dwMajorVersion;
|
||||
if (verMin) *verMin = info.dwMinorVersion;
|
||||
}
|
||||
s_version.initialized = true;
|
||||
|
||||
#if defined(__WXWINCE__)
|
||||
return wxOS_WINDOWS_CE;
|
||||
s_version.os = wxOS_WINDOWS_CE;
|
||||
#elif defined(__WXMICROWIN__)
|
||||
return wxOS_WINDOWS_MICRO;
|
||||
#else
|
||||
s_version.os = wxOS_WINDOWS_MICRO;
|
||||
#else // "normal" desktop Windows system, use run-time detection
|
||||
switch ( info.dwPlatformId )
|
||||
{
|
||||
case VER_PLATFORM_WIN32_NT:
|
||||
return wxOS_WINDOWS_NT;
|
||||
s_version.os = wxOS_WINDOWS_NT;
|
||||
break;
|
||||
|
||||
case VER_PLATFORM_WIN32_WINDOWS:
|
||||
return wxOS_WINDOWS_9X;
|
||||
s_version.os = wxOS_WINDOWS_9X;
|
||||
break;
|
||||
}
|
||||
#endif // Windows versions
|
||||
|
||||
s_version.verMaj = info.dwMajorVersion;
|
||||
s_version.verMin = info.dwMinorVersion;
|
||||
}
|
||||
else // GetVersionEx() failed
|
||||
{
|
||||
s_version.initialized = -1;
|
||||
}
|
||||
}
|
||||
|
||||
return wxOS_UNKNOWN;
|
||||
#endif
|
||||
if ( s_version.initialized == 1 )
|
||||
{
|
||||
if ( verMaj )
|
||||
*verMaj = s_version.verMaj;
|
||||
if ( verMin )
|
||||
*verMin = s_version.verMin;
|
||||
}
|
||||
|
||||
// this works even if we were not initialized successfully as the initial
|
||||
// values of this field is 0 which is wxOS_UNKNOWN and exactly what we need
|
||||
return s_version.os;
|
||||
}
|
||||
|
||||
wxWinVersion wxGetWinVersion()
|
||||
|
Loading…
Reference in New Issue
Block a user