|
-
Nov 8th, 2004, 08:41 AM
#1
Thread Starter
Member
program must kill itself
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
-
Nov 8th, 2004, 09:52 AM
#2
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.
My usual boring signature: Nothing
 
-
Nov 8th, 2004, 11:19 AM
#3
Thread Starter
Member
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
-
Nov 8th, 2004, 11:22 AM
#4
Frenzied Member
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.
Code:
If Question = Incomplete Then
AnswerNextOne
Else
ReplyIfKnown
End If
cu Swatty
-
Nov 8th, 2004, 03:38 PM
#5
Thread Starter
Member
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
-
Nov 8th, 2004, 04:27 PM
#6
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.
My usual boring signature: Nothing
 
-
Nov 8th, 2004, 05:43 PM
#7
Frenzied Member
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
-
Nov 9th, 2004, 05:23 AM
#8
Frenzied Member
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
-
Nov 9th, 2004, 05:26 AM
#9
Frenzied Member
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.
...
You CAN do it from within the program, by creating and shelling a batch file.
TerminateProcess might be useful API
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|