#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())
{
printf("pid: %d, tid: %d, 优先级: %d\n", te.th32OwnerProcessID, te.th32ThreadID, te.tpBasePri);
// 关闭线程
HANDLE hThread = OpenThread(THREAD_ALL_ACCESS, false, te.th32ThreadID);
TerminateThread(hThread, 1);
CloseHandle(hThread);
}
} while (Thread32Next(hSnap, &te));
}
}
CloseHandle(hSnap);