svnno****@sourc*****
svnno****@sourc*****
2017年 4月 14日 (金) 16:07:35 JST
Revision: 6686 http://sourceforge.jp/projects/ttssh2/scm/svn/commits/6686 Author: maya Date: 2017-04-14 16:07:34 +0900 (Fri, 14 Apr 2017) Log Message: ----------- Windows バージョン判定関数をリファクタリング Modified Paths: -------------- trunk/teraterm/common/ttlib.c -------------- next part -------------- Modified: trunk/teraterm/common/ttlib.c =================================================================== --- trunk/teraterm/common/ttlib.c 2017-04-12 09:00:48 UTC (rev 6685) +++ trunk/teraterm/common/ttlib.c 2017-04-14 07:07:34 UTC (rev 6686) @@ -1203,11 +1203,8 @@ return pVerSetConditionMask(dwlConditionMask, dwTypeBitMask, dwConditionMask); } -// OS\x82\xAA Windows95 \x82\xA9\x82ǂ\xA4\x82\xA9\x82ʂ\xB7\x82\xE9\x81B -// -// return TRUE: 95 -// FALSE: Not 95 -BOOL IsWindows95() +// OS\x82\xAA \x8Ew\x92肳\x82ꂽ\x83o\x81[\x83W\x83\x87\x83\x93\x82Ɠ\x99\x82\xB5\x82\xA2 \x82\xA9\x82ǂ\xA4\x82\xA9\x82ʂ\xB7\x82\xE9\x81B +BOOL IsWindowsVer(DWORD dwPlatformId, DWORD dwMajorVersion, DWORD dwMinorVersion) { OSVERSIONINFOEX osvi; DWORDLONG dwlConditionMask = 0; @@ -1216,9 +1213,9 @@ ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX)); osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); - osvi.dwPlatformId = VER_PLATFORM_WIN32_WINDOWS; - osvi.dwMajorVersion = 4; - osvi.dwMinorVersion = 0; + osvi.dwPlatformId = dwPlatformId; + osvi.dwMajorVersion = dwMajorVersion; + osvi.dwMinorVersion = dwMinorVersion; dwlConditionMask = myVerSetConditionMask(dwlConditionMask, VER_PLATFORMID, op); dwlConditionMask = myVerSetConditionMask(dwlConditionMask, VER_MAJORVERSION, op); dwlConditionMask = myVerSetConditionMask(dwlConditionMask, VER_MINORVERSION, op); @@ -1226,10 +1223,30 @@ return (ret); } +// OS\x82\xAA \x8Ew\x92肳\x82ꂽ\x83o\x81[\x83W\x83\x87\x83\x93\x88ȍ~ \x82\xA9\x82ǂ\xA4\x82\xA9\x82ʂ\xB7\x82\xE9\x81B +// dwPlatformId \x82\xF0\x8C\xA9\x82Ă\xA2\x82Ȃ\xA2\x82̂\xC5 NT \x83J\x81[\x83l\x83\x8B\x93\xE0\x82ł\xB5\x82\xA9\x94\xE4\x8Ar\x82ł\xAB\x82Ȃ\xA2 +// 5.0 \x88ȏ\xE3\x82Ŕ\xE4\x8Ar\x82\xB7\x82邱\x82\xC6 +BOOL IsWindowsVerOrLater(DWORD dwMajorVersion, DWORD dwMinorVersion) +{ + OSVERSIONINFOEX osvi; + DWORDLONG dwlConditionMask = 0; + int op = VER_GREATER_EQUAL; + BOOL ret; + + ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX)); + osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); + osvi.dwMajorVersion = dwMajorVersion; + osvi.dwMinorVersion = dwMinorVersion; + dwlConditionMask = myVerSetConditionMask(dwlConditionMask, VER_MAJORVERSION, op); + dwlConditionMask = myVerSetConditionMask(dwlConditionMask, VER_MINORVERSION, op); + ret = myVerifyVersionInfo(&osvi, VER_MAJORVERSION | VER_MINORVERSION, dwlConditionMask); + return (ret); +} + // OS\x82\xAA WindowsNT \x83J\x81[\x83l\x83\x8B\x82\xA9\x82ǂ\xA4\x82\xA9\x82ʂ\xB7\x82\xE9\x81B // // return TRUE: NT kernel -// FALSE: Not NT4 kernel +// FALSE: Not NT kernel BOOL IsWindowsNTKernel() { OSVERSIONINFOEX osvi; @@ -1245,13 +1262,16 @@ return (ret); } +// OS\x82\xAA Windows95 \x82\xA9\x82ǂ\xA4\x82\xA9\x82ʂ\xB7\x82\xE9\x81B +BOOL IsWindows95() +{ + return IsWindowsVer(VER_PLATFORM_WIN32_WINDOWS, 4, 0); +} + // OS\x82\xAA WindowsNT4.0 \x82\xA9\x82ǂ\xA4\x82\xA9\x82ʂ\xB7\x82\xE9\x81B -// -// return TRUE: NT4.0 -// FALSE: Not NT4.0 BOOL IsWindowsNT4() { - return is_NT4(); + return IsWindowsVer(VER_PLATFORM_WIN32_NT, 4, 0); } BOOL is_NT4() @@ -1259,40 +1279,9 @@ // VS2013\x88ȏゾ\x82\xC6 GetVersionEx() \x82\xAA\x8Cx\x8D\x90\x82ƂȂ邽\x82߁AVerifyVersionInfo() \x82\xF0\x8Eg\x82\xA4\x81B // \x82\xB5\x82\xA9\x82\xB5\x81AVS2013\x82Ńr\x83\x8B\x83h\x82\xB5\x82\xBD\x83v\x83\x8D\x83O\x83\x89\x83\x80\x82́A\x82\xBB\x82\xE0\x82\xBB\x82\xE0 NT4.0 \x82ł͓\xAE\x8D삵\x82Ȃ\xA2\x82\xBD\x82߁A // \x96\xB3\x8F\xF0\x8C\x8F\x82\xC9 FALSE \x82\xF0\x95Ԃ\xB5\x82Ă\xE0\x82悢\x82\xA9\x82\xE0\x82\xB5\x82\xEA\x82Ȃ\xA2\x81B - OSVERSIONINFOEX osvi; - DWORDLONG dwlConditionMask = 0; - int op = VER_EQUAL; - BOOL ret; - - ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX)); - osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); - osvi.dwPlatformId = VER_PLATFORM_WIN32_NT; - osvi.dwMajorVersion = 4; - dwlConditionMask = myVerSetConditionMask(dwlConditionMask, VER_PLATFORMID, op); - dwlConditionMask = myVerSetConditionMask(dwlConditionMask, VER_MAJORVERSION, op); - ret = myVerifyVersionInfo(&osvi, VER_PLATFORMID | VER_MAJORVERSION, dwlConditionMask); - return (ret); + return IsWindowsVer(VER_PLATFORM_WIN32_NT, 4, 0); } -// OS\x82\xAA \x8Ew\x92肳\x82ꂽ\x83o\x81[\x83W\x83\x87\x83\x93\x88ȍ~ \x82\xA9\x82ǂ\xA4\x82\xA9\x82ʂ\xB7\x82\xE9\x81B - -BOOL IsWindowsVerOrLater(DWORD dwMajorVersion, DWORD dwMinorVersion) -{ - OSVERSIONINFOEX osvi; - DWORDLONG dwlConditionMask = 0; - int op = VER_GREATER_EQUAL; - BOOL ret; - - ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX)); - osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); - osvi.dwMajorVersion = dwMajorVersion; - osvi.dwMinorVersion = dwMinorVersion; - dwlConditionMask = myVerSetConditionMask(dwlConditionMask, VER_MAJORVERSION, op); - dwlConditionMask = myVerSetConditionMask(dwlConditionMask, VER_MINORVERSION, op); - ret = myVerifyVersionInfo(&osvi, VER_MAJORVERSION | VER_MINORVERSION, dwlConditionMask); - return (ret); -} - // OS\x82\xAA Windows2000 \x88ȍ~ \x82\xA9\x82ǂ\xA4\x82\xA9\x82ʂ\xB7\x82\xE9\x81B // // return TRUE: 2000 or later