Error when I run the easy-php devserver "run-devserver.exe" with ShellExecute

323 Views Asked by At

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

There are 1 best solutions below

0
On

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';