OS Information 


You probably know the API "GetVersionEx" or the SysUtils variables "Win32Platform" etc. Unfortunately all the infos you're getting there are quite abstract. You have to translate them to get "real" infos about the operating system.

To make your (and my own) life a bit easier, I've written a little function, which collects all important infos and translates them into a practicable format. The function is named "OS" and returns the structure "TOS", which contains all the infos. Here are the definitions:

  TOsEnum = (osNone, osWin95, osWin95osr2, osWin98, osWin98se, osWinME, osWin9xNew,
                     osWinNtOld, osWinNt4, osWin2k, osWinXP, osWin2003, osWinVista, osWinNtNew);
  TOS = record
    major       : cardinal;
    minor       : cardinal;
    build       : cardinal;
    spStr       : string;
    win9x       : boolean;
    win9xEnum   : osNone..osWin9xNew;
    winNt       : boolean;
    winNtEnum   : TOsEnum;
    Enum        : TOsEnum;
    x64         : boolean;
    spNo        : cardinal;
    description : string;

function OS : TOS;

Now if you want to ask whether you're running on a win9x based system or whether the current system is either winME or win2k - such kind of checks are really easy now. Let us see some examples:

if OS.win9x then
  ShowMessage('The current system is a win9x based one.');
if OS.winNt then
  ShowMessage('The current system is a winNt based one.');
if OS.enum in [osWinME..osWin9xNew, osWin2k..osWinNtNew] then
  ShowMessage('The current system is either winME or win2k or something even newer.');
if OS.win9xEnum >= osWin98 then
  ShowMessage('The current system is win98 or something newer, but win9x based.');