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 }