Hi Everyone -
I have a program that simply will not die -
Is there a way to force an application to terminate itself?
the terminate part of the code is being called -
but it will not remove itself from memory...
vb6
thanks
tony
Printable View
Hi Everyone -
I have a program that simply will not die -
Is there a way to force an application to terminate itself?
the terminate part of the code is being called -
but it will not remove itself from memory...
vb6
thanks
tony
End?
This is not a good answer, but it is fairly final.
Can you be more specific about what is happening? Perhaps you have to clear a bunch of objects.
Sorry to be so vague -
I created a module to kill a running application by its
process ID - and it seems to work...
the caller program will simply need to call
a exposed sub and the process will die.
thanks
tony
Can you be more specific , like the Hiker asked.
Your question is incomplete.
Are you trying to delete the program from the drive.
Or are you trying to stop the program from running ??
The first can't be done from itself, another program is needed herefore.
The second can be made difficult if not all objects are cleared, and or forms are unloaded. Hiding a form doesn't unload it, it stay's in the background.
Hi Everyone -
Since my question didn't seem to obvious....
i will ask it again - this time in an area of the message
i am sure will be visible.....
'*********************************************
'* Question begins here
Is there a way to force an application to terminate itself?
'* Question ends here
'*********************************************
I have looped through all the forms -
setting each one to nothing,
and applied a unload to each one.
I'm not entirely sure on the process of destroying (setting to nothing) any and all objects that were created in the program...
perhaps someone could enlighten me on the looping through
all the created objects for a particular application??????
thanks for the replies!!
take care
tony
If this is a fairly simple program you are talking about, destroying all the forms should be pretty good. If there are other objects that need to be destroyed, you'd probably know about them, because you probably created them. Database connections and database related objects are probably the most common.
The End statement terminates a program, but you would find that most people on this forum would prefer something a bit nicer than that.
There may also be an API solution by posting a WM_QUIT message to the program, but you may not need that. In the normal VB6 template program, once you have unloaded all forms, the program quits. In your case, that might not happen. If you don't think you have any other objects, you might just try End.
VB Code:
Private Sub Form_Unload(Cancel As Integer) 'unload only forms 'unload form2 'set form2 = nothing Set Form1 = Nothing End End Sub Private Sub mnuQuit_Click() Unload Me End Sub Private Sub Command1_Click() Unload Me End Sub
Surely you need to unload the objects too?
VB Code:
Function vbCloseForms() Dim frm As Form Dim obj As Object For Each frm In Forms For Each obj In frm On Error Resume Next Unload obj ' Debug.Print obj.Name Set obj = Nothing Next 'Calls the Form_Unload Event Unload frm Set frm = Nothing Next
You CAN do it from within the program, by creating and shelling a batch file.Quote:
Originally posted by swatty
...
Are you trying to delete the program from the drive.
Or are you trying to stop the program from running ??
The first can't be done from itself, another program is needed herefore.
...
TerminateProcess might be useful API