//声明: 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;
//效果图: