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. Managed C++/CLI
  4. Opening and closing an application

Opening and closing an application

Scheduled Pinned Locked Moved Managed C++/CLI
question
2 Posts 2 Posters 3 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.
  • S Offline
    S Offline
    squeaky
    wrote on last edited by
    #1

    I am trying to get my C program to open and close another application. ShellExecute (NULL,"open","C:/myproject.exe",NULL,NULL,SW_RESTORE); works to open the application, but I can't get it to close. I've tried DestroyWindow("C:/myproject.exe"); but it doesn't work. Can anyone tell me what to use for the file reference for DestroyWindow? Or is there a completely different way to do this better? squeaky

    N 1 Reply Last reply
    0
    • S squeaky

      I am trying to get my C program to open and close another application. ShellExecute (NULL,"open","C:/myproject.exe",NULL,NULL,SW_RESTORE); works to open the application, but I can't get it to close. I've tried DestroyWindow("C:/myproject.exe"); but it doesn't work. Can anyone tell me what to use for the file reference for DestroyWindow? Or is there a completely different way to do this better? squeaky

      N Offline
      N Offline
      Nish Nishant
      wrote on last edited by
      #2

      Hi squeaky Read my article below :- http://www.codeproject.com/system/newbiespawn.asp That'll show you how to use CreateProcess which gives you both the process handle and the thread handle for the main thread. Now use EnumWindows to enumerate all top level windows. Call GetWindowThreadProcessId on each HWND and compare with the thread ID you had saved earlier. If they match, post a WM_CLOSE message to this HWND. Hope this helps, Nish


      Author of the romantic comedy Summer Love and Some more Cricket [New Win] Review by Shog9 Click here for review[NW]

      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