檢查系統版本

Ox9A82發表於2016-03-18
 1 //與核心模組相關
 2 #include <VersionHelpers.h>
 3 #include "windows.h"
 4 ///////////////////////////////
 5 //檢測window版本來決定要不要載入核心模組
 6 #define CHECK_XP_SP3 3
 7 #define CHECK_WIN7_X64 2
 8 #define CHECK_WIN7_X86 1
 9 #define CHECK_BEYOND_WIN7 0
10 #define CHECK_LOW_XP -1
11 DWORD CheckWindowsVersion(void)
12 {
13     SYSTEM_INFO If64Bit;
14     if (IsWindowsXPSP3OrGreater())
15     {
16         if (IsWindows7OrGreater())
17         {
18             GetSystemInfo(&If64Bit);
19             if (IsWindows8OrGreater)
20             {
21                 return CHECK_BEYOND_WIN7;
22             }
23             if (If64Bit.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_AMD64||
24                 If64Bit.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_IA64)
25             {
26                 return CHECK_WIN7_X64;
27             }
28             else
29             {
30                 return CHECK_WIN7_X86;
31             }
32         
33             return CHECK_SUCCESS;
34         }
35         else
36         {
37             return CHECK_XP_SP3;
38         }
39     }
40     else
41     {
42         if (IsWindowsXPOrGreater())
43         {
44             return CHECK_LOW_XP;
45         }
46     }
47 
48 
49 }

 

相關文章