Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Kill Process Using a Process Name

Status
Not open for further replies.

iranor

Programmer
Jun 17, 2004
174
CA
Code:
#using <mscorlib.dll>
#using <System.dll>

using namespace System;
using namespace System::Diagnostics;
using namespace System::ComponentModel;

int main() {
    // Get all instances of Notepad running on computer.
    Process* localByName[] = Process::GetProcessesByName(S"notepad");

What for() should I use there? I need to get the process ID, make a for loop then pass the process id in the following code:

Code:
DWORD dwProcess;
HANDLE hProcess = OpenProcess(PROCESS_TERMINATE, FALSE, dwProcess);
TerminateProcess(hProcess, 1);
CloseHandle(hProcess);
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top