【发布时间】:2014-01-05 03:09:30
【问题描述】:
这段代码列出了所有进程和进程的所有线程,但我希望它只列出 pid 进程的线程...例如:explorer.exe pid = 5454 通过 pid 希望他拥有的 id线程和线程状态。
【问题讨论】:
-
Listing Threads 的可能重复项
标签: c++ c multithreading visual-c++
这段代码列出了所有进程和进程的所有线程,但我希望它只列出 pid 进程的线程...例如:explorer.exe pid = 5454 通过 pid 希望他拥有的 id线程和线程状态。
【问题讨论】:
标签: c++ c multithreading visual-c++
如何将进程 ID 作为命令行参数传递给程序并过滤掉所需的内容。
while( pi )
{
SYSTEM_PROCESS_INFORMATION* next = PROCESS_INFORMATION_NEXT( pi );
UINT32 count, n;
if (argc > 1 && pi->UniqueProcessId == (HANDLE)atoi(argv[1])) {
printf("**************************************\n");
if( pi->ImageName.Buffer )
wprintf(L"%u %s <------ PROCESSO\r\n", pi->UniqueProcessId, pi->ImageName.Buffer);
else
wprintf(L"%u %s *\r\n", pi->UniqueProcessId, L"System Idle Process");
if( next )
count = ThreadCount( pi, (ULONG_PTR)next );
else
count = ThreadCount( pi, (ULONG_PTR)spi + size );
for( n=0; n<count; n++ )
{
SYSTEM_THREAD_INFORMATION* th = pi->Threads + n;
wprintf(L" [%u] StartAddress=%p ID Processo=%u IdThred=%u State=%u \r\n",
n+1, th->StartAddress, th->ClientId.UniqueProcess, th->ClientId.UniqueThread,th->WaitReason);
}
}
pi = next;
}
【讨论】:
你可以在 msdn 上看到this 我想这就是你要找的。
【讨论】: