Bonjour à toutes et à tous,

Dans un programme écrit avec Lazarus, je souhaite afficher un fichier PDF via la fonction "Process",

Avec la partie de code qui suit, ça fonctionne bien sous Windows et Ubuntu. Par contre, sous macOS, un message me dit que l'application invoquée n'est pas trouvée :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
var
  Process: TProcess;
  WSDoc: WideString;
  Buff: array[0..255] of WideChar;
  Pgm: String;
begin
  Process:= TProcess.Create(nil);
  with Process do
  begin
{$IFDEF WINDOWS}
    WSDoc:= UTF8Decode(Doc);
    FindExecutableW(PWideChar(WSDoc), nil, Buff);
    Pgm:= UTF8ToString(Buff);
    Executable:= Pgm;
    Parameters.Add(Doc);
{$ENDIF}
{$IFDEF LINUX}
    Executable:= 'xdg-open';
    Parameters.Add(Doc);
{$ENDIF}
{$IFDEF DARWIN}
    Executable:= '/Système/Applications/Aperçu.app';
    Parameters.Add(Doc);
{$ENDIF}
 
    Options:= Options+[poWaitOnExit];
    Execute;
    Free;
  end;
end;
Quand je vais dans le répertoire des applications, celle-ci existe bien.

J'ai essayé différentes sortes d'appellations, mais rien n'y fait :

  • Système/Applications/Aperçu.app
  • Système/Applications/Aperçu
  • System/Applications/Preview.app
  • System/Applications/Preview

Que faut-il faire ?

Cordialement.

Pierre.