#include <iostream>
#include <Windows.h>
#include <Psapi.h>
#include <TlHelp32.h>
HANDLE hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, GetCurrentProcessId());
if (hSnap != INVALID_HANDLE_VALUE)
{
THREADENTRY32 te;
te.dwSize = sizeof(THREADENTRY32);
if ( Thread32First(hSnap, &te) )
{
do
{
if (te.th32OwnerProcessID == GetCurrentProcessId())
{
// 关闭线程 ExitThread(te.th32ThreadID);
printf("pid: %d, tid: %d, 优先级: %d\n", te.th32OwnerProcessID, te.th32ThreadID, te.tpBasePri);
}
} while (Thread32Next(hSnap, &te));
}
}
CloseHandle(hSnap);
原文:https://www.cnblogs.com/ajanuw/p/13739017.html