Welcome to the Tweaking4All community forums!
When participating, please keep the Forum Rules in mind!
Topics for particular software or systems: Start your topic link with the name of the application or system.
For example “MacOS X – Your question“, or “MS Word – Your Tip or Trick“.
Please note that switching to another language when reading a post will not bring you to the same post, in Dutch, as there is no translation for that post!
[Solved] Lazarus Pascal - Determine macOS version
Delphi, Lazarus, Free Pascal
(@hans)
Famed Member Admin
Joined: 12 years ago
Posts: 2859
Topic starter
April 14, 2021 11:39 AM
Here an example on how I retrieve the macOS version info for my projects ...
Maybe it is useful for someone out there, as I did get this question and made a small example project for it.
Don't forget:
- {$modeswitch objectivec1}
- uses CocoaAll
unit Unit1;
{$mode objfpc}{$H+}
{$modeswitch objectivec1}
interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, CocoaAll;
type
{ TForm1 }
TForm1 = class(TForm)
Label1: TLabel;
Label2: TLabel;
procedure FormCreate(Sender: TObject);
private
public
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.FormCreate(Sender: TObject);
begin
Label1.Caption := NSProcessInfo.ProcessInfo.operatingSystemVersionString.UTF8String;
Label2.Caption := IntToStr( NSProcessInfo.ProcessInfo.OperatingSystemVersion.majorVersion ) + '.' +
IntToStr( NSProcessInfo.ProcessInfo.OperatingSystemVersion.minorVersion ) + '.' +
IntToStr( NSProcessInfo.ProcessInfo.OperatingSystemVersion.patchVersion );
end;
end.