api函数:GetVersionEx()
void __fastcall TForm1::FormCreate(Tobject *Sender)
{
OSVERSIONINFO info ;
info.dwOSVersionInfoSize = sizeof (info) ;
GetVersionEx (&info) ;
switch (info.dwPlatfoRmid)
{
case VER_PLATFORM_win32s:
Label1->Caption = "System: windows Win 32s" ;
break ;
case VER_PLATFORM_WIN32_WINDOWS:
Label1->Caption = "System: Windows 95" ;
break ;
case VER_PLATFORM_WIN32_NT:
Label1->Caption = "System: windows NT" ;
break ;
default:
Label1->Caption = "System: Unknown" ;
break ;
}
Label2->Caption = String ("Version: ")
+ String ((int) info.dwMajorVersion) + "." + String((int)info.dwMinorVersion) ;
Label3->Caption = String ("Build: ") + String ((int) (info.dwBuildNumber & 0xFFFF)) ;
Label4->Caption = String ("System Info: ) + info.szCSDVersion + " ;
}
或者
The following code fragment illustrates how to extract information from the GetVersion return value:
dwVersion = GetVersion();
// Get major and minor version numbers of Windows
dwWindowsMajorVersion = (Dword)(LOBYTE(LOWORD(dwVersion)));
dwWindowsMinorVersion = (DWORD)(HIBYTE(LOWORD(dwVersion)));
// Get build numbers for Windows NT or Win32s
if (dwVersion < 0x80000000) // Windows NT
dwBuild = (DWORD)(HIWORD(dwVersion));
else if (dwWindowsMajorVersion < 4) // Win32s
dwBuild = (DWORD)(HIWORD(dwVersion) & ~0x8000);
else // Windows 95 -- No build numbers provided
dwBuild = 0;
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/10748419/viewspace-980827/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/10748419/viewspace-980827/