升龙物业 老版本 ocx IPO, 加密狗 转值班电话

GetWinVer.cpp 4.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. // GetWinVer.cpp Version 1.1
  2. //
  3. // Copyright (C) 2001-2003 Hans Dietrich
  4. //
  5. // This software is released into the public domain.
  6. // You are free to use it in any way you like, except
  7. // that you may not sell this source code.
  8. //
  9. // This software is provided "as is" with no expressed
  10. // or implied warranty. I accept no liability for any
  11. // damage or loss of business that this software may cause.
  12. //
  13. ///////////////////////////////////////////////////////////////////////////////
  14. #include "stdafx.h"
  15. #include "tchar.h"
  16. #include "GetWinVer.h"
  17. // from winbase.h
  18. #ifndef VER_PLATFORM_WIN32s
  19. #define VER_PLATFORM_WIN32s 0
  20. #endif
  21. #ifndef VER_PLATFORM_WIN32_WINDOWS
  22. #define VER_PLATFORM_WIN32_WINDOWS 1
  23. #endif
  24. #ifndef VER_PLATFORM_WIN32_NT
  25. #define VER_PLATFORM_WIN32_NT 2
  26. #endif
  27. #ifndef VER_PLATFORM_WIN32_CE
  28. #define VER_PLATFORM_WIN32_CE 3
  29. #endif
  30. /*
  31. This table has been assembled from Usenet postings, personal
  32. observations, and reading other people's code. Please feel
  33. free to add to it or correct it.
  34. dwPlatFormID dwMajorVersion dwMinorVersion dwBuildNumber
  35. 95 1 4 0 950
  36. 95 SP1 1 4 0 >950 && <=1080
  37. 95 OSR2 1 4 <10 >1080
  38. 98 1 4 10 1998
  39. 98 SP1 1 4 10 >1998 && <2183
  40. 98 SE 1 4 10 >=2183
  41. ME 1 4 90 3000
  42. NT 3.51 2 3 51
  43. NT 4 2 4 0 1381
  44. 2000 2 5 0 2195
  45. XP 2 5 1 2600
  46. 2003 Server 2 5 2 3790
  47. CE 3
  48. */
  49. ///////////////////////////////////////////////////////////////////////////////
  50. // GetWinVer
  51. BOOL GetWinVer(LPTSTR pszVersion, int *nVersion, LPTSTR pszMajorMinorBuild)
  52. {
  53. if (!pszVersion || !nVersion || !pszMajorMinorBuild)
  54. return FALSE;
  55. lstrcpy(pszVersion, WUNKNOWNSTR);
  56. *nVersion = WUNKNOWN;
  57. OSVERSIONINFO osinfo;
  58. osinfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
  59. if (!GetVersionEx(&osinfo))
  60. return FALSE;
  61. DWORD dwPlatformId = osinfo.dwPlatformId;
  62. DWORD dwMinorVersion = osinfo.dwMinorVersion;
  63. DWORD dwMajorVersion = osinfo.dwMajorVersion;
  64. DWORD dwBuildNumber = osinfo.dwBuildNumber & 0xFFFF; // Win 95 needs this
  65. wsprintf(pszMajorMinorBuild, _T("%u.%u.%u"), dwMajorVersion, dwMinorVersion, dwBuildNumber);
  66. if ((dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) && (dwMajorVersion == 4))
  67. {
  68. if ((dwMinorVersion < 10) && (dwBuildNumber == 950))
  69. {
  70. lstrcpy(pszVersion, W95STR);
  71. *nVersion = W95;
  72. }
  73. else if ((dwMinorVersion < 10) &&
  74. ((dwBuildNumber > 950) && (dwBuildNumber <= 1080)))
  75. {
  76. lstrcpy(pszVersion, W95SP1STR);
  77. *nVersion = W95SP1;
  78. }
  79. else if ((dwMinorVersion < 10) && (dwBuildNumber > 1080))
  80. {
  81. lstrcpy(pszVersion, W95OSR2STR);
  82. *nVersion = W95OSR2;
  83. }
  84. else if ((dwMinorVersion == 10) && (dwBuildNumber == 1998))
  85. {
  86. lstrcpy(pszVersion, W98STR);
  87. *nVersion = W98;
  88. }
  89. else if ((dwMinorVersion == 10) &&
  90. ((dwBuildNumber > 1998) && (dwBuildNumber < 2183)))
  91. {
  92. lstrcpy(pszVersion, W98SP1STR);
  93. *nVersion = W98SP1;
  94. }
  95. else if ((dwMinorVersion == 10) && (dwBuildNumber >= 2183))
  96. {
  97. lstrcpy(pszVersion, W98SESTR);
  98. *nVersion = W98SE;
  99. }
  100. else if (dwMinorVersion == 90)
  101. {
  102. lstrcpy(pszVersion, WMESTR);
  103. *nVersion = WME;
  104. }
  105. }
  106. else if (dwPlatformId == VER_PLATFORM_WIN32_NT)
  107. {
  108. if ((dwMajorVersion == 3) && (dwMinorVersion == 51))
  109. {
  110. lstrcpy(pszVersion, WNT351STR);
  111. *nVersion = WNT351;
  112. }
  113. else if ((dwMajorVersion == 4) && (dwMinorVersion == 0))
  114. {
  115. lstrcpy(pszVersion, WNT4STR);
  116. *nVersion = WNT4;
  117. }
  118. else if ((dwMajorVersion == 5) && (dwMinorVersion == 0))
  119. {
  120. lstrcpy(pszVersion, W2KSTR);
  121. *nVersion = W2K;
  122. }
  123. else if ((dwMajorVersion == 5) && (dwMinorVersion == 1))
  124. {
  125. lstrcpy(pszVersion, WXPSTR);
  126. *nVersion = WXP;
  127. }
  128. else if ((dwMajorVersion == 5) && (dwMinorVersion == 2))
  129. {
  130. lstrcpy(pszVersion, W2003SERVERSTR);
  131. *nVersion = W2003SERVER;
  132. }
  133. }
  134. else if (dwPlatformId == VER_PLATFORM_WIN32_CE)
  135. {
  136. lstrcpy(pszVersion, WCESTR);
  137. *nVersion = WCE;
  138. }
  139. return TRUE;
  140. }