Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

87 lines
2.2 KiB

  1. //
  2. // osver.h
  3. //
  4. #include <windows.h>
  5. #ifndef OSVER_H
  6. #define OSVER_H
  7. #define OSVER_ONNT 0x0001
  8. #define OSVER_ONNT5 0x0002
  9. #define OSVER_ON95 0x0004
  10. #define OSVER_ON98 0x0008
  11. #define OSVER_ONFE 0x0010
  12. #define OSVER_ONIMM 0x0020
  13. #define OSVER_ONDBCS 0x0040
  14. #define OSVER_ONNT51 0x0080
  15. #define DECLARE_OSVER() \
  16. DWORD g_dwOsVer; \
  17. UINT g_uACP;
  18. #ifdef __cplusplus
  19. extern "C" {
  20. #endif
  21. extern DWORD g_dwOsVer;
  22. extern UINT g_uACP;
  23. #ifdef __cplusplus
  24. }
  25. #endif
  26. #define IsOnNT() (g_dwOsVer & OSVER_ONNT)
  27. #define IsOnNT5() (g_dwOsVer & OSVER_ONNT5)
  28. #define IsOn95() (g_dwOsVer & OSVER_ON95)
  29. #define IsOn98() (g_dwOsVer & OSVER_ON98)
  30. #define IsOn98orNT5() (g_dwOsVer & (OSVER_ON98 | OSVER_ONNT5))
  31. #define IsOnFE() (g_dwOsVer & OSVER_ONFE)
  32. #define IsOnImm() (g_dwOsVer & OSVER_ONIMM)
  33. #define IsOnDBCS() (g_dwOsVer & OSVER_ONDBCS)
  34. #define IsOnNT51() (g_dwOsVer & OSVER_ONNT51)
  35. #ifdef __cplusplus
  36. inline void InitOSVer()
  37. {
  38. OSVERSIONINFO osvi;
  39. g_uACP = GetACP();
  40. osvi.dwOSVersionInfoSize = sizeof(osvi);
  41. GetVersionEx(&osvi);
  42. g_dwOsVer = 0;
  43. g_dwOsVer |= (VER_PLATFORM_WIN32_NT == osvi.dwPlatformId) ? OSVER_ONNT : 0;
  44. g_dwOsVer |= (IsOnNT() && (osvi.dwMajorVersion >= 0x00000005)) ? OSVER_ONNT5 : 0;
  45. g_dwOsVer |= (IsOnNT5() && (osvi.dwMinorVersion >= 0x00000001)) ? OSVER_ONNT51 : 0;
  46. g_dwOsVer |= (!IsOnNT() && (osvi.dwMinorVersion >= 0x0000000A)) ? OSVER_ON98 : 0;
  47. g_dwOsVer |= (!IsOnNT() && !IsOn98()) ? OSVER_ON95 : 0;
  48. switch (g_uACP)
  49. {
  50. case 932:
  51. case 936:
  52. case 949:
  53. case 950:
  54. g_dwOsVer |= OSVER_ONFE;
  55. break;
  56. }
  57. if (IsOnNT5()) {
  58. #if(_WIN32_WINNT >= 0x0500)
  59. /*
  60. * Only NT5 or later suppoert SM_IMMENABLED
  61. */
  62. if (GetSystemMetrics(SM_IMMENABLED)) {
  63. g_dwOsVer |= OSVER_ONIMM;
  64. }
  65. #endif
  66. }
  67. if (GetSystemMetrics(SM_DBCSENABLED)) {
  68. if (!IsOnNT5())
  69. g_dwOsVer |= OSVER_ONIMM;
  70. g_dwOsVer |= OSVER_ONDBCS;
  71. }
  72. }
  73. #endif // __cplusplus
  74. #endif // OSVER_H