Recent

Author Topic: What operating system I'm using?  (Read 5880 times)

xinyiman

  • Hero Member
  • *****
  • Posts: 2261
    • Lazarus and Free Pascal italian community
What operating system I'm using?
« on: December 28, 2010, 07:53:53 am »
{$ifdef win32}
                     ShowMessage('Windows');
{$endif}
{$ifdef Unix}
                     ShowMessage('Linux');
{$endif}

Other possibility? Thank You
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

faber

  • Guest
Re: What operating system I'm using?
« Reply #1 on: December 28, 2010, 09:04:51 am »
Code: [Select]
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);

xinyiman

  • Hero Member
  • *****
  • Posts: 2261
    • Lazarus and Free Pascal italian community
Re: What operating system I'm using?
« Reply #2 on: December 28, 2010, 09:33:42 am »
And to Apple OS?
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

faber

  • Guest
Re: What operating system I'm using?
« Reply #3 on: December 28, 2010, 11:46:51 am »
{$IFDEF Darwin}

JanRoza

  • Hero Member
  • *****
  • Posts: 744
    • http://www.silentwings.nl
Re: What operating system I'm using?
« Reply #4 on: December 28, 2010, 12:48:27 pm »
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.
 
OS: Windows 11 / Linux Mint 22.3
       Lazarus 4.6 RC FPC 3.2.2
       CodeTyphon 8.90 FPC 3.3.1

xinyiman

  • Hero Member
  • *****
  • Posts: 2261
    • Lazarus and Free Pascal italian community
Re: What operating system I'm using?
« Reply #5 on: December 28, 2010, 01:18:39 pm »
Thank you
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

 

TinyPortal © 2005-2018