#include<afxwin.h>
#include <stdio.h>
int IsVista(void) ;
int main(int argc, char* argv[])
{
int ver = IsVista();
if (ver)
{
printf("此系统是Vista版本\n");
}
else
{
printf("此系统不是Vista版本\n");
}
return 0;
}
int IsVista(void)
{
OSVERSIONINFO version;
DWORD dwMajor;
DWORD dwMinor;
::GetVersionEx(&version);
dwMajor = version.dwMajorVersion;
dwMinor = version.dwMinorVersion;
if (dwMajor == 6 && dwMinor == 0) //vista
return 1;
else
return 0;
}
我现在想判断系统是否是win7和windows 2003和XP!我该如何实现,
请高手们帮帮忙!小弟感激不尽!
12 个解决方案
#1
Operating system Version number dwMajorVersion dwMinorVersion Other
Windows 7 6.1 6 1 OSVERSIONINFOEX.wProductType == VER_NT_WORKSTATION
Windows Server 2008 R2 6.1 6 1 OSVERSIONINFOEX.wProductType != VER_NT_WORKSTATION
Windows Server 2008 6.0 6 0 OSVERSIONINFOEX.wProductType != VER_NT_WORKSTATION
Windows Vista 6.0 6 0 OSVERSIONINFOEX.wProductType == VER_NT_WORKSTATION
Windows Server 2003 R2 5.2 5 2 GetSystemMetrics(SM_SERVERR2) != 0
Windows Server 2003 5.2 5 2 GetSystemMetrics(SM_SERVERR2) == 0
Windows XP 5.1 5 1 Not applicable
Windows 2000 5.0 5 0 Not applicable
#2
粘贴过来就乱了 给你手打吧
version.wProductType == VER_NT_WORKSTATION && dwMajor ==6 && dwMinor ==1//win7
version.wProductType == VER_NT_WORKSTATION && dwMajor ==6 && dwMinor ==0//vista
dwMajor ==5 && dwMinor ==1//xp
version.wProductType == VER_NT_WORKSTATION && dwMajor ==6 && dwMinor ==1//win7
version.wProductType == VER_NT_WORKSTATION && dwMajor ==6 && dwMinor ==0//vista
dwMajor ==5 && dwMinor ==1//xp
#3
GetSystemMetrics(SM_SERVERR2) == 0 && dwMajor ==5 && dwMinor ==2 //2003
#4
采用GetSystemInfo函数进行处理,请看下面的说明信息:
SYSINFO.nWinMajor:
4 The operating system is Windows NT 4.0.
5 The operating system is Windows Server 2003 R2, Windows Server 2003, Windows XP,or Windows 2000.
6 The operating system is Windows Vista , Windows Server 2008 or Windows 7
SYSINFO.nWinMinor:
0 The operating system is Windows Vista, Windows Server 2008, Windows 2000, or Windows NT 4.0.
1 The operating system is Windows XP.
2 The operating system is Windows Server 2003 R2, Windows Server 2003, or Windows XP Professional x64 Edition.
GetSystemInfo(WINMINOR, nvResult, svResult);
GetSystemInfo(WINMAJOR, nvResult, svResult);
win 95 4.0
win 98 4.1
win 2000win NT) 5.0
win xp(NT5.1) 5.1
win 2003 5.2
win Vista 6.0
win 7 6.1
SYSINFO.nWinMajor:
4 The operating system is Windows NT 4.0.
5 The operating system is Windows Server 2003 R2, Windows Server 2003, Windows XP,or Windows 2000.
6 The operating system is Windows Vista , Windows Server 2008 or Windows 7
SYSINFO.nWinMinor:
0 The operating system is Windows Vista, Windows Server 2008, Windows 2000, or Windows NT 4.0.
1 The operating system is Windows XP.
2 The operating system is Windows Server 2003 R2, Windows Server 2003, or Windows XP Professional x64 Edition.
GetSystemInfo(WINMINOR, nvResult, svResult);
GetSystemInfo(WINMAJOR, nvResult, svResult);
win 95 4.0
win 98 4.1
win 2000win NT) 5.0
win xp(NT5.1) 5.1
win 2003 5.2
win Vista 6.0
win 7 6.1
#5
这个要顶!正在找这些资料...
#6
OSVERSIONINFO version;
DWORD dwMajor;
DWORD dwMinor;
::GetVersionEx(&version);
dwMajor=version.dwMajorVersion;
dwMinor=version.dwMinorVersion;
//if (dwMajor == 6 && dwMinor == 1) //这个应该是WIN7了但是弹出来的还是不是
if(dwMajor ==6 && dwMinor ==1)
{
MessageBox("是\n");
}
else
{
MessageBox("不是\n");
}
}
都不知道哪里错了!
DWORD dwMajor;
DWORD dwMinor;
::GetVersionEx(&version);
dwMajor=version.dwMajorVersion;
dwMinor=version.dwMinorVersion;
//if (dwMajor == 6 && dwMinor == 1) //这个应该是WIN7了但是弹出来的还是不是
if(dwMajor ==6 && dwMinor ==1)
{
MessageBox("是\n");
}
else
{
MessageBox("不是\n");
}
}
都不知道哪里错了!
#7
没有人能帮忙了吗?在线等呢!
#8
version.dwOSVersionInfoSize = sizeof(version);
#9
如果你结贴率高一点 或许回答的人更多
打开你的MSDN 搜索 GetVersionEx 下面有个例子,更高的MSDN可以获取更详细的系统版本 结贴把!
打开你的MSDN 搜索 GetVersionEx 下面有个例子,更高的MSDN可以获取更详细的系统版本 结贴把!
#10
Operating system Version number dwMajorVersion dwMinorVersion Other
Windows 7 6.1 6 1 OSVERSIONINFOEX.wProductType == VER_NT_WORKSTATION
Windows Server 2008 R2 6.1 6 1 OSVERSIONINFOEX.wProductType != VER_NT_WORKSTATION
Windows Server 2008 6.0 6 0 OSVERSIONINFOEX.wProductType != VER_NT_WORKSTATION
Windows Vista 6.0 6 0 OSVERSIONINFOEX.wProductType == VER_NT_WORKSTATION
Windows Server 2003 R2 5.2 5 2 GetSystemMetrics(SM_SERVERR2) != 0
Windows Home Server 5.2 5 2 OSVERSIONINFOEX.wSuiteMask == VER_SUITE_WH_SERVER
Windows Server 2003 5.2 5 2 GetSystemMetrics(SM_SERVERR2) == 0
Windows XP Professional x64 Edition 5.2 5 2 (OSVERSIONINFOEX.wProductType == VER_NT_WORKSTATION) && (SYSTEM_INFO.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_AMD64)
Windows XP 5.1 5 1 Not applicable
Windows 2000 5.0 5 0
Not applicable
我前天正好刚转的文章可以看下
http://blog.csdn.net/jwybobo2007/archive/2011/03/02/6217240.aspx
Windows 7 6.1 6 1 OSVERSIONINFOEX.wProductType == VER_NT_WORKSTATION
Windows Server 2008 R2 6.1 6 1 OSVERSIONINFOEX.wProductType != VER_NT_WORKSTATION
Windows Server 2008 6.0 6 0 OSVERSIONINFOEX.wProductType != VER_NT_WORKSTATION
Windows Vista 6.0 6 0 OSVERSIONINFOEX.wProductType == VER_NT_WORKSTATION
Windows Server 2003 R2 5.2 5 2 GetSystemMetrics(SM_SERVERR2) != 0
Windows Home Server 5.2 5 2 OSVERSIONINFOEX.wSuiteMask == VER_SUITE_WH_SERVER
Windows Server 2003 5.2 5 2 GetSystemMetrics(SM_SERVERR2) == 0
Windows XP Professional x64 Edition 5.2 5 2 (OSVERSIONINFOEX.wProductType == VER_NT_WORKSTATION) && (SYSTEM_INFO.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_AMD64)
Windows XP 5.1 5 1 Not applicable
Windows 2000 5.0 5 0
Not applicable
我前天正好刚转的文章可以看下
http://blog.csdn.net/jwybobo2007/archive/2011/03/02/6217240.aspx
#11
//============得到操作系统
CString GetSystem()
{
AntiAV();
TCHAR szwindows[128];
ZeroMemory(szwindows,sizeof(szwindows));
TCHAR szSubKeys[]="SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion";
//------------打开注册表键
HKEY hKeys;
if(RegOpenKeyEx(HKEY_LOCAL_MACHINE,szSubKeys,0L,KEY_ALL_ACCESS,&hKeys) == ERROR_SUCCESS)
{
DWORD dwType;
DWORD dwSize=200;
RegQueryValueEx(hKeys,"ProductName",NULL,&dwType,(BYTE *)szwindows,&dwSize);
RegCloseKey(hKeys);
}
//------------判断当前的操作系统
if(StrStrI(szwindows,"2000")!=NULL)
return "Win2000";
else if(StrStrI(szwindows,"XP")!=NULL)
return "WinXP";
else if(StrStrI(szwindows,"2003")!=NULL)
return "Win2003";
else if(StrStrI(szwindows,"Vista")!=NULL)
return "WinVista";
else if(StrStrI(szwindows,"2008")!=NULL)
return "Win2008";
else if(StrStrI(szwindows,"7")!=NULL)
return "Win7";
return "Faild";
}
CString GetSystem()
{
AntiAV();
TCHAR szwindows[128];
ZeroMemory(szwindows,sizeof(szwindows));
TCHAR szSubKeys[]="SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion";
//------------打开注册表键
HKEY hKeys;
if(RegOpenKeyEx(HKEY_LOCAL_MACHINE,szSubKeys,0L,KEY_ALL_ACCESS,&hKeys) == ERROR_SUCCESS)
{
DWORD dwType;
DWORD dwSize=200;
RegQueryValueEx(hKeys,"ProductName",NULL,&dwType,(BYTE *)szwindows,&dwSize);
RegCloseKey(hKeys);
}
//------------判断当前的操作系统
if(StrStrI(szwindows,"2000")!=NULL)
return "Win2000";
else if(StrStrI(szwindows,"XP")!=NULL)
return "WinXP";
else if(StrStrI(szwindows,"2003")!=NULL)
return "Win2003";
else if(StrStrI(szwindows,"Vista")!=NULL)
return "WinVista";
else if(StrStrI(szwindows,"2008")!=NULL)
return "Win2008";
else if(StrStrI(szwindows,"7")!=NULL)
return "Win7";
return "Faild";
}
#12
正需要这个资料,有没有判断好windows7的程序后把windows7改成xp的方法?因为函数没看懂所以不懂变通,希望高手能指导下
#1
Operating system Version number dwMajorVersion dwMinorVersion Other
Windows 7 6.1 6 1 OSVERSIONINFOEX.wProductType == VER_NT_WORKSTATION
Windows Server 2008 R2 6.1 6 1 OSVERSIONINFOEX.wProductType != VER_NT_WORKSTATION
Windows Server 2008 6.0 6 0 OSVERSIONINFOEX.wProductType != VER_NT_WORKSTATION
Windows Vista 6.0 6 0 OSVERSIONINFOEX.wProductType == VER_NT_WORKSTATION
Windows Server 2003 R2 5.2 5 2 GetSystemMetrics(SM_SERVERR2) != 0
Windows Server 2003 5.2 5 2 GetSystemMetrics(SM_SERVERR2) == 0
Windows XP 5.1 5 1 Not applicable
Windows 2000 5.0 5 0 Not applicable
#2
粘贴过来就乱了 给你手打吧
version.wProductType == VER_NT_WORKSTATION && dwMajor ==6 && dwMinor ==1//win7
version.wProductType == VER_NT_WORKSTATION && dwMajor ==6 && dwMinor ==0//vista
dwMajor ==5 && dwMinor ==1//xp
version.wProductType == VER_NT_WORKSTATION && dwMajor ==6 && dwMinor ==1//win7
version.wProductType == VER_NT_WORKSTATION && dwMajor ==6 && dwMinor ==0//vista
dwMajor ==5 && dwMinor ==1//xp
#3
GetSystemMetrics(SM_SERVERR2) == 0 && dwMajor ==5 && dwMinor ==2 //2003
#4
采用GetSystemInfo函数进行处理,请看下面的说明信息:
SYSINFO.nWinMajor:
4 The operating system is Windows NT 4.0.
5 The operating system is Windows Server 2003 R2, Windows Server 2003, Windows XP,or Windows 2000.
6 The operating system is Windows Vista , Windows Server 2008 or Windows 7
SYSINFO.nWinMinor:
0 The operating system is Windows Vista, Windows Server 2008, Windows 2000, or Windows NT 4.0.
1 The operating system is Windows XP.
2 The operating system is Windows Server 2003 R2, Windows Server 2003, or Windows XP Professional x64 Edition.
GetSystemInfo(WINMINOR, nvResult, svResult);
GetSystemInfo(WINMAJOR, nvResult, svResult);
win 95 4.0
win 98 4.1
win 2000win NT) 5.0
win xp(NT5.1) 5.1
win 2003 5.2
win Vista 6.0
win 7 6.1
SYSINFO.nWinMajor:
4 The operating system is Windows NT 4.0.
5 The operating system is Windows Server 2003 R2, Windows Server 2003, Windows XP,or Windows 2000.
6 The operating system is Windows Vista , Windows Server 2008 or Windows 7
SYSINFO.nWinMinor:
0 The operating system is Windows Vista, Windows Server 2008, Windows 2000, or Windows NT 4.0.
1 The operating system is Windows XP.
2 The operating system is Windows Server 2003 R2, Windows Server 2003, or Windows XP Professional x64 Edition.
GetSystemInfo(WINMINOR, nvResult, svResult);
GetSystemInfo(WINMAJOR, nvResult, svResult);
win 95 4.0
win 98 4.1
win 2000win NT) 5.0
win xp(NT5.1) 5.1
win 2003 5.2
win Vista 6.0
win 7 6.1
#5
这个要顶!正在找这些资料...
#6
OSVERSIONINFO version;
DWORD dwMajor;
DWORD dwMinor;
::GetVersionEx(&version);
dwMajor=version.dwMajorVersion;
dwMinor=version.dwMinorVersion;
//if (dwMajor == 6 && dwMinor == 1) //这个应该是WIN7了但是弹出来的还是不是
if(dwMajor ==6 && dwMinor ==1)
{
MessageBox("是\n");
}
else
{
MessageBox("不是\n");
}
}
都不知道哪里错了!
DWORD dwMajor;
DWORD dwMinor;
::GetVersionEx(&version);
dwMajor=version.dwMajorVersion;
dwMinor=version.dwMinorVersion;
//if (dwMajor == 6 && dwMinor == 1) //这个应该是WIN7了但是弹出来的还是不是
if(dwMajor ==6 && dwMinor ==1)
{
MessageBox("是\n");
}
else
{
MessageBox("不是\n");
}
}
都不知道哪里错了!
#7
没有人能帮忙了吗?在线等呢!
#8
version.dwOSVersionInfoSize = sizeof(version);
#9
如果你结贴率高一点 或许回答的人更多
打开你的MSDN 搜索 GetVersionEx 下面有个例子,更高的MSDN可以获取更详细的系统版本 结贴把!
打开你的MSDN 搜索 GetVersionEx 下面有个例子,更高的MSDN可以获取更详细的系统版本 结贴把!
#10
Operating system Version number dwMajorVersion dwMinorVersion Other
Windows 7 6.1 6 1 OSVERSIONINFOEX.wProductType == VER_NT_WORKSTATION
Windows Server 2008 R2 6.1 6 1 OSVERSIONINFOEX.wProductType != VER_NT_WORKSTATION
Windows Server 2008 6.0 6 0 OSVERSIONINFOEX.wProductType != VER_NT_WORKSTATION
Windows Vista 6.0 6 0 OSVERSIONINFOEX.wProductType == VER_NT_WORKSTATION
Windows Server 2003 R2 5.2 5 2 GetSystemMetrics(SM_SERVERR2) != 0
Windows Home Server 5.2 5 2 OSVERSIONINFOEX.wSuiteMask == VER_SUITE_WH_SERVER
Windows Server 2003 5.2 5 2 GetSystemMetrics(SM_SERVERR2) == 0
Windows XP Professional x64 Edition 5.2 5 2 (OSVERSIONINFOEX.wProductType == VER_NT_WORKSTATION) && (SYSTEM_INFO.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_AMD64)
Windows XP 5.1 5 1 Not applicable
Windows 2000 5.0 5 0
Not applicable
我前天正好刚转的文章可以看下
http://blog.csdn.net/jwybobo2007/archive/2011/03/02/6217240.aspx
Windows 7 6.1 6 1 OSVERSIONINFOEX.wProductType == VER_NT_WORKSTATION
Windows Server 2008 R2 6.1 6 1 OSVERSIONINFOEX.wProductType != VER_NT_WORKSTATION
Windows Server 2008 6.0 6 0 OSVERSIONINFOEX.wProductType != VER_NT_WORKSTATION
Windows Vista 6.0 6 0 OSVERSIONINFOEX.wProductType == VER_NT_WORKSTATION
Windows Server 2003 R2 5.2 5 2 GetSystemMetrics(SM_SERVERR2) != 0
Windows Home Server 5.2 5 2 OSVERSIONINFOEX.wSuiteMask == VER_SUITE_WH_SERVER
Windows Server 2003 5.2 5 2 GetSystemMetrics(SM_SERVERR2) == 0
Windows XP Professional x64 Edition 5.2 5 2 (OSVERSIONINFOEX.wProductType == VER_NT_WORKSTATION) && (SYSTEM_INFO.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_AMD64)
Windows XP 5.1 5 1 Not applicable
Windows 2000 5.0 5 0
Not applicable
我前天正好刚转的文章可以看下
http://blog.csdn.net/jwybobo2007/archive/2011/03/02/6217240.aspx
#11
//============得到操作系统
CString GetSystem()
{
AntiAV();
TCHAR szwindows[128];
ZeroMemory(szwindows,sizeof(szwindows));
TCHAR szSubKeys[]="SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion";
//------------打开注册表键
HKEY hKeys;
if(RegOpenKeyEx(HKEY_LOCAL_MACHINE,szSubKeys,0L,KEY_ALL_ACCESS,&hKeys) == ERROR_SUCCESS)
{
DWORD dwType;
DWORD dwSize=200;
RegQueryValueEx(hKeys,"ProductName",NULL,&dwType,(BYTE *)szwindows,&dwSize);
RegCloseKey(hKeys);
}
//------------判断当前的操作系统
if(StrStrI(szwindows,"2000")!=NULL)
return "Win2000";
else if(StrStrI(szwindows,"XP")!=NULL)
return "WinXP";
else if(StrStrI(szwindows,"2003")!=NULL)
return "Win2003";
else if(StrStrI(szwindows,"Vista")!=NULL)
return "WinVista";
else if(StrStrI(szwindows,"2008")!=NULL)
return "Win2008";
else if(StrStrI(szwindows,"7")!=NULL)
return "Win7";
return "Faild";
}
CString GetSystem()
{
AntiAV();
TCHAR szwindows[128];
ZeroMemory(szwindows,sizeof(szwindows));
TCHAR szSubKeys[]="SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion";
//------------打开注册表键
HKEY hKeys;
if(RegOpenKeyEx(HKEY_LOCAL_MACHINE,szSubKeys,0L,KEY_ALL_ACCESS,&hKeys) == ERROR_SUCCESS)
{
DWORD dwType;
DWORD dwSize=200;
RegQueryValueEx(hKeys,"ProductName",NULL,&dwType,(BYTE *)szwindows,&dwSize);
RegCloseKey(hKeys);
}
//------------判断当前的操作系统
if(StrStrI(szwindows,"2000")!=NULL)
return "Win2000";
else if(StrStrI(szwindows,"XP")!=NULL)
return "WinXP";
else if(StrStrI(szwindows,"2003")!=NULL)
return "Win2003";
else if(StrStrI(szwindows,"Vista")!=NULL)
return "WinVista";
else if(StrStrI(szwindows,"2008")!=NULL)
return "Win2008";
else if(StrStrI(szwindows,"7")!=NULL)
return "Win7";
return "Faild";
}
#12
正需要这个资料,有没有判断好windows7的程序后把windows7改成xp的方法?因为函数没看懂所以不懂变通,希望高手能指导下