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;
}
But i get the following error message
error C2664: ‘WaitForSingleObject’ : cannot convert parameter 1 from ‘uintptr_t’ to ‘HANDLE’
Could someone please help me ?
You need to cast the
uintptr_tto typeHANDLE, this is demonstrated in the second example on this page, more specifically:(note: this is only legal with
_beginthreadex)