如何获取使用标准库创建的线程的winapi id? [英] How to get the winapi id of a thread that has been created using the standard library?
本文介绍了如何获取使用标准库创建的线程的winapi id?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
C ++ 11的标准库包含< thread>
,它允许创建线程。但是,Windows api需要一些功能的ID( PostThreadMessage ,即)。如何获得?
C++11’s standard library contains <thread>
which allows threads to be created. However, the Windows api requires an ID for some functions (PostThreadMessage, namely). How can I get it?
注释: std :: thread :: get_id()
work:
PostThreadMessage(m_thread->get_id(), WM_QUIT, 0, 0);
e:\documents\khook\khooker\hook_runner.cpp(129): error C2664: 'PostThreadMessageW' : cannot convert parameter 1 from 'std::thread::id' to 'DWORD'
推荐答案
使用成员函数 native_handle()
。它提供本机线程句柄。然后你可以调用 GetThreadId()
。
这篇关于如何获取使用标准库创建的线程的winapi id?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文