本文介绍了WaitForSingleObject:如何从_beginthreadex获取处理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
hello guys这是我的代码
hello guys this is my code
#include "StdAfx.h"
#include <iostream>
#include <windows.h>
#include <process.h>
unsigned int __stdcall threadproc(void* lparam)
{
std::cout << "my thread" << std::endl;
return 0;
}
int main()
{
unsigned uiThread1ID = 0;
uintptr_t th = _beginthreadex(NULL, 0, threadproc, NULL, 0, &uiThread1ID);
WaitForSingleObject(th, INFINITE/*optional timeout, in ms*/);
return 0;
}
但我得到以下错误信息
错误C2664:'WaitForSingleObject':无法将参数1从'uintptr_t'转换为'HANDLE'
error C2664: 'WaitForSingleObject' : cannot convert parameter 1 from 'uintptr_t' to 'HANDLE'
有人可以帮助我吗?
Could someone please help me ?
推荐答案
您需要将 uintptr_t
转换为 HANDLE
,将在的第二个示例中更具体地演示:
You need to cast the uintptr_t
to type HANDLE
, this is demonstrated in the second example on this page, more specifically:
HANDLE hThread;
hThread = (HANDLE)_beginthreadex(...);
(注意:这只适用于 _beginthreadex
)
这篇关于WaitForSingleObject:如何从_beginthreadex获取处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!