How to get the winapi id of a thread that has been created using the standard library?

后端 未结 2 1310
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-18 03:46

C++11’s standard library contains which allows threads to be created. However, the Windows api requires an ID for some functions (PostThreadMessa

相关标签:
2条回答
  • 2021-01-18 04:14

    The thread::id class only allows comparison between ids and an output. It does not provide a means to access the actual underlying id. You could try outputting it to a stringstream and then parsing it back in, I guess.

    0 讨论(0)
  • 2021-01-18 04:22

    Use the member function native_handle(). It provides the native thread handle. Then you can call GetThreadId() on it.

    0 讨论(0)
提交回复
热议问题