Forum > General

What operating system I'm using?

(1/2) > >>

xinyiman:
{$ifdef win32}
                     ShowMessage('Windows');
{$endif}
{$ifdef Unix}
                     ShowMessage('Linux');
{$endif}

Other possibility? Thank You

faber:

--- Code: ---uses
{$IFDEF WIN32}
Win32Proc,
{$ENDIF}
...
function GetOsVer: string;
begin
{$IFDEF WIN32}
 if WindowsVersion = wv95 then Result:='Windows 95'
 else if WindowsVersion = wvNT4 then Result:='Windows NT v.4'
 else if WindowsVersion = wv98 then Result:='Windows 98'
 else if WindowsVersion = wvMe then Result:='Windows ME'
 else if WindowsVersion = wv2000 then Result:='Windows 2000'
 else if WindowsVersion = wvXP then Result:='Windows XP'
 else if WindowsVersion = wvServer2003 then Result:='Windows Server 2003'
 else if WindowsVersion = wvVista then Result:='Windows Vista'
 else if WindowsVersion = wv7 then Result:='Windows 7'
 else Result:='Unknown';
{$ENDIF}
{$IFDEF UNIX}
 Result:='Linux';
{$ENDIF}
end;
...
ShowMessage(GetOsVer);

--- End code ---

xinyiman:
And to Apple OS?

faber:
{$IFDEF Darwin}

JanRoza:
Download and install DelphiDabbler's CodeSnip database program (www.delphidabbler.com).
It's free and full of handy code snippets and routines you can use in Delphi and/or Lazarus/FPC. In that database are routines like IsVista, IsWin7 and more which give you an exact answer as to the operaton system version.
Per routine the database neatly shows for which version of Delphi and FPC the routine will compile and work.
I've installed it and made a shortcut to it in the Tools menu of Lazarus so I have the whole code repositery just a mouse click away.
 

Navigation

[0] Message Index

[#] Next page

Go to full version