比如,有一个1.exe 我想知道他是那个文件创建的,怎么办
PROCESSENTRY32 pe32={0};
DWORD dwRemoteProcessId;
hProcessSnap=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
//打开进程快照
if(hProcessSnap==(HANDLE)-1)
{
MessageBox("CreateToolhelp32Snapshot failed","",MB_OK);
} //失败返回
pe32.dwSize=sizeof(PROCESSENTRY32);
if(Process32First(hProcessSnap,&pe32)) //获取第一个进程
{
do{
CString te;
te=pe32.szExeFile;//在98下就是这里了。在2k要用psapi了。
}
while(Process32Next(hProcessSnap,&pe32));//获取下一个进程
}
else
{
MessageBox("取第一个进程失败","",MB_OK);
return;
}
}
HANDLE GetParentID(CString FilePath)
{
HANDLE hSnapShot=CreateToolhelp32Snapshot(TH32CS_SNAPALL,NULL);
PROCESSENTRY32 pEntry;
pEntry.dwSize =sizeof(pEntry);
BOOL hRes=Process32First(hSnapShot,&pEntry);
while(hRes)
{
if(FilePath==pEntry.szExeFile)
return pEntry.th32ParentProcessID;
hRes=Process32Next(hSnapShot,&pEntry);
}
return 0;
}
CString GetParentPath(HANDLE handle)
{
HANDLE hSnapShot=CreateToolhelp32Snapshot(TH32CS_SNAPALL,NULL);
PROCESSENTRY32 pEntry;
pEntry.dwSize =sizeof(pEntry);
BOOL hRes=Process32First(hSnapShot,&pEntry);
while(hRes)
{
if(handle==pEntry.th32ParentProcessID)
return pEntry.szExeFile;
hRes=Process32Next(hSnapShot,&pEntry);
}
return NULL;
}