C++ createthread怎么传递多个参数?
PHP中文网
PHP中文网 2017-04-17 15:07:23
0
1
639

线程函数:

DWORD WINAPI socket2(LPVOID lpp)
{
    SOCKET s = ((RECVPARAM*)lpp)->ServerSocket;
    //do morething...
    return 0;
}

创建线程:

struct RECVPARAM
{
    SOCKET ClientSocket;
    SOCKET ServerSocket;
};
RECVPARAM* svc; //这个svc的值是一大堆函数生成的,这里就不贴了
DWORD tid;
RECVPARAM th2 = {svc->ServerSocket,svc->ClientSocket};
int x = "0"; //我还想把这个x传给socket2函数
HANDLE h2 = CreateThread(0,0,socket2,&th2,0,&tid);

请问在CreateThread单独时候怎么把X也传给socket2函数?

新手 大神轻喷

PHP中文网
PHP中文网

认证高级PHP讲师

reply all(1)
刘奇

Solved, just redefine a structure

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!