VC 根据线程句柄获得线程ID 根据线程句柄获得进程ID

/*
hThread:线程句柄
返回值:成功返回线程ID,否则返回零值
*/

DWORD GetThreadIdEx(HANDLE hThread)
{
 THREAD_BASIC_INFORMATION         tbi;
 DWORD dwReturnedSize;
 if(::ZwQueryInformationThread(hThread,ThreadBasicInformation,&tbi,sizeof(THREAD_BASIC_INFORMATION),&dwReturnedSize)
  !=STATUS_SUCCESS)  return 0;
 return (DWORD)tbi.ClientId.UniqueThread; //返回线程ID
 //return (DWORD)tbi.ClientId.UniqueProcess; //返回进程ID
 }


 

所需头文件,至:http://download.csdn.net/source/2079829下载
posted @ 2011-07-17 18:41  eATM  阅读(1371)  评论(0编辑  收藏  举报