Question about starting an application with a process

I want to start an application and be able to close it. I've tried to terminateProcess - which was a no no because it didn't "clean up" after itself. ExitProcess after finding the process''s exit code - but that just exited the entire program. I've tried exitThread and same thing as exitprocess .. it exited my program. A snipet of teh code follows.

try
####GetStartUpInfo(StartInfo);
####StartInfo.wShowWindow := SW_SHOWMINNOACTIVE;
####if CreateProcess(nil, PChar('addline ' + fnFile +
####################' OUT.txt' + ' 335'), nil, nil, False, ####################CREATE_DEFAULT_ERROR_MODE, nil, nil,
####################StartInfo, ProcInfo) = False then
####Result := False
####else
####begin
######ProcHandle := ProcInfo.hProcess;
######ThreadHandle := ProcInfo.hThread;
######if procHandle = 0 then
########Result := False
######else
######begin
########repeat
##########RetVal := FindFirstChangeNotification(PChar
################(Directory), False,
################FILE_NOTIFY_CHANGE_LAST_WRITE);
##########until RetVal <> NOT_SET;
##########case RetVal of
############INVALID_HANDLE_VALUE:
############Result := False;
############HANDLE_SET: //own declaration, dont know codes
############Result := True;
##########else
##########Result := False;
########end;
########if GetExitCodeThread(ThreadHandle, ExitCode) = True Then
##########ExitThread(ExitCode);
######end
####end
##except
#####Result := False;
##end
end;

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories