Board index » delphi » CreateProcess function ???

CreateProcess function ???

I use the following code:

var
   cmd : string;
   StartupInfo : TStartupInfo;
   ProcessInfo : TProcessInformation;
   buff : Pchar;
begin
     cmd := 'C:\32bit\netscape\netscape.exe';
     buff := StrAlloc(129);
     StrPCopy(buff, cmd);
     CreateProcess(nil, buff, nil, nil, FALSE,
               NORMAL_PRIORITY_CLASS, nil, nil, StartupInfo, ProcessInfo);

end;

When the function CreateProcess runs I get an error and the application
(in this case netscape.exe) never runs. This seems to happen to a lot of
windows programs. However 'write.exe' seems to run ok. Any help ???

Thanks in advance,

Jonathan.

 

Re:CreateProcess function ???


On 20 Nov 1996 16:17:03 GMT, iss009@thunder (J.Gould) wrote:

Quote
>I use the following code:

>var
>   cmd : string;
>   StartupInfo : TStartupInfo;
>   ProcessInfo : TProcessInformation;
>   buff : Pchar;
>begin
>     cmd := 'C:\32bit\netscape\netscape.exe';
>     buff := StrAlloc(129);
>     StrPCopy(buff, cmd);
>     CreateProcess(nil, buff, nil, nil, FALSE,
>               NORMAL_PRIORITY_CLASS, nil, nil, StartupInfo, ProcessInfo);

>end;

>When the function CreateProcess runs I get an error and the application
>(in this case netscape.exe) never runs. This seems to happen to a lot of
>windows programs. However 'write.exe' seems to run ok. Any help ???

Well, by not initializing the StartupInfo and ProcessInfo structures,
you're passing "random" values for those options.  I suggest you look
at a function I've written that uses CreateProcess to launch
applications.  It's called "WinExecAndWait".  It will work for both
Delphi 1 and 2, using WinExec under Delphi 1 and CreateProcess under
Delphi 2 (using $IFDEFs to separate the code).  The function will
launch the app and pause execution of your program until that
application has been closed.  The function itself may not be what
you're wanting, but the source code will demonstrate the proper use of
CreateProcess.

You can find it listed on this page (along with lots of other stuff):
   http://www.delphiexchange.com/offers.html

Cheers,
Brad Choate

--
Brad Choate <cho...@cswnet.com>  | http://www.cswnet.com/~choate
Webmaster of the Delphi EXchange | http://www.DelphiEXchange.com
You should have asked that question on the Efnet #delphi IRC channel!
Have a Coke and a :)

Other Threads