The C ++ 11s standard library contains <thread> , which allows you to create threads. However, for Windows api, an ID is required for some functions ( PostThreadMessage , namely). How can i get it?
<thread>
note: std::thread::get_id() does not seem to work:
std::thread::get_id()
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'
Use the member function native_handle() . It provides a native flow handle. Then you can call GetThreadId() on it.
native_handle()
GetThreadId()
The thread::id class allows comparisons between id and output. It does not provide a means to access the actual base id . You can try to output it to stringstream and then, apparently, play it out.
thread::id
id
stringstream