I have made a Game Launcher and I use this command:
procedure TFMain.ImgBtn1Click(Sender: TObject);
begin
ShellExecute(TForm(Owner).Handle, nil, 'starter.exe', '-lang rus', nil, SW_SHOWNORMAL);
end;
with '-lang rus' as a parameter. Everything works fine. The Game Launches and the language is in russian(if i put '-lang eng' it still works fine and the game is in english).
The starter.exe application is inside a folder named ''bin''. When i want to relocate the launcher outside this folder i use this command:
procedure TFMain.ImgBtn1Click(Sender: TObject);
begin
ShellExecute(TForm(Owner).Handle, nil, 'bin\starter.exe', '-lang rus', nil, SW_SHOWNORMAL);
end;
But then the game isn't launching. Actually nothing happens. What should i change?
You have to use full path to the application you are trying to start.
ExtractFilePath(Application.ExeName)
will give you full path to your launcher exe.Solution 1: using
ShellExecute
You can find list of error codes at: ShellExecute function documentation
Most common error codes:
ERROR_FILE_NOT_FOUND 0x2
ERROR_PATH_NOT_FOUND 0x3
Solution 2: using
ShellExecuteEx
ShellExecuteEx documentation
Solution 3: using
CreateProcess
CreateProcess documentation