//CString GetOSVersionInfo() //这里直接返回字符串int GetOSVersionInfo() //这里返回对应的数值//1:win2000 2:winxp 3:win2003 4:winvista 5:win7{ 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)) { //return "系统版本为 Windows 2000"; return 1; } else if((i==5)&&(j==1)) { //return "系统版本为 Windows Xp"; return 2; } else if((i==5)&&(j==2)) { //return "系统版本为 Windows 2003"; return 3; } else if((i==6)&&(j==0)) { //return "系统版本为 Windows Vista"; return 4; } else if((i==6)&&(j==1)) { //return "系统版本为 Windows 7"; return 5; }}//以上是两种方式//下面代码 则是判断//可以在按钮或其他地方做个判断int my_version;my_version=GetOSVersionInfo();switch(my_version){case 0:MessageBox("未知系统");break;case 1:MessageBox("win2000");break;case 2:MessageBox("winxp");break;case 3:MessageBox("win2003");break;case 4:MessageBox("win vista");break;case 5:MessageBox("win7");break;}