I have two .exe programs, one is the game launcher and the other is the main executable. How would i go about making my main executable run the game launcher if someone goes to open it. It would be something to do with the .dpr file and some Windows API's i am guessing just not sure what/where to start to be honest.
Reason i want it like this is simply because, the game launcher will be used to update the game and then when complete start the game thus people will always be using the latest up2date files.
So the functionality i would like too require is: I can click on Main Executable or Launcher Executable both will open Launcher Executable and then when updates / downloads are complete Launcher will start Main Executable when the user has clicked Start button.
/Thanks
Have the main executables startup code look for a command-line parameter of your choosing. You can use the RTL's FindCmdLineSwitch()
function for that purpose. If the parameter exists, run the game normally. Otherwise, use the Win32 CreateProcess()
function to run the launcher executable and then exit itself. When the launcher is ready, it can use the CreateProcess()
function to run the main executable, passing it the command line parameter to run the game.
For example:
Main.dpr:
Var
SI: TStrartupInfo;
PI: TProcessInformation;
Begin
If not FindCmdLineSwitch('RunGameNow') then
Begin
ZeroMemory(@SI, SizeOf(SI));
SI.cbSize := SizeOf(SI);
...
If CreateProcess(nil, 'launcher.exe', nil, nil, False, 0, nil, nil, @SI, @PI) then
Begin
CloseHandle(PI.hThread);
CloseHandle(PI.hProcess);
End;
Exit;
End;
... Run game normally...
End.
Launcher.dpr:
Begin
...
CreateProcess(nil, 'main.exe /RunGameNow', nil, nil, False, 0, nil, nil, @SI, @PI)
...
End.