RLopezLo
asked on
How can use CreateProcess(...) in Delphi 2005 (Vcl.Net)?
In past delphi versions (no .net) I started processes with CreateProcess. Under .net I can't start a process with this routine.
I haven't errors in compilation but the process never start.
I know that there is other ways to start a process but, for me, CreateProcess is the best due to the possibilities of control.
Coul'd someone help me to know the correct way to use CreateProcess?
Thanks in advance.
I haven't errors in compilation but the process never start.
I know that there is other ways to start a process but, for me, CreateProcess is the best due to the possibilities of control.
Coul'd someone help me to know the correct way to use CreateProcess?
Thanks in advance.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
var
zAppName:array[0..512] of char;
zCurDir:array[0..255] of char;
WorkDir:String;
StartupInfo:TStartupInfo;
ProcessInfo:TProcessInform
ID : Cardinal;
begin
StrPCopy(zAppName,ExName);
GetDir(0,WorkDir);
StrPCopy(zCurDir,WorkDir);
FillChar(StartupInfo,Sizeo
StartupInfo.cb := Sizeof(StartupInfo);
StartupInfo.dwFlags := STARTF_USESHOWWINdow;
StartupInfo.wShowWindow := 0 ;
if not CreateProcess(nil, PChar(zAppName + ' "' +Arg+ '"'), nil , nil , false,
CREATE_NEW_CONSOLE or NORMAL_PRIORITY_CLASS, nil , PChar(Dir) ,StartupInfo,ProcessInfo)
then Result := 0
else begin
WaitforSingleObject(Proces
GetExitCodeProcess(Process
Result := 1;
end ;
end ;