- 注册时间
- 2011-3-6
- 最后登录
- 1970-1-1
该用户从未签到
|
// 判断操作系统.cpp : 定义控制台应用程序的入口点。
#include "stdafx.h"
#include <Windows.h>
void GetSystem()
{
int a=0,b=0,i=0,j=0;
_asm
{
pushad
mov ebx,fs:[0x18] ; get self pointer from TEB
mov eax,fs:[0x30] ; get pointer to PEB / database
mov ebx,[eax+0A8h] ; get OSMinorVersion
mov eax,[eax+0A4h] ; get OSMajorVersion
mov j,ebx
mov i,eax
popad
}
if((i==5)&&(j==0))
{
MessageBox(NULL,_T("系统版本为 Windows 2000"),_T("ok"),MB_OK);
}
else if((i==5)&&(j==1))
{
MessageBox(NULL,_T("系统版本为 Windows XP"),_T("ok"),MB_OK);
}
else if((i==5)&&(j==2))
{
MessageBox(NULL,_T("系统版本为 Windows 2003"),_T("ok"),MB_OK);
}
else if((i==6)&&(j==0))
{
MessageBox(NULL,_T("系统版本为 Windows Vista"),_T("ok"),MB_OK);
}
else if((i==6)&&(j==1))
{
MessageBox(NULL,_T("系统版本为 Win7"),_T("ok"),MB_OK);
}
}
int _tmain(int argc, _TCHAR* argv[])
{
GetSystem();
return 0;
}
在后面的学习中,发现 还有一个API函数可以获得系统类型
GetVersionExW |
|