如题,如何通过已知的线程ID取得进程ID?
解决方案 »
- 不同的编译解决方案平台的两个小问题
- vc6中得到列表框中的内容怎么进行排序呢
- 感觉学API中最难的问题......请教大家是如何做的
- 我刚学vc几天,问一个菜问题:“××(乱码)中包含无效的路径”怎么回事呀?
- 如何实现这样监控程序?????? ------ 给分68
- 关于消息循环的问题,请教大家
- 弹出菜单点菜鸟问题,大虾们帮帮忙呀
- 我要在VC程序中下载一个网上的文件保存到硬盘上,如HTTP://CSDN/downfile/be.jpg ,把be.jpg保存到硬盘,用什么实现好呢?
- MFC中,为什么做好的程序,隔天再打开就出错呢
- 在vc环境下调试windows c程序调不通,怎么回事?
- Format()的问题
- 全局 鼠标 hook ,如何检测
BOOL RefreshThreadList (DWORD dwOwnerPID)
{
HANDLE hThreadSnap = NULL;
BOOL bRet = FALSE;
THREADENTRY32 te32 = {0};
// Take a snapshot of all threads currently in the system. hThreadSnap = CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, 0);
if (hThreadSnap == (HANDLE)-1)
return (FALSE);
// Fill in the size of the structure before using it. te32.dwSize = sizeof(THREADENTRY32);
// Walk the thread snapshot to find all threads of the process.
// If the thread belongs to the process, add its information
// to the display list.
if (Thread32First(hThreadSnap, &te32))
{
do
{
if (te32.th32OwnerProcessID == dwOwnerPID)
{
TRACE( "\nTID\t\t%d\n", te32.th32ThreadID);
TRACE( "Owner PID\t%d\n", te32.th32OwnerProcessID);
TRACE( "Delta Priority\t%d\n", te32.tpDeltaPri);
TRACE( "Base Priority\t%d\n", te32.tpBasePri);
}
}
while (Thread32Next(hThreadSnap, &te32));
bRet = TRUE;
}
else
bRet = FALSE; // could not walk the list of threads
// Do not forget to clean up the snapshot object. CloseHandle (hThreadSnap);
return (bRet);
}
te32.th32OwnerProcessID