wipnav
asked on
CreateProcess resource allocation issue
Hi,
I am creating a process from my Delphi 7 application. I wait for it to complete and then continue execution of my program. Here is my code:
FillChar(StartupInfo, SizeOf(StartupInfo), 0);
FillChar(ProcessInfo, SizeOf(ProcessInfo), 0);
if CreateProcess(nil, PChar(CommandLine), nil, nil, True, 0, nil, nil, StartupInfo, ProcessInfo) then
repeat
Application.ProcessMessage s;
GetExitCodeProcess(Process Info.hProc ess, ExitCode);
until (ExitCode <> STILL_ACTIVE) or Application.Terminated;
It works fine. My problem is that Memory Sleuth indicates that there is a Thread Handle and a Process Handle still allocated once my application terminates.
My question is, how do I free these resources?
Regards,
Bill
I am creating a process from my Delphi 7 application. I wait for it to complete and then continue execution of my program. Here is my code:
FillChar(StartupInfo, SizeOf(StartupInfo), 0);
FillChar(ProcessInfo, SizeOf(ProcessInfo), 0);
if CreateProcess(nil, PChar(CommandLine), nil, nil, True, 0, nil, nil, StartupInfo, ProcessInfo) then
repeat
Application.ProcessMessage
GetExitCodeProcess(Process
until (ExitCode <> STILL_ACTIVE) or Application.Terminated;
It works fine. My problem is that Memory Sleuth indicates that there is a Thread Handle and a Process Handle still allocated once my application terminates.
My question is, how do I free these resources?
Regards,
Bill
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Geo,
Perfect!
Thank you very much.
Regards,
Bill
Perfect!
Thank you very much.
Regards,
Bill
You are welcome :-)
Add these two lines at the end of your code:
CloseHandle(ProcessInfo.hP
CloseHandle(ProcessInfo.hT
Regards, Geo