SRL Archive - Delphi/FPC Help and Tutorials

Question on Delphi, and in general Handles.


ShowerThoughts

2009-08-27 01:24:36

Hey!
In short I want my program to run game executable's but I think because I am using the application handle it doesn't how can I get the user handle so the executable thinks it gets executed by a user for example?


procedure Run(Path:string);
var
SEInfo: TShellExecuteInfo;
ExitCode: DWORD;
ExecuteFile: string;
begin
ExecuteFile := Path;
FillChar(SEInfo, SizeOf(SEInfo), 0);
SEInfo.cbSize := SizeOf(TShellExecuteInfo);
with SEInfo do begin
fMask := SEE_MASK_NOCLOSEPROCESS;
Wnd := Application.Handle;
lpFile := PChar(ExecuteFile);
nShow := SW_SHOWNORMAL;
end;
ShellExecuteEx(@SEInfo);
end;


Error.

I would deeply appreciate your help.

nielsie95

2009-08-27 01:51:19

Maybe you should set your working directory to the directory of the file (you can set it in the TShellExecuteInfo)? And have you tried the regular ShellExecute?

ShowerThoughts

2009-08-27 11:23:58

I added this:
lpDirectory := PChar(ExtractFileDir(ExecuteFile)+'\');
and
lpDirectory := PChar(ExtractFileDir(ExecuteFile));

It doesn't work.
But you are right btw when I do it from the same directory it seems to work.