C++ 列出线程c++;
这段代码它列出了所有进程和进程的所有线程,但我希望它只列出一个进程的线程的pid。。。示例:explorer.exe pid=5454通过pid希望他拥有线程和线程状态的ID。将进程ID作为命令行参数传递给程序并过滤掉所需的内容如何C++ 列出线程c++;,c++,c,multithreading,visual-c++,C++,C,Multithreading,Visual C++,这段代码它列出了所有进程和进程的所有线程,但我希望它只列出一个进程的线程的pid。。。示例:explorer.exe pid=5454通过pid希望他拥有线程和线程状态的ID。将进程ID作为命令行参数传递给程序并过滤掉所需的内容如何 while( pi ) { SYSTEM_PROCESS_INFORMATION* next = PROCESS_INFORMATION_NEXT( pi );
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;
}
while(pi)
{
系统处理信息*next=处理信息\U next(pi);
UINT32计数,n;
if(argc>1&&pi->UniqueProcessId==(句柄)atoi(argv[1])){
printf(“*********************************************************\n”);
if(pi->ImageName.Buffer)
wprintf(L“%u%s您可以在msdn上看到
我想这就是你要找的。答案中可能有重复的地方。最好在答案中总结所需的步骤,而不是仅仅发布链接。这样,如果链接将来更改或消失,答案仍然有用。如果(argc>1&&pi->UniqueProcessId==(HANDLE)atoi(argv[1])详细说明?