得到pid 获取程序名字
Code
void PrintProcessNameAndId(DWORD ProcessId)
{
char szProcessName[MAX_PATH]="unknown";
HANDLE hProecss=OpenProcess(PROCESS_ALL_ACCESS,FALSE,ProcessId);
if (hProecss!=NULL)
{
HMODULE hMod;
DWORD cdNeeded;
if (EnumProcessModules(hProecss,&hMod,sizeof(hMod),&cdNeeded))
{
GetModuleBaseName(hProecss,hMod,szProcessName,sizeof(szProcessName));
}
else return;
}
else
return;
CString str;
str.Format("%s",szProcessName);
AfxMessageBox(str);
CloseHandle(hProecss);
}