Thread: Commands for terminating programs?

  1. #1
    Registered User
    Join Date
    Jan 2003

    Question Commands for terminating programs?

    I'm interested in writing a program which, if it is possible, will terminate another program upon execution. For example, could a program be written that would, when run, terminate any instances of "notepad.exe" that are open at the time? And if so, what command should be used to terminate the other program?

  2. #2
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    You need WinAPI....

    One method - EnumWindows() to get handles to all open windows.....GetWindowModuleFileName() - to see if it runs from "notepad.exe" - if so...SendMessage() with WM_QUIT or GetWindowThreadProcessId() to get the PID....use that in OpenProcess() to get handle to process...then call TerminateProcess() to kill the app

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 07-27-2007, 12:48 PM
  2. Problem using java programs within C code
    By lemania in forum Linux Programming
    Replies: 1
    Last Post: 05-08-2005, 02:02 AM
  3. POSIX/DOS programs?
    By nickname_changed in forum C++ Programming
    Replies: 1
    Last Post: 02-28-2003, 05:42 AM
  4. Dos commands hehe
    By Carp in forum A Brief History of
    Replies: 2
    Last Post: 01-17-2003, 02:51 PM
  5. executing c++ programs on the web
    By gulti01 in forum C++ Programming
    Replies: 4
    Last Post: 08-12-2002, 03:12 AM