Visual Basic > Visual Basic Forums > Visual Basic Language > Close application from dll?
Ask a questionAsk a question
 

AnswerClose application from dll?

  • Wednesday, November 04, 2009 5:04 PMamygreenx Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    hi

    i have a dll file and i need to use it to close/exit/shutdown the application thats using it if that makes sense.   i can code something inside the main application that would close it if it receives a specific response from the dll but im trying to minimize the amount of code i need to use within the main application.


    could someone please show me how i could shutdown the application from the dll?

    thank you so much x

Answers

  • Wednesday, November 04, 2009 5:10 PMDick Grier Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    What I'd do is add an event in the dll that it raises when it wants the application to close.  Then add an event handler in the application, and close the application in that event. 

    There are "issues" that may need to be addressed, such as open files, databases, etc., so you need to consider all of the ramifications of this operation.  This doesn't sound very user friendly, but... I suppose "friendly" may not be the goal?

    Dick
    Dick Grier, MVP. Author of Visual Basic Programmer's Guide to Serial Communications 4. See www.hardandsoftware.net.
  • Wednesday, November 04, 2009 5:18 PMjinzai Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Post a WM_QUIT message to its message queue, using PostMessage.

All Replies

  • Wednesday, November 04, 2009 5:10 PMDick Grier Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    What I'd do is add an event in the dll that it raises when it wants the application to close.  Then add an event handler in the application, and close the application in that event. 

    There are "issues" that may need to be addressed, such as open files, databases, etc., so you need to consider all of the ramifications of this operation.  This doesn't sound very user friendly, but... I suppose "friendly" may not be the goal?

    Dick
    Dick Grier, MVP. Author of Visual Basic Programmer's Guide to Serial Communications 4. See www.hardandsoftware.net.
  • Wednesday, November 04, 2009 5:18 PMjinzai Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Post a WM_QUIT message to its message queue, using PostMessage.