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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

End App Thru DLL

Status
Not open for further replies.

SpiderBear6

Programmer
Sep 17, 2003
422
AU
Is it possible to end (gracefully would be nice) an application through a dll that was called by that application? I can't use End.

--------------------------------------
"We are star-stuff. We are the universe made manifest trying to figure itself out."
-- Delenn in Babylon 5 - "A Distant Star"
 

Not quite sure of what you are doing but in each form you should use a sub that does all of the cleanup for you. Most of the time I use Query_Unload to do my cleanup. Then if I have public objects that could be instantiated I have a public sub that takes care of those objects and end my program for me.

So my suggestion for you is to do something similar (this is just an example...
[tt]
Public Sub EndProgram()
Dim F As Form
For Each F In Forms
Unload F 'this will tell the form to unload which in turn will activate the query unload in each form (if it exists)
Next
'clean up public stuff here
End Sub
[/tt]

Also to answer your question I do not belive it would be a good idea to attempt such a thing.

Good Luck

 
VB5, i think the main question asked here is if it is possible to End an application from within the dll that it is connected to...

Spider...I would look into the raise_events functions of DLL's in order to raise an event in the main app, kinda like when a textbox is clicked "text1_click()" or whatever, and in the event you can run the end or whatever clean up code you may need.

Hope this helps

*****************************************
May the Code Be With You...[lightsaber]
----------
x50-8 (X Fifty Eigt)
 
Yeah...I got taught to "Raise Events" by a master...:)

*****************************************
May the Code Be With You...[lightsaber]
----------
x50-8 (X Fifty Eigt)
 
Funny - I thought it was me...

Spider - remember do dim your dll "withevents"...

 

Well thank you mmilan and x508 for just reinforcing what I was saying. You see the origional question was to end the app via a dll that was initiated by the app,

>VB5, i think the main question asked here is if it is possible to End an application from within the dll that it is connected to

and you have suggested that the dll raise an event for the program to take action on. In this case end the program.

So SpiderBear6 you have the advice from x508 and mmilan to call the main application via a raise events and my advice...

>Also to answer your question I do not belive it would be a good idea to attempt such a thing.

and a suggested method on how to end your program gracefully (see my origional post).

It's good when we all agree...

Good Luck

 
Actually I went a different way and returned a flag from the method call, which tells the main program whether it needs to shut down or not.

Thanks for all of your help guys.

--------------------------------------
"We are star-stuff. We are the universe made manifest trying to figure itself out."
-- Delenn in Babylon 5 - "A Distant Star"
 
Uhm...just in case anyone wondered...by master I meant mmilan....:)

*****************************************
May the Code Be With You...[lightsaber]
----------
x50-8 (X Fifty Eigt)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top