已失效-------
本帖最后由 suyuxi 于 2016-5-28 15:20 编辑已失效------- 有一个API可以读系统的搞忘了 //获取系统版本
BOOL GetOSName( CString& csOsName )
{
OSVERSIONINFOEX osvi;
SYSTEM_INFO si;
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);
bOsVersionInfoEx = GetVersionEx((OSVERSIONINFO *) &osvi);
if( !bOsVersionInfoEx )
{
osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
if (! GetVersionEx ( (OSVERSIONINFO *) &osvi) )
return FALSE;
}
// Call GetNativeSystemInfo if supported
// or GetSystemInfo otherwise.
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 )
{
csOsName += _T( "Windows Vista " );
}
else
{
csOsName += _T( "Windows Server \"Longhorn\" " );
}
}
if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 2 )
{
if( osvi.wProductType == VER_NT_WORKSTATION &&
si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_AMD64)
{
csOsName += _T( "Microsoft Windows XP Professional x64 Edition " );
}
else
{
csOsName += _T( "Microsoft Windows Server 2003, " );
}
}
if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1 )
{
csOsName += _T( "Microsoft Windows XP " );
}
if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 0 )
{
csOsName += _T( "Microsoft Windows 2000 " );
}
if ( osvi.dwMajorVersion <= 4 )
{
csOsName += _T( "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 )
{
csOsName += _T( "Workstation 4.0 " );
}
else if( osvi.wSuiteMask & VER_SUITE_PERSONAL )
{
csOsName += _T( "Home Edition " );
}
else
{
csOsName += _T( "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 )
{
csOsName += _T("Datacenter Edition for Itanium-based Systems");
}
else if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE )
{
csOsName += _T("Enterprise Edition for Itanium-based Systems");
}
}
else if ( si.wProcessorArchitecture ==
PROCESSOR_ARCHITECTURE_AMD64 )
{
if( osvi.wSuiteMask & VER_SUITE_DATACENTER )
{
csOsName += _T( "Datacenter x64 Edition " );
}
else if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE )
{
}
else
{
csOsName += _T( "Standard x64 Edition " );
}
}
else
{
if( osvi.wSuiteMask & VER_SUITE_DATACENTER )
{
csOsName += _T( "Datacenter Edition " );
}
else if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE )
{
csOsName += _T( "Enterprise Edition " );
}
else if ( osvi.wSuiteMask & VER_SUITE_BLADE )
{
csOsName += _T( "Web Edition " );
}
else
{
csOsName += _T( "Standard Edition " );
}
}
}
else if(osvi.dwMajorVersion==5 && osvi.dwMinorVersion==0)
{
if( osvi.wSuiteMask & VER_SUITE_DATACENTER )
{
csOsName += _T( "Datacenter Server " );
}
else if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE )
{
csOsName += _T( "Advanced Server " );
}
else
{
csOsName += _T( "Server " );
}
}
else// Windows NT 4.0
{
if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE )
{
csOsName += _T( "Server 4.0, Enterprise Edition " );
}
else
{
csOsName += _T( "Server 4.0 " );
}
}
}
}
// Test for specific product on Windows NT 4.0 SP5 and earlier
else
{
HKEY hKey;
TCHAR szProductType;
DWORD dwBufLen=256*sizeof(TCHAR);
LONG lRet;
lRet = RegOpenKeyEx( HKEY_LOCAL_MACHINE,
_T("SYSTEM\\CurrentControlSet\\Control\\ProductOptions"),
0, KEY_QUERY_VALUE, &hKey );
if( lRet != ERROR_SUCCESS )
return FALSE;
lRet = RegQueryValueEx( hKey, TEXT("ProductType"),
NULL, NULL, (LPBYTE) szProductType, &dwBufLen);
RegCloseKey( hKey );
if( (lRet != ERROR_SUCCESS) ||
(dwBufLen > 256*sizeof(TCHAR)) )
return FALSE;
if ( lstrcmpi( TEXT("WINNT"), szProductType) == 0 )
{
csOsName += _T( "Workstation " );
}
if ( lstrcmpi( TEXT("LANMANNT"), szProductType) == 0 )
{
csOsName += _T( "Server " );
}
if ( lstrcmpi( TEXT("SERVERNT"), szProductType) == 0 )
{
csOsName += _T( "Advanced Server " );
}
CString cstmp;
cstmp.Format( _T( "%d.%d " ), osvi.dwMajorVersion, osvi.dwMinorVersion );
csOsName += cstmp;
}
// Display service pack (if any) and build number.
if( osvi.dwMajorVersion == 4 &&
lstrcmpi( osvi.szCSDVersion, TEXT("Service Pack 6") ) == 0 )
{
HKEY hKey;
LONG lRet;
// Test for SP6 versus SP6a.
lRet = RegOpenKeyEx( HKEY_LOCAL_MACHINE,
_T("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Hotfix\\Q246009"),
0, KEY_QUERY_VALUE, &hKey );
if( lRet == ERROR_SUCCESS )
{
CString cstmp;
cstmp.Format( _T( "Service Pack 6a (Build %d)" ), osvi.dwBuildNumber & 0xFFFF );
csOsName += cstmp;
}
else // Windows NT 4.0 prior to SP6a
{
CString cstmp;
cstmp.Format( _T( "%s (Build %d)" ), osvi.szCSDVersion, osvi.dwBuildNumber & 0xFFFF );
csOsName += cstmp;
}
RegCloseKey( hKey );
}
else // not Windows NT 4.0
{
CString cstmp;
cstmp.Format( _T( "%s (Build %d)" ), osvi.szCSDVersion, osvi.dwBuildNumber & 0xFFFF );
csOsName += cstmp;
}
break;
// Test for the Windows Me/98/95.
case VER_PLATFORM_WIN32_WINDOWS:
if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 0)
{
csOsName += _T( "Microsoft Windows 95 " );
if (osvi.szCSDVersion=='C' || osvi.szCSDVersion=='B')
{
csOsName += _T( "OSR2 " );
}
}
if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 10)
{
csOsName += _T("Microsoft Windows 98 ");
if ( osvi.szCSDVersion=='A' || osvi.szCSDVersion=='B')
{
csOsName += _T("SE " );
}
}
if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 90)
{
csOsName += _T("Microsoft Windows Millennium Edition");
}
break;
case VER_PLATFORM_WIN32s:
csOsName += _T("Microsoft Win32s\n");
break;
}
return TRUE;
} 3800CC 发表于 2015-5-31 00:18
//获取系统版本
BOOL GetOSName( CString& csOsName )
{
感谢大神! 读环境变量就可以取出 还有一个是这个 GetVersionEx 本帖最后由 ztd 于 2015-5-31 00:26 编辑
GetNtVersionNumbers
GetNtVersionNumbers(DWORD&dwMajorVer, DWORD& dwMinorVer,DWORD& dwBuildNumber)
本帖最后由 天空の幻像 于 2015-5-31 00:33 编辑
{:1_918:}我有汇编版的哦。。。
.版本 2
.子程序 获取系统版本, 整数型, 公开, 0.未知 1.Win95 2.Win98 3.WinME 4.WinNT 5.Win2000 6.WinXP 7.Win2003 8.Vista 9.Win7 10.Win8
置入代码 ({ 83, 51, 192, 100, 139, 29, 24, 0, 0, 0, 100, 139, 13, 48, 0, 0, 0, 133, 201, 121, 32, 185, 0, 0, 83, 0, 57, 75, 88, 117, 4, 176, 1, 235, 99, 57, 75, 84, 117, 4, 176, 2, 235, 90, 57, 75, 124, 117, 85, 176, 3, 235, 81, 139, 153, 168, 0, 0, 0, 139, 137, 164, 0, 0, 0, 131, 249, 4, 119, 4, 176, 4, 235, 60, 131, 249, 5, 117, 27, 131, 251, 0, 117, 4, 176, 5, 235, 46, 131, 251, 1, 117, 4, 176, 6, 235, 37, 131, 251, 2, 117, 4, 176, 7, 235, 28, 131, 249, 6, 117, 7, 131, 251, 0, 117, 4, 176, 8, 235, 14, 131, 251, 1, 117, 2, 176, 9, 131, 251, 2, 117, 2, 176, 10, 91, 139, 229, 93, 195 })
返回 (0)
天空の幻像 发表于 2015-5-31 00:32
我有汇编版的哦。。。
.版本 2
版本齐了,偶买噶
页:
[1]