码迷,mamicode.com
首页 > 系统相关 > 详细

枚举进程

时间:2019-04-17 00:17:37      阅读:204      评论:0      收藏:0      [点我收藏+]

标签:find   ESS   max   return   handle   highlight   word   ring   进程   

DWORD FindProcess(TCHAR *strProcessName)
{
	DWORD aProcesses[1024], cbNeeded, cbMNeeded;
	HMODULE hMods[1024];
	HANDLE hProcess;
	TCHAR szProcessName[MAX_PATH];

	if (!EnumProcesses(aProcesses, sizeof(aProcesses), &cbNeeded))  return 0;
	for (int i = 0; i < (int)(cbNeeded / sizeof(DWORD)); i++)
	{
		hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, aProcesses[i]);
		EnumProcessModules(hProcess, hMods, sizeof(hMods), &cbMNeeded);
		GetModuleFileNameEx(hProcess, hMods[0], szProcessName, sizeof(szProcessName));

		CString strPrcFullName(szProcessName);
		CString strPrcName(strProcessName);
		if (_tcsstr(strPrcFullName, strPrcName) || _tcsstr(strPrcFullName, strPrcName.MakeLower()))
		{
			CString strNameFull;
			strNameFull.Format(_T("Process full name:\n%s;"), szProcessName);
			//AfxMessageBox(strNameFull);
			return(aProcesses[i]);
		}
	}

	return 0;
}

  

枚举进程

标签:find   ESS   max   return   handle   highlight   word   ring   进程   

原文地址:https://www.cnblogs.com/hshy/p/10720983.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!