Title: Windows Version Routines
Question: How do you know what version of Windows your running?
Answer:
Have you ever needed to know the version of Windows your program is running on? Here are some simple routines you can use:
function IsWin95: Bool;
var
Info: TOSVersionInfo;
begin
Info.dwOSVersionInfoSize := SizeOf(Info);
if not GetVersionEx(Info) then
begin
Result := False;
Exit;
end;
if (Info.dwMajorVersion = 4) and (Info.dwMinorVersion = 0) and (Info.dwPlatformId = VER_PLATFORM_WIN32_WINDOWS) then
begin
Result := True;
end
else
begin
Result := False;
end;
end;
function IsWin98: Bool;
var
Info: TOSVersionInfo;
begin
Info.dwOSVersionInfoSize := SizeOf(Info);
if not GetVersionEx(Info) then
begin
Result := False;
Exit;
end;
if (Info.dwMajorVersion = 4) and (Info.dwMinorVersion = 1) and (Info.dwPlatformId = VER_PLATFORM_WIN32_WINDOWS) then
begin
Result := True;
end
else
begin
Result := False;
end;
end;
function IsWinME: Bool;
var
Info: TOSVersionInfo;
begin
Info.dwOSVersionInfoSize := SizeOf(Info);
if not GetVersionEx(Info) then
begin
Result := False;
Exit;
end;
if (Info.dwMajorVersion = 4) and (Info.dwMinorVersion = 9) and (Info.dwPlatformId = VER_PLATFORM_WIN32_WINDOWS) then
begin
Result := True;
end
else
begin
Result := False;
end;
end;
function IsWinNT351: Bool;
var
Info: TOSVersionInfo;
begin
Info.dwOSVersionInfoSize := SizeOf(Info);
if not GetVersionEx(Info) then
begin
Result := False;
Exit;
end;
if (Info.dwMajorVersion = 3) and (Info.dwMinorVersion = 51) and (Info.dwPlatformId = VER_PLATFORM_WIN32_NT) then
begin
Result := True;
end
else
begin
Result := False;
end;
end;
function IsWinNT4: Bool;
var
Info: TOSVersionInfo;
begin
Info.dwOSVersionInfoSize := SizeOf(Info);
if not GetVersionEx(Info) then
begin
Result := False;
Exit;
end;
if (Info.dwMajorVersion = 4) and (Info.dwMinorVersion = 0) and (Info.dwPlatformId = VER_PLATFORM_WIN32_NT) then
begin
Result := True;
end
else
begin
Result := False;
end;
end;
function IsWin2K: Bool;
var
Info: TOSVersionInfo;
begin
Info.dwOSVersionInfoSize := SizeOf(Info);
if not GetVersionEx(Info) then
begin
Result := False;
Exit;
end;
if (Info.dwMajorVersion = 5) and (Info.dwMinorVersion = 0) and (Info.dwPlatformId = VER_PLATFORM_WIN32_NT) then
begin
Result := True;
end
else
begin
Result := False;
end;
end;
function IsWinNT: Bool;
var
Info: TOSVersionInfo;
begin
Info.dwOSVersionInfoSize := SizeOf(Info);
if not GetVersionEx(Info) then
begin
Result := False;
Exit;
end;
if Info.dwPlatformId = VER_PLATFORM_WIN32_NT then
begin
Result := True;
Exit;
end
else
begin
Result := False;
Exit;
end;
end;
function IsWin32s: Bool;
var
Info: TOSVersionInfo;
begin
Info.dwOSVersionInfoSize := SizeOf(Info);
if not GetVersionEx(Info) then
begin
Result := False;
Exit;
end;
if Info.dwPlatformId = VER_PLATFORM_WIN32s then
begin
Result := True;
Exit;
end
else
begin
Result := False;
Exit;
end;
end;
If this topic has already been covered then so be it - here's my take on it...