Nie wiem czy to ma być w delphi czy w tp. Jak w TP to jest procedura
procedure Exec(Path, CmdLine :string)
gdzie Path to ścieżka dostępu do pliku, a CmdLine to parametry uruchomieniowe.
Postać funkcji byłaby następująca:
procedure Run(const mode :Byte); { nie wiem dlaczego użyłeś modyfikatora var }
begin
SwapVectors;
case mode of
1 : Exec('PLIK1.EXE', '');
2 : Exec('PLIK2.EXE', '');
end;
SwapVectors;
Run := DosError; zwracamy kod bledu
Halt;
end;
Natomiast w delphi
HINSTANCE ShellExecute(
HWND hwnd, // handle to parent window
LPCTSTR lpOperation, // pointer to string that specifies operation to perform
LPCTSTR lpFile, // pointer to filename or folder name string
LPCTSTR lpParameters, // pointer to string that specifies executable-file parameters
LPCTSTR lpDirectory, // pointer to string that specifies default directory
INT nShowCmd // whether file is shown when opened
);
Przykład, który uruchamia kalkulator systemowy (do sekcji uses dodaj ShellApi);
uses ShellApi;
procedure FormCreate(Sender :TObject);
begin
ShellExecute(Application.MainForm.Handle,
nil, 'CALC.EXE', '', '', SW_SHOWNORMAL);
Application.Terminate();
end;