Page 1 of 1

CreateProcess problem?

PostPosted: November 16th, 2010, 3:56 pm
by cralias
Trying to make Games Explorer here, functionally similar to one in Vista/7 (that, honestly, fails to serve it's purpose most of the time)
I'm using CreateProcess() to launch the game executable (or anything else for that matter).

Code: Select all
function LaunchTarget(Target: string): BOOL;
var
  SI: TStartupInfo;
  PI: TProcessInformation;
begin
  ZeroMemory(@SI, SizeOf(SI));
  SI.cb := SizeOf(SI);
  ZeroMemory(@PI, SizeOf(PI));
  Result := CreateProcess(nil, PChar(Target), nil, nil, false, 0, nil, PChar(ExtractFilePath(Target)), SI, PI);
end;


Most games work this way. One does not. When it's run from Windows Explorer (e.g., directly or using a shortcut), everything is ok.
When run from my program, using the code above, it crashes.

Could it be that my CreateProcess code is wrong? :?

Re: CreateProcess problem?

PostPosted: November 16th, 2010, 9:14 pm
by Kambiz
Recently I had a similar problem with CreateProcess. The application that I wanted to execute needed elevation, and CreateProcess couldn't run it.

I used ShellExecuteEx and then all was fine.

Re: CreateProcess problem?

PostPosted: November 20th, 2010, 9:23 pm
by cralias
Finally got to it. I have dug so far that it was a problem with Games for Windows Live taking a dislike and updating the game itself solves it. Protection against piracy up to the teeth, so to speak.

Anyway, I'll use more powerful ShellExecuteEx from now on, more useful for my purpose. I was just about to look for how to get the default program for opening files. Thanks. :)