Thread count of a Process

  • Thread starter Thread starter Abubakar
  • Start date Start date
A

Abubakar

Hi,

In native/unmanaged vc2k5, I want to get the thread count of my process.
What apis do I have to use to get the thread count?

Regards,

Ab.
 
In native/unmanaged vc2k5, I want to get the thread count of my process.
What apis do I have to use to get the thread count?

Try the Thread32First, Thread32Next APIs.

Dave
 
Thanks. I wrote the following code:

DWORD pid = ::GetCurrentProcessId ();
THREADENTRY32 entry;
entry.dwSize = sizeof (THREADENTRY32 );
int count;
HANDLE handle = ::CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD , pid );
BOOL enum_more = Thread32First ( handle, & entry);
count = 0;
while (1)
{
enum_more = Thread32Next ( handle, & entry);
if ( !enum_more )
break;
if ( entry.th32OwnerProcessID == pid )
count ++;
}

Regards,

Ab.
 
Back
Top