3

こんにちは、これは私のコードです

#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' に変換できません

誰か助けてくれませんか?

4

1 に答える 1

7

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(...);

(note: this is only legal with _beginthreadex)

于 2012-09-26T16:15:08.367 に答える