0
votes

I use easy-php devserver 17 on Windows 10 x64 without any problem if I click with the mouse on the "run-devserver.exe" file.

But in my new project, I want to run easy-php from my Delphi program (RAD Studio 10.1 Berlin).

I use this code:

ShellExecute(Handle, 'runas', 'c:\Program Files (x86)\EasyPHP-Devserver-17\run-devserver.exe', nil, nil, SW_SHOWNORMAL);

I get this error (I think it created with MadExcept 3.0):

Aestan Try menu: An error has occurred in Aestan Try Menu.

This error gives me some options, like the bug report, restart the application, close application!

I used some tips in another post like these:

WAMP Server V 2.5 icon is orange,does not respond and no menu

ShellExecute Command doesn't work properly in win10

but they didn't solve my problem.

1
I guess you must start as administrator?, the problem is that your application starts without elevated privileges.Does it work when you start your application as administrator (ie right-click, select "run as administrator")?whosrdaddy
yes, I start it as administrator but the problem is not solved.siavosh1
Entirely possible that the difference is the working directory. As an aside, never call ShellExecute since it can't report errors properly. Use ShellExecuteEx.David Heffernan
I used "ShellExecuteEx" but the problem not solved. I even used the recommended methods of this link : stackoverflow.com/questions/27249995/…siavosh1
Please attention that error is for Dev-server 17, it means that the program is running good and I think "ShellExecute" or "ShellExecuteEx" works without any problem, but maybe I need new configuration to run dev-server with another program or set some permission inside of configuration file, but which file !!?siavosh1

1 Answers

0
votes

Problem Solved. when I use this code the Error appears: "The directory name is invalid".

procedure TForm1.Button90Click(Sender: TObject);
var
  FileName, Parameters, Folder: string;
  sei: TShellExecuteInfo;
  Error: DWORD;
  OK: boolean;
begin
   FileName := 'C:\Program Files (x86)\EasyPHP-Devserver-17\run-devserver.exe';
   Parameters := '-lang rus';
   ZeroMemory(@sei, SizeOf(sei));
   sei.cbSize := SizeOf(sei);
   sei.lpFile := PChar(FileName);
   sei.lpParameters := PChar(Parameters);
   sei.lpDirectory := PChar(Folder);
   sei.nShow := SW_SHOWNORMAL;
   OK := ShellExecuteEx(@sei);
   if not OK then
   begin
      Error := GetLastError;
      ShowMessage('Error: ' + IntToStr(Error));
   end;

but when I edit folder and filename string like this code everything is OK.

Folder := 'C:\Program Files (x86)\EasyPHP-Devserver-17\';
FileName := Folder + 'run-devserver.exe';