## CreateProcess problem?

Please discuss general Delphi programming topics here.

### CreateProcess problem?

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?

cralias
Member

Posts: 4
Joined: August 25th, 2010, 10:20 pm
Location: Latvia

### Re: CreateProcess problem?

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

Kambiz

Posts: 2424
Joined: March 7th, 2003, 7:10 pm

### Re: CreateProcess problem?

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.

cralias
Member

Posts: 4
Joined: August 25th, 2010, 10:20 pm
Location: Latvia

### Who is online

Users browsing this forum: Bing [Bot] and 1 guest