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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Closing hh.exe when my programs exits.

Closing hh.exe when my programs exits.

Scheduled Pinned Locked Moved C / C++ / MFC
questionhelp
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.
  • O Offline
    O Offline
    oRion
    wrote on last edited by
    #1

    Hi, I have launch the hh.exe ( help viewer) via CreateProcess(). I am trying to close this window when my main program exits. How do I do that? Here's a snip of my code... bSuccess = CreateProcess ("C:\\WINDOWS\\HH.EXE"," NATURAL.CHM", NULL, NULL, TRUE, NORMAL_PRIORITY_CLASS, NULL, NULL, &si, &ppi ); helphnd = ppi.hProcess; CloseHandle ( ppi.hThread ); CloseHandle ( ppi.hProcess ); The code is written as part of defining a 'Help' menuitem. Quite new to the idea of process, copy this idea from FAQ in this website. If CloseHandle is executed right after CreateProcess, that means the process should have finish and return to the executing program, therefore closehandle would do the cleaning up? Now, I am executing something in the ::OnCloseDocument(), how do I check whether the help program is still running,so that I wouldn't be trying to close the program? :~

    T 1 Reply Last reply
    0
    • O oRion

      Hi, I have launch the hh.exe ( help viewer) via CreateProcess(). I am trying to close this window when my main program exits. How do I do that? Here's a snip of my code... bSuccess = CreateProcess ("C:\\WINDOWS\\HH.EXE"," NATURAL.CHM", NULL, NULL, TRUE, NORMAL_PRIORITY_CLASS, NULL, NULL, &si, &ppi ); helphnd = ppi.hProcess; CloseHandle ( ppi.hThread ); CloseHandle ( ppi.hProcess ); The code is written as part of defining a 'Help' menuitem. Quite new to the idea of process, copy this idea from FAQ in this website. If CloseHandle is executed right after CreateProcess, that means the process should have finish and return to the executing program, therefore closehandle would do the cleaning up? Now, I am executing something in the ::OnCloseDocument(), how do I check whether the help program is still running,so that I wouldn't be trying to close the program? :~

      T Offline
      T Offline
      Todd Smith
      wrote on last edited by
      #2

      unsigned long status;
      int rv = GetExitCodeProcess(ppi.hProcess, &status);

      Todd Smith

      O 1 Reply Last reply
      0
      • T Todd Smith

        unsigned long status;
        int rv = GetExitCodeProcess(ppi.hProcess, &status);

        Todd Smith

        O Offline
        O Offline
        oRion
        wrote on last edited by
        #3

        THanks for the reply. It's this function just checking whether the process is closed? How to close the process then?

        T 1 Reply Last reply
        0
        • O oRion

          THanks for the reply. It's this function just checking whether the process is closed? How to close the process then?

          T Offline
          T Offline
          Todd Smith
          wrote on last edited by
          #4

          First try to get a handle to the main window and then do a SendMessage with WM_CLOSE. If that doens't work then try TerminateProcess. See http://www.codetools.com/threads/asyncprocnotify.asp[^] Todd Smith

          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