windows 下获取当前进程的线程数量

#include <TlHelp32.h>

int
get_thread_amount() { int i = 0; char Buff[9]; PROCESSENTRY32 pe32; pe32.dwSize = sizeof(pe32); int processid = GetCurrentProcessId(); HANDLE hProcessSnap = ::CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); if (hProcessSnap == INVALID_HANDLE_VALUE) { printf("CreateToolhelp32Snapshot() failed. error code:%d.\n", GetLastError()); return 0; } BOOL bMore = ::Process32First(hProcessSnap, &pe32); HANDLE hProcess; while (bMore) { if (pe32.th32ProcessID == processid) { return pe32.cntThreads; } bMore = Process32Next(hProcessSnap, &pe32); i++; } return 0; }

 

windows 下获取当前进程的线程数量,布布扣,bubuko.com

windows 下获取当前进程的线程数量

上一篇:JAVA大集合数据分批次进行切割处理


下一篇:JAVA开发简易计算器界面-SWT