hi
how can i terminate a process using vc++
i check somewhere and i found TerminateProcess function
but this is not useful to terminate a process by it's name[for example notepad.exe]
i hope you help me

thanks but i receive Undeclared Identifier 'HANDLE' error
i don't know what should i add

Post down the total code so its easier to troubleshoot.

my program was under win32 console app
so 'HANDLE' was Undeclared for me
----------
now myApp is under mfc
this is the function

int CMyTaskManagerDlg::Killprocess(int nProcessID)
{
	
	HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, 0, nProcessID );

	BOOL nReturnVal = TerminateProcess( hProcess,0);
	CloseHandle (hProcess);
	return nReturnVal;

}

but how can i find the nProcessID for my notepad.exe to close it?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.