Commands for terminating programs?

This is a discussion on Commands for terminating programs? within the C++ Programming forums, part of the General Programming Boards category; I'm interested in writing a program which, if it is possible, will terminate another program upon execution. For example, could ...

  1. #1
    Registered User
    Join Date
    Jan 2003
    Posts
    1

    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
    Posts
    5,789
    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, 04:42 AM
  4. Dos commands hehe
    By Carp in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 01-17-2003, 01: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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21