Windows获取当前线程,当前进程的ID

获取当前线程的id
方法一:

#include <thread>
thread::id currentID = this_thread::get_id();
cout<<"当前线程的ID是:"<<thread::id<<endl;

方法二:

int threadID = GetCurrentThreadId();
cout<<"当前线程的ID是:"<<threadID<<endl;

获取当前进程的id

int processID = GetCurrentProcessId();
cout<<"当前进程的ID是:"<<processID<<endl;
posted @ 2022-12-05 14:41  手写不期而遇  阅读(1205)  评论(0编辑  收藏  举报