//聲明:
GetVersionEx(
var lpVersionInformation: TOSVersionInfo {參數是一個結構}
): BOOL;
//結構 TOSVersionInfo 是 _OSVERSIONINFOA 的重命名
_OSVERSIONINFOA = record
dwOSVersionInfoSize: DWORD; {結構大小}
dwMajorVersion: DWORD; {主編號}
dwMinorVersion: DWORD; {次編號}
dwBuildNumber: DWORD; {建立編號}
dwPlatformId: DWORD; {作業平台}
szCSDVersion: array[0..127] of AnsiChar; {更多說明}
end;
{另外參數4(作業平台)可能的取值是:
VER_PLATFORM_WIN32s = 0;
VER_PLATFORM_WIN32_WINDOWS = 1;
VER_PLATFORM_WIN32_NT = 2;
VER_PLATFORM_WIN32_CE = 3;
我沒裝 Vista.
}
//舉例:
var
OsInfo: TOSVersionInfo;
const
s = '主編號: %d' + sLineBreak +
'次編號: %d' + sLineBreak +
'建立編號: %d' + sLineBreak +
'作業平台: %d' + sLineBreak +
'更多說明: %s';
begin
OsInfo.dwOSVersionInfoSize := SizeOf(TOSVersionInfo); {先根據大小要內存}
GetVersionEx(OsInfo);
ShowMessage(Format(s, [OsInfo.dwMajorVersion,
OsInfo.dwMinorVersion,
OsInfo.dwBuildNumber,
OsInfo.dwPlatformId,
OsInfo.szCSDVersion]));
end;
//效果圖: