CreateProcess problem?

Please discuss general Delphi programming topics here.

CreateProcess problem?

Postby cralias » November 16th, 2010, 3:56 pm

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? :?
User avatar
cralias
Member
Member
 
Posts: 4
Joined: August 25th, 2010, 10:20 pm
Location: Latvia

Re: CreateProcess problem?

Postby Kambiz » November 16th, 2010, 9:14 pm

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.
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2429
Joined: March 7th, 2003, 7:10 pm

Re: CreateProcess problem?

Postby cralias » November 20th, 2010, 9:23 pm

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. :)
User avatar
cralias
Member
Member
 
Posts: 4
Joined: August 25th, 2010, 10:20 pm
Location: Latvia


Return to Delphi Programming

Who is online

Users browsing this forum: No registered users and 1 guest

cron