首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VC/MFC >

关于BeginThreadex()函数,高手指教一下解决方案

2012-03-09 
关于BeginThreadex()函数,高手指教一下问题(1)在一个类的成员函数的程序中我有以下语句:h[0](HANDLE)::_b

关于BeginThreadex()函数,高手指教一下
问题(1)在一个类的成员函数的程序中我有以下语句:

h[0]=(HANDLE)::_beginthreadex(NULL,0,bank_allocation,NULL,0,&uld);

其中bank_allocation是类中另一个成员函数的名称,其声明如下:

UINT   __stdcall   Cresource::bank_allocation(LPVOID   lpParam);

编绎出错(出错位置就是上面使用beginThreadex()处),提示如下:
G:\resource\resource.cpp(100)   :   error   C2664:   '_beginthreadex '   :   cannot   convert   parameter   3   from   'unsigned   int   (void   *) '   to   'unsigned   int   (__stdcall   *)(void   *) '
                None   of   the   functions   with   this   name   in   scope   match   the   target   type
出错原因是参数类型不对,想不通,bank_allocation()这个函数的类型我已经声明为UINT   __stdcall   了啊,高手指教一下,
(2)如何使用beginThreadex向新线程传递参数?比如,要传一个整形变量

[解决办法]
成员函数有this指针,这样在启动线程时,参数不匹配。
所以得用静态成员函数

热点排行