函数-线程遍历
/// <summary> /// 线程遍历 /// </summary> /// <returns></returns> BOOL EnumThread() { THREADENTRY32 te32 = { 0 }; te32.dwSize = sizeof(THREADENTRY32); HANDLE hThreadSnap = ::CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, 0);// 获取全部线程快照 if (INVALID_HANDLE_VALUE == hThreadSnap) { ShowError(L"CreateToolhelp32Snapshot"); return FALSE; } BOOL bRet = ::Thread32First(hThreadSnap, &te32);// 获取快照中第一条信息 while (bRet) { printf("[%d]\t", te32.th32OwnerProcessID);// 显示 Owner Process ID printf("[%d]\n", te32.th32ThreadID);// 显示 Thread ID bRet = ::Thread32Next(hThreadSnap, &te32);// 获取快照中下一条信息 } ::CloseHandle(hThreadSnap);// 关闭句柄 return TRUE; }