Forum > Beginners
Running external program (*.exe file) problem.
TomTom:
There are no parameters. It's not a shortcut.
--- Quote from: loaded on November 29, 2022, 02:40:57 pm ---There may be parameters in the shortcut of the exe you are trying to run. You can see this in the shortcut properties. Can you check this situation?
I have prepared a sample parameter for you.
--- End quote ---
loaded:
Then my last trump card ;D
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---uses shellapi,LConvEncoding;procedure TForm1.Button1Click(Sender: TObject);varexe_path:String='C:\Program Files (x86)\Google\Chrome\Application\chrome.exe';begin ShellExecute(Application.handle, 'open', 'cmd.exe', PChar('/c "'+exe_path+'"' ), nil, 1);end;
TomTom:
I found solution... Gameprocess.options := GameProcess.Options + [poDetached]... so it's not a child process of my app... I guess ;)
KodeZwerg:
Windows Explorer way of doing works too.
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---uses ... Windows, ShellApi; procedure TForm1.Button1Click(Sender: TObject);var LTarget: string;begin LTarget := 'c:\Games\cytadela_1.1.0_win32\cytadela.exe'; if (not FileExists(LTarget)) then begin ShowMessage('Not found!'); Exit; end; ShellExecute(0, 'open', PChar(LTarget), PChar(''), PChar(ExtractFilePath(LTarget)), SW_SHOWNORMAL);end;I think it is because your app is not in the folder (Working folder).
TomTom:
I'm checking if file exists before user is able to click the button and my Procedure looks like this and it's working fine :) :
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TForm1.Button3Click(Sender: TObject);var i: Integer;begin GameProcess := TProcess.Create(nil); try GameProcess.InheritHandles := False; GameProcess.Options := [poDetached]; GameProcess.ShowWindow := swoShow; GameProcess.CurrentDirectory := ExtractFilePath(exepath.text); for i := 1 to GetEnvironmentVariableCount do GameProcess.Environment.Add(GetEnvironmentString(i)); GameProcess.Executable:=exepath.text; GameProcess.Execute; finally GameProcess.Free; end;
Navigation
[0] Message Index
[*] Previous page