Hola
Estos tres funcionan juntos y sirven para llamar a otro programa.
El primero lo que hace es enviar un mensaje de error si detener el programa.
Código Delphi
[-]
function SysErrorMessageParam(ErrorCode: Integer; Param: string): string;
var
Len: Integer;
Buffer: array[0..255] of Char;
ArgArray: array[1..1] of PChar;
begin
ArgArray[1] := PChar(Param);
Len := FormatMessage(Format_Message_From_System or
Format_Message_Argument_Array, nil, ErrorCode, 0, Buffer,
SizeOf(Buffer), @ArgArray);
while (Len > 0) and (Buffer[Len - 1] in [#0..#32, '.']) do Dec(Len);
SetString(Result, Buffer, Len);
end;
Código Delphi
[-]
function TFMainForm.ExecuteApp(AppName, Params: string): TProcessInformation;
var
SI: TStartupInfo;
PI: TProcessInformation;
begin
FillChar(SI, SizeOf(SI), 0);
with SI do
begin
cb := SizeOf(TStartupInfo);
dwFlags := StartF_UseShowWindow;
wShowWindow := sw_ShowNormal;
end;
if not CreateProcess(nil, PChar(AppName + ' ' + Params), nil,
nil, False, 0, nil, nil, SI, PI) then
raise EExecAppError.Create(SysErrorMessageParam(GetLastError, AppName));
Result := PI;
end;
Código Delphi
[-]
procedure TFMainForm.Launch(AppName, Params: string);
begin
ExecuteApp(AppName, Params);
end;
Saludos