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 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
| unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Forms, LCLType, Registry, ShellApi, ComCtrls, StdCtrls, Dialogs;
type
{ TForm1 }
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
{ TForm1 }
// Execute FSX.exe
procedure TForm1.Button1Click(Sender: TObject);
var
reg: TRegistry;
str: string;
exeFSX : string;
begin // Allons chercher le chemin de FSX.exe
{
reg := TRegistry.Create;
reg.RootKey := HKEY_CURRENT_USER;
reg.OpenKeyreadonly('Software\Microsoft\Microsoft Games\Flight Simulator\10.0');
str := reg.ReadString('AppPath');
reg.closekey;
reg.free;
}
str := 'F:\Microsoft Flight Simulator X\';
ShowMessage('str = ' + str); // Résultat donne str = F:\Microsoft Flight Simulator X\
exeFSX := (str + 'FSX.exe');
ShowMessage('str + FSX.exe = ' + exeFSX); // Résultat donne str + FSX.exe = F:\Microsoft Flight Simulator X\FSX.exe
// Executer FSX.exe si retourne > 32 c'est qu'il y a erreur
if ShellExecute(0,nil, PChar(exeFSX),nil,nil,SW_SHOWNORMAL) > 32 then
begin
Halt();
end
else
Application.MessageBox('Unable to find FSX.exe!', 'Run FSX.exe', MB_ICONINFORMATION);
end;
end. |
Partager