Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

App not closing

Status
Not open for further replies.

cyprus106

Programmer
Apr 30, 2001
654
I've got several applications that, when I call the
Application->Terminate(); function it does not close the program. I looked and looked and couldn't find any reasonwhy in the world they would do this. Application->Terminate() shoots off without a hitch and everything's wonderful. The windows close, but the process keeps running. This has happened on more than one of my programs, which is reason for concern (for lack of a better word) Has anybody else had this problem. How do I kill the program when Application->Terminate commits suicide? Cyprus
 
try using the close function on the main form of the app.
This will kill it if it is a windows app.

Otherwise try using the TerminateProcess() function,
assuming you have the process id
 
tried close. doesn't work. How do i get the process ID? Cyprus
 
if you created the process with the createprocess function, then you can get it from that.

////////
STARTUPINFO stStartInformation;
PROCESS_INFORMATION stProcessInformation;
String clExecutable;
String clArguments;
String clExercise;
DWORD dwCreationFlags = DETACHED_PROCESS;

//used to initially start training
STARTUPINFO RTStartupInfo;
PROCESS_INFORMATION RTProcessInfo;
RTProcessInfo.hProcess = 0;
// configure the startup info for the real time process
memset(&RTStartupInfo, 0, sizeof(STARTUPINFO));
RTStartupInfo.cb = sizeof(STARTUPINFO);
RTStartupInfo.dwFlags = STARTF_USESHOWWINDOW;
RTStartupInfo.dwXSize = 200;
RTStartupInfo.dwYSize = 100;

CreateProcess("C:\\Project\\TheApplication.exe",NULL, NULL ,NULL,FALSE,NULL, NULL,"C:\\Project\\",&RTStartupInfo , &RTProcessInfo);

processPid = RTProcessInfo.dwProcessId;
/////

the use the TerminateProcess() function like this

/////
HANDLE TheHandle = OpenProcess( SYNCHRONIZE|PROCESS_TERMINATE, FALSE, processPid);
unsigned long int iExitCode;
GetExitCodeProcess(TheHandle ,&iExitCode);
TerminateProcess(TheHandle ,iExitCode);
CloseHandle(TheHandle );
 
Have you tried caFree on the form's OnClose property? James P. Cottingham

I am the Unknown lead by the Unknowing.
I have done so much with so little
for so long that they think I am now
qualified to do anything with nothing.
 
ooh theres an idea. I'll see what I can't do. Cyprus
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top