Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. How to close an application completely

How to close an application completely

Scheduled Pinned Locked Moved Visual Basic
questionc++helptutorial
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    nahitan
    wrote on last edited by
    #1

    Hi there, I have a VB MFC that uses a dll for sending, receiving, dispalying and logging data from/to another application the problem is that SOMETIMES when I close the VB window by clicking on X the application goes off ( you do not see it on desktop) but when you open the task manager, you can see that the application is still there. The problem is that it happens just sometimes. Any ideas? It is the way I close the appliaction: Private Sub MDIForm_QueryUnload(Cancel As Integer, UnloadMode As Integer) If MsgBox("Are you sure you want to Exit the application?", vbYesNo + vbQuestion, "Application") = vbNo Then Cancel = True End If End Sub Private Sub MDIForm_Terminate() fnWEHostShtdn End Sub Private Sub MDIForm_Unload(Cancel As Integer) If Me.WindowState <> vbMinimized Then SaveSetting App.Title, "Settings", "MainLeft", Me.Left SaveSetting App.Title, "Settings", "MainTop", Me.Top SaveSetting App.Title, "Settings", "MainWidth", Me.Width SaveSetting App.Title, "Settings", "MainHeight", Me.Height End If End Sub The other question is that how I can check if an application is running and if for any reason (even a hard close by user) the application is closed, it reopens itself. Thanks in advanced. Nahitan

    D 1 Reply Last reply
    0
    • N nahitan

      Hi there, I have a VB MFC that uses a dll for sending, receiving, dispalying and logging data from/to another application the problem is that SOMETIMES when I close the VB window by clicking on X the application goes off ( you do not see it on desktop) but when you open the task manager, you can see that the application is still there. The problem is that it happens just sometimes. Any ideas? It is the way I close the appliaction: Private Sub MDIForm_QueryUnload(Cancel As Integer, UnloadMode As Integer) If MsgBox("Are you sure you want to Exit the application?", vbYesNo + vbQuestion, "Application") = vbNo Then Cancel = True End If End Sub Private Sub MDIForm_Terminate() fnWEHostShtdn End Sub Private Sub MDIForm_Unload(Cancel As Integer) If Me.WindowState <> vbMinimized Then SaveSetting App.Title, "Settings", "MainLeft", Me.Left SaveSetting App.Title, "Settings", "MainTop", Me.Top SaveSetting App.Title, "Settings", "MainWidth", Me.Width SaveSetting App.Title, "Settings", "MainHeight", Me.Height End If End Sub The other question is that how I can check if an application is running and if for any reason (even a hard close by user) the application is closed, it reopens itself. Thanks in advanced. Nahitan

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      This is usually caused by an improper shutdown of a component in your app. Most likely, this would be the .DLL you're using. It's possible that it created a seperate thread(s) that are still running when your app quits. You'll have to check with the docs or anything else you can find on this library and see if it needs you to do anything special to shut it down before your app closes.

      Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
           2006, 2007

      N 1 Reply Last reply
      0
      • D Dave Kreskowiak

        This is usually caused by an improper shutdown of a component in your app. Most likely, this would be the .DLL you're using. It's possible that it created a seperate thread(s) that are still running when your app quits. You'll have to check with the docs or anything else you can find on this library and see if it needs you to do anything special to shut it down before your app closes.

        Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
             2006, 2007

        N Offline
        N Offline
        nahitan
        wrote on last edited by
        #3

        Thanks for the reply, but when you want purposely close the application, is it the VB application responsible for that or the dll application which is written in C++ and has many threads? Thanks

        D 1 Reply Last reply
        0
        • N nahitan

          Thanks for the reply, but when you want purposely close the application, is it the VB application responsible for that or the dll application which is written in C++ and has many threads? Thanks

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #4

          Yes! Any .DLL you load becomes a part of your code, not a seperate process. This is a curious question, because throughout all coding, if your code creates or loads something, your code is also responsible for managing and destroying that something properly. Making the assumption that an object or runtime can clean itself up without you telling it to do so is a very bad thing to do. This practice leads to unstable applications and operating systems. For instance, if you application creates a Graphics object, you are also responsible for destroying it when your done with it. If not, you'll eventually run the system out of resources and crash the whole operating system.

          Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
               2006, 2007

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups