码迷,mamicode.com
首页 > 其他好文 > 详细

获取操作系统版本号

时间:2014-05-14 01:38:18      阅读:417      评论:0      收藏:0      [点我收藏+]

标签:style   blog   class   code   c   tar   

bubuko.com,布布扣
 1 #include "windows.h"
 2 #include "iostream"
 3 
 4 void main(){
 5     DWORD dwIdThis=GetCurrentProcessId();
 6 
 7     DWORD dwVerReq=GetProcessVersion(dwIdThis);
 8     WORD wMajorReq=(WORD)(dwVerReq>>16);
 9     WORD wMinorReq=(WORD)(dwVerReq & 0xffff);
10 
11     printf("Process ID :%d ,requires OS:%d.%d\n",dwIdThis,wMajorReq,wMinorReq);
12 
13     OSVERSIONINFOEX osvix;
14 
15     ZeroMemory(&osvix,sizeof(osvix));
16     osvix.dwOSVersionInfoSize=sizeof(osvix);
17 
18     GetVersionEx(reinterpret_cast<LPOSVERSIONINFO>(&osvix));
19     printf("Running on OS:%d.%d\n",20         osvix.dwMajorVersion,osvix.dwMinorVersion);
21 
22     if(osvix.dwPlatformId==VER_PLATFORM_WIN32_NT && osvix.dwMajorVersion>=5){
23         
24         SetPriorityClass(
25             GetCurrentProcess(),
26             HIGH_PRIORITY_CLASS);
27         printf("Task Manager should now indicate this");
28         printf("process is high priority.\n");
29     
30     }
31 
32     getchar();
33 }
34  
View Code

 

获取操作系统版本号,布布扣,bubuko.com

获取操作系统版本号

标签:style   blog   class   code   c   tar   

原文地址:http://www.cnblogs.com/593213556wuyubao/p/3723964.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!