[Opalvoip-svn] SF.net SVN: opalvoip:[32388] ptlib/branches/v2_14
Brought to you by:
csoutheren,
rjongbloed
From: <rjo...@us...> - 2014-07-27 17:30:50
|
Revision: 32388 http://sourceforge.net/p/opalvoip/code/32388 Author: rjongbloed Date: 2014-07-27 17:30:40 +0000 (Sun, 27 Jul 2014) Log Message: ----------- Update to latest Windows API for operating system version numbers. Modified Paths: -------------- ptlib/branches/v2_14/configure.ac ptlib/branches/v2_14/include/ptlib_config.h.in ptlib/branches/v2_14/src/ptlib/msos/remconn.cxx ptlib/branches/v2_14/src/ptlib/msos/sound_win32.cxx ptlib/branches/v2_14/src/ptlib/msos/svcproc.cxx ptlib/branches/v2_14/src/ptlib/msos/win32.cxx Modified: ptlib/branches/v2_14/configure.ac =================================================================== --- ptlib/branches/v2_14/configure.ac 2014-07-27 16:12:39 UTC (rev 32387) +++ ptlib/branches/v2_14/configure.ac 2014-07-27 17:30:40 UTC (rev 32388) @@ -222,6 +222,10 @@ MY_VERSION_FILE([$VERSION_DIR/version.h], [PTLIB]) +dnl MSWIN_DISPLAY version_helpers,Version Helpers +dnl MSWIN_CHECK_FILE version_helpers,VersionHelpers.h,P_VERSION_HELPERS=1 + + dnl ######################################################################## dnl Find programs we need Modified: ptlib/branches/v2_14/include/ptlib_config.h.in =================================================================== --- ptlib/branches/v2_14/include/ptlib_config.h.in 2014-07-27 16:12:39 UTC (rev 32387) +++ ptlib/branches/v2_14/include/ptlib_config.h.in 2014-07-27 17:30:40 UTC (rev 32388) @@ -65,6 +65,9 @@ #undef WINVER #endif +#undef P_VERSION_HELPERS + + ///////////////////////////////////////////////// // // Language stuff Modified: ptlib/branches/v2_14/src/ptlib/msos/remconn.cxx =================================================================== --- ptlib/branches/v2_14/src/ptlib/msos/remconn.cxx 2014-07-27 16:12:39 UTC (rev 32387) +++ ptlib/branches/v2_14/src/ptlib/msos/remconn.cxx 2014-07-27 17:30:40 UTC (rev 32388) @@ -33,35 +33,11 @@ #include <ptlib.h> #include <ptlib/remconn.h> +#include <ptlib/pprocess.h> + #if P_REMCONN -#define SizeWin400_RAS_MaxEntryName 256 -#define SizeWin400_RAS_MaxPhoneNumber 128 -#define SizeWin400_RAS_MaxCallbackNumber SizeWin400_RAS_MaxPhoneNumber -#define SizeWin400_RAS_MaxDeviceType 16 -#define SizeWin400_RAS_MaxDeviceName 128 - -#define SizeWin400_RASCONN (sizeof(DWORD) + \ - sizeof(HRASCONN) + \ - SizeWin400_RAS_MaxEntryName + 1) - -#define SizeWin400_RASDIALPARAMS (sizeof(DWORD) + \ - SizeWin400_RAS_MaxEntryName + 1 + \ - SizeWin400_RAS_MaxPhoneNumber + 1 + \ - SizeWin400_RAS_MaxCallbackNumber + 1 + \ - UNLEN + 1 + \ - PWLEN + 1 + \ - DNLEN + 1) - -#define SizeWin400_RASCONNSTATUS (sizeof(DWORD) + \ - sizeof(RASCONNSTATE) + \ - sizeof(DWORD) + \ - SizeWin400_RAS_MaxDeviceType + 1 + \ - SizeWin400_RAS_MaxDeviceName + 1) - - - class PRASDLL : public PDynaLink { PCLASSINFO(PRASDLL, PDynaLink) @@ -106,22 +82,6 @@ #define new PNEW -static PBoolean IsWinVer401() -{ - OSVERSIONINFO verinf; - verinf.dwOSVersionInfoSize = sizeof(verinf); - GetVersionEx(&verinf); - - if (verinf.dwPlatformId != VER_PLATFORM_WIN32_NT) - return false; - - if (verinf.dwMajorVersion < 4) - return false; - - return true; -} - - PRemoteConnection::PRemoteConnection() { Construct(); @@ -192,10 +152,8 @@ if (!Ras.IsLoaded()) return false; - PBoolean isVer401 = IsWinVer401(); - RASCONN connection; - connection.dwSize = isVer401 ? sizeof(RASCONN) : SizeWin400_RASCONN; + connection.dwSize = sizeof(RASCONN); LPRASCONN connections = &connection; DWORD size = sizeof(connection); @@ -231,7 +189,7 @@ RASDIALPARAMS params; memset(¶ms, 0, sizeof(params)); - params.dwSize = isVer401 ? sizeof(params) : SizeWin400_RASDIALPARAMS; + params.dwSize = sizeof(params); if (remoteName[0] != '.') { PAssert(remoteName.GetLength() < (PINDEX)sizeof(params.szEntryName)-1, PInvalidParameter); @@ -270,7 +228,7 @@ static int GetRasStatus(HRASCONN rasConnection, DWORD & rasError) { RASCONNSTATUS status; - status.dwSize = IsWinVer401() ? sizeof(status) : SizeWin400_RASCONNSTATUS; + status.dwSize = sizeof(status); rasError = Ras.GetConnectStatus(rasConnection, &status); if (rasError == ERROR_INVALID_HANDLE) { Modified: ptlib/branches/v2_14/src/ptlib/msos/sound_win32.cxx =================================================================== --- ptlib/branches/v2_14/src/ptlib/msos/sound_win32.cxx 2014-07-27 16:12:39 UTC (rev 32387) +++ ptlib/branches/v2_14/src/ptlib/msos/sound_win32.cxx 2014-07-27 17:30:40 UTC (rev 32388) @@ -32,7 +32,9 @@ */ #include <ptlib.h> +#include <ptlib/pprocess.h> + #define P_FORCE_STATIC_PLUGIN 1 #include <ptlib/sound.h> @@ -819,11 +821,7 @@ bool haveControl = true; MIXERLINECONTROLS controls; - if ((activeDirection == Recorder) -#ifndef _WIN32_WCE - && ((DWORD)(LOBYTE(LOWORD(GetVersion()))) < 6) -#endif - ) { //5=XP/win2003 + if ((activeDirection == Recorder) && !PProcess::IsOSVersion(6,0,0)) { //5=XP/win2003 /* There is no "master" for the recording side, so need to find the single selected input or at least individual microphone input No need to do all of these on Vista/Win7/Win2008 as there is Modified: ptlib/branches/v2_14/src/ptlib/msos/svcproc.cxx =================================================================== --- ptlib/branches/v2_14/src/ptlib/msos/svcproc.cxx 2014-07-27 16:12:39 UTC (rev 32387) +++ ptlib/branches/v2_14/src/ptlib/msos/svcproc.cxx 2014-07-27 17:30:40 UTC (rev 32388) @@ -338,10 +338,8 @@ hInstance = (HINSTANCE)arg; - OSVERSIONINFO verinfo; - verinfo.dwOSVersionInfoSize = sizeof(verinfo); - GetVersionEx(&verinfo); - if (verinfo.dwPlatformId != VER_PLATFORM_WIN32_NT) { + + if (!PProcess::IsOSVersion(5,1,0)) { PError << "Unsupported Win32 platform type!" << endl; return 1; } Modified: ptlib/branches/v2_14/src/ptlib/msos/win32.cxx =================================================================== --- ptlib/branches/v2_14/src/ptlib/msos/win32.cxx 2014-07-27 16:12:39 UTC (rev 32387) +++ ptlib/branches/v2_14/src/ptlib/msos/win32.cxx 2014-07-27 17:30:40 UTC (rev 32388) @@ -41,7 +41,7 @@ #include <errors.h> #include <shlobj.h> -#ifdef WIN32 +#ifdef _MSC_VER #ifndef _WIN32_WCE #pragma comment(lib, "mpr.lib") #pragma comment(lib, "Shell32.lib") @@ -56,6 +56,9 @@ #endif #endif +#if P_VERSION_HELPERS + #include <versionhelpers.h> +#endif #define new PNEW @@ -1275,6 +1278,26 @@ PString PProcess::GetOSName() { +#if P_VERSION_HELPERS + if (IsWindows8Point1OrGreater()) + return "8.1"; + if (IsWindows8OrGreater()) + return "8"; + if (IsWindows7SP1OrGreater()) + return "7 sp1"; + if (IsWindows7OrGreater()) + return "7"; + if (IsWindowsVistaSP2OrGreater()) + return "Vista sp2"; + if (IsWindowsVistaSP1OrGreater()) + return "Vista sp1"; + if (IsWindowsVistaOrGreater()) + return "Vista"; + if (IsWindowsXPSP3OrGreater()) + return "XP sp3"; + if (IsWindowsXPOrGreater()) + return "XP"; +#else OSVERSIONINFO info; info.dwOSVersionInfoSize = sizeof(info); GetVersionEx(&info); @@ -1318,6 +1341,7 @@ } } } +#endif // P_VERSION_HELPERS return "?"; } @@ -1359,17 +1383,54 @@ PString PProcess::GetOSVersion() { +#if P_VERSION_HELPERS + if (IsWindows8Point1OrGreater()) + return "v6.3"; + if (IsWindows8OrGreater()) + return "v6.2"; + if (IsWindows7SP1OrGreater()) + return "v6.1.1"; + if (IsWindows7OrGreater()) + return "v6.1"; + if (IsWindowsVistaSP2OrGreater()) + return "v6.0.2"; + if (IsWindowsVistaSP1OrGreater()) + return "v6.0.1"; + if (IsWindowsVistaOrGreater()) + return "v6.0"; + if (IsWindowsXPSP3OrGreater()) + return "v5.1.3"; + if (IsWindowsXPOrGreater()) + return "v5.1"; + return "?"; +#else OSVERSIONINFO info; info.dwOSVersionInfoSize = sizeof(info); GetVersionEx(&info); WORD wBuildNumber = (WORD)info.dwBuildNumber; return psprintf(wBuildNumber > 0 ? "v%u.%u.%u" : "v%u.%u", info.dwMajorVersion, info.dwMinorVersion, wBuildNumber); +#endif // P_VERSION_HELPERS } bool PProcess::IsOSVersion(unsigned major, unsigned minor, unsigned build) { +#if P_VERSION_HELPERS + OSVERSIONINFOEXW osvi = { sizeof(osvi), 0, 0, 0, 0, { 0 }, 0, 0 }; + DWORDLONG const dwlConditionMask = VerSetConditionMask( + VerSetConditionMask( + VerSetConditionMask( + 0, VER_MAJORVERSION, VER_GREATER_EQUAL), + VER_MINORVERSION, VER_GREATER_EQUAL), + VER_SERVICEPACKMAJOR, VER_GREATER_EQUAL); + + osvi.dwMajorVersion = major; + osvi.dwMinorVersion = minor; + osvi.wServicePackMajor = (WORD)build; + + return VerifyVersionInfoW(&osvi, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR, dwlConditionMask) != FALSE; +#else OSVERSIONINFO info; info.dwOSVersionInfoSize = sizeof(info); GetVersionEx(&info); @@ -1385,6 +1446,7 @@ return true; return info.dwBuildNumber >= build; +#endif // P_VERSION_HELPERS } @@ -1393,17 +1455,8 @@ #ifdef _WIN32_WCE return PString("\\Windows"); #else - OSVERSIONINFO info; - info.dwOSVersionInfoSize = sizeof(info); - GetVersionEx(&info); - char dir[_MAX_PATH]; - if (info.dwPlatformId != VER_PLATFORM_WIN32_NT) { - PAssertOS(GetWindowsDirectory(dir, sizeof(dir)) != 0); - return dir; - } - PAssertOS(GetSystemDirectory(dir, sizeof(dir)) != 0); PDirectory sysdir = dir; return sysdir; //+ "drivers\\etc"; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |