首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

有没有人知道XP64位系统版本好是多少?解决方案

2012-03-16 
有没有人知道XP64位系统版本好是多少?osvi.dwMajorVersion5&&osvi.dwMinorVersion1//xposvi.dwMajorVe

有没有人知道XP64位系统版本好是多少?
osvi.dwMajorVersion   ==   5   &&osvi.dwMinorVersion   ==   1//xp
osvi.dwMajorVersion   ==   5   &&osvi.dwMinorVersion   ==   3//2003

[解决办法]
MSDN的一个例子 有获取到64位系统
#include <windows.h>
#include <tchar.h>
#include <stdio.h>

#define BUFSIZE 80

typedef void (WINAPI *PGNSI)(LPSYSTEM_INFO);

int __cdecl _tmain()
{
OSVERSIONINFOEX osvi;
SYSTEM_INFO si;
PGNSI pGNSI;
BOOL bOsVersionInfoEx;

ZeroMemory(&si, sizeof(SYSTEM_INFO));
ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX));

// Try calling GetVersionEx using the OSVERSIONINFOEX structure.
// If that fails, try using the OSVERSIONINFO structure.

osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);

if( !(bOsVersionInfoEx = GetVersionEx ((OSVERSIONINFO *) &osvi)) )
{
osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
if (! GetVersionEx ( (OSVERSIONINFO *) &osvi) )
return FALSE;
}

// Call GetNativeSystemInfo if supported
// or GetSystemInfo otherwise.

pGNSI = (PGNSI) GetProcAddress(
GetModuleHandle(TEXT( "kernel32.dll ")),
"GetNativeSystemInfo ");
if(NULL != pGNSI)
pGNSI(&si);
else GetSystemInfo(&si);

switch (osvi.dwPlatformId)
{
// Test for the Windows NT product family.

case VER_PLATFORM_WIN32_NT:

// Test for the specific product.

if ( osvi.dwMajorVersion == 6 && osvi.dwMinorVersion == 0 )
{
if( osvi.wProductType == VER_NT_WORKSTATION )
printf ( "Windows Vista ");
else printf ( "Windows Server \ "Longhorn\ " " );
}

if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 2 )
{
if( GetSystemMetrics(SM_SERVERR2) )
printf( "Microsoft Windows Server 2003 \ "R2\ " ");
else if( osvi.wProductType == VER_NT_WORKSTATION &&
si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_AMD64)
{
printf( "Microsoft Windows XP Professional x64 Edition ");
}
else printf ( "Microsoft Windows Server 2003, ");
}

if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1 )
printf ( "Microsoft Windows XP ");

if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 0 )
printf ( "Microsoft Windows 2000 ");

if ( osvi.dwMajorVersion <= 4 )
printf ( "Microsoft Windows NT ");

// Test for specific product on Windows NT 4.0 SP6 and later.
if( bOsVersionInfoEx )
{
// Test for the workstation type.
if ( osvi.wProductType == VER_NT_WORKSTATION &&
si.wProcessorArchitecture!=PROCESSOR_ARCHITECTURE_AMD64)
{
if( osvi.dwMajorVersion == 4 )
printf ( "Workstation 4.0 " );
else if( osvi.wSuiteMask & VER_SUITE_PERSONAL )
printf ( "Home Edition " );
else printf ( "Professional " );
}

// Test for the server type.
else if ( osvi.wProductType == VER_NT_SERVER ||
osvi.wProductType == VER_NT_DOMAIN_CONTROLLER )


{
if(osvi.dwMajorVersion==5 && osvi.dwMinorVersion==2)
{
if ( si.wProcessorArchitecture ==
PROCESSOR_ARCHITECTURE_IA64 )
{
if( osvi.wSuiteMask & VER_SUITE_DATACENTER )
printf ( "Datacenter Edition "
"for Itanium-based Systems " );
else if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE )
printf ( "Enterprise Edition "
"for Itanium-based Systems " );
}

else if ( si.wProcessorArchitecture ==
PROCESSOR_ARCHITECTURE_AMD64 )
{
if( osvi.wSuiteMask & VER_SUITE_DATACENTER )
printf ( "Datacenter x64 Edition " );
else if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE )
printf ( "Enterprise x64 Edition " );
else printf( "Standard x64 Edition " );
}

else
{
if( osvi.wSuiteMask & VER_SUITE_DATACENTER )
printf ( "Datacenter Edition " );
else if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE )
printf ( "Enterprise Edition " );
else if ( osvi.wSuiteMask & VER_SUITE_BLADE )
printf ( "Web Edition " );
else printf ( "Standard Edition " );
}
}
else if(osvi.dwMajorVersion==5 && osvi.dwMinorVersion==0)
{
if( osvi.wSuiteMask & VER_SUITE_DATACENTER )
printf ( "Datacenter Server " );
else if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE )
printf ( "Advanced Server " );
else printf ( "Server " );
}
else // Windows NT 4.0
{
if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE )
printf ( "Server 4.0, Enterprise Edition " );
else printf ( "Server 4.0 " );
}
}
}

热点排行