battles
2010-12-10 13:06:40 UTC
I have the following CreateProcess that is not starting the program
successfully. The error is that the program that is started cannot
find a config file it needs to open. I have tried to point to
the .exe's folder in executableparameters as well as puting in the
whole file name, putting them in double quotes, but that doesn't work
either. Any ideas on how to get the CreateProcess to pass the ability
to find the files it needs? Thanks.
with lpStartupInfo do begin
FillChar(lpStartupInfo, SizeOf(lpStartupInfo), 0);
cb := SizeOf(lpStartupInfo);
dwFlags := STARTF_USESHOWWINDOW; //// or
STARTF_USESTDHANDLES;
wShowWindow := SW_HIDE;
hStdInput := GetStdHandle(STD_INPUT_HANDLE); // don't
redirect std input
end;
if FileExists(filenm) then begin
with lpStartupInfo2 do begin
FillChar(lpStartupInfo2, SizeOf(lpStartupInfo2),
0);
cb := SizeOf(lpStartupInfo2);
dwFlags := STARTF_USESHOWWINDOW; //// or
STARTF_USESTDHANDLES;
wShowWindow := SW_HIDE;
hStdInput := GetStdHandle(STD_INPUT_HANDLE); //
don't redirect std input
end;
CreateProcess(
PChar(trim(filenm)), // pointer to name of executable
module
PChar(executableparameters),// pointer to command
line string
nil, // pointer to process
security attributes
nil, // pointer to thread
security attributes
FALSE, // handle inheritance
flag
CREATE_NEW_PROCESS_GROUP OR NORMAL_PRIORITY_CLASS,
nil, // pointer to new
environment block
nil, // pointer to current
directory name
lpStartupInfo2, // pointer to
STARTUPINFO
lpProcessInformation2); // pointer to
PROCESS_INFORMATION
//bombs before OpenProcess
OpenProcess(
PROCESS_ALL_ACCESS, // access flag
TRUE, // handle inheritance
flag
lpProcessInformation2.hProcess); // process
identifier - PID
AHandleArray[AHA] :=
lpProcessInformation2.dwProcessId; // process identifier - PID
inc(AHA);
end
successfully. The error is that the program that is started cannot
find a config file it needs to open. I have tried to point to
the .exe's folder in executableparameters as well as puting in the
whole file name, putting them in double quotes, but that doesn't work
either. Any ideas on how to get the CreateProcess to pass the ability
to find the files it needs? Thanks.
with lpStartupInfo do begin
FillChar(lpStartupInfo, SizeOf(lpStartupInfo), 0);
cb := SizeOf(lpStartupInfo);
dwFlags := STARTF_USESHOWWINDOW; //// or
STARTF_USESTDHANDLES;
wShowWindow := SW_HIDE;
hStdInput := GetStdHandle(STD_INPUT_HANDLE); // don't
redirect std input
end;
if FileExists(filenm) then begin
with lpStartupInfo2 do begin
FillChar(lpStartupInfo2, SizeOf(lpStartupInfo2),
0);
cb := SizeOf(lpStartupInfo2);
dwFlags := STARTF_USESHOWWINDOW; //// or
STARTF_USESTDHANDLES;
wShowWindow := SW_HIDE;
hStdInput := GetStdHandle(STD_INPUT_HANDLE); //
don't redirect std input
end;
CreateProcess(
PChar(trim(filenm)), // pointer to name of executable
module
PChar(executableparameters),// pointer to command
line string
nil, // pointer to process
security attributes
nil, // pointer to thread
security attributes
FALSE, // handle inheritance
flag
CREATE_NEW_PROCESS_GROUP OR NORMAL_PRIORITY_CLASS,
nil, // pointer to new
environment block
nil, // pointer to current
directory name
lpStartupInfo2, // pointer to
STARTUPINFO
lpProcessInformation2); // pointer to
PROCESS_INFORMATION
//bombs before OpenProcess
OpenProcess(
PROCESS_ALL_ACCESS, // access flag
TRUE, // handle inheritance
flag
lpProcessInformation2.hProcess); // process
identifier - PID
AHandleArray[AHA] :=
lpProcessInformation2.dwProcessId; // process identifier - PID
inc(AHA);
end