P psynet123 Unregistered / Unconfirmed GUEST, unregistred user! 2008-02-20 #1 void MP4_ServerSetStart(void(CALLBACK *StartCap)(DWORD dwChannel))
白 白河愁 Unregistered / Unconfirmed GUEST, unregistred user! 2008-02-21 #5 procedure MP4_ServerSetStart(StartCap: Pointer; dwChannel: DWORD);
X [xiaopei] Unregistered / Unconfirmed GUEST, unregistred user! 2008-02-21 #6 //这样。<br>type TStartCaprocedure (dwChannelWORD);stdcall;<br><br>procedure MP4_ServerSetStart(StartCap:TStartCap);<br><br>//调用时只须这样。<br>//先定义一个回调函数_StartCap<br>procedure _StartCap(dwChannelWORD);stdcall;<br>begin<br> ShowMessage('调用了_StartCap函数');<br> ShowMessage(Format('dwChannel的值是:%u',[dwChannel]));<br>end;<br>//然后这样调用就行了<br>MP4_ServerSetStart(_StartCap);
//这样。<br>type TStartCaprocedure (dwChannelWORD);stdcall;<br><br>procedure MP4_ServerSetStart(StartCap:TStartCap);<br><br>//调用时只须这样。<br>//先定义一个回调函数_StartCap<br>procedure _StartCap(dwChannelWORD);stdcall;<br>begin<br> ShowMessage('调用了_StartCap函数');<br> ShowMessage(Format('dwChannel的值是:%u',[dwChannel]));<br>end;<br>//然后这样调用就行了<br>MP4_ServerSetStart(_StartCap);
P psynet123 Unregistered / Unconfirmed GUEST, unregistred user! 2008-02-21 #7 接受 [xiaopei], 的答案,分数会在2008-02-21 12:00转给你,主要的目的是让更多的人知道怎么转,谢谢!!!
P psynet123 Unregistered / Unconfirmed GUEST, unregistred user! 2008-02-21 #8 但是现在有个问题, void MP4_ServerSetStart(void(CALLBACK *StartCap)(DWORD dwChannel)) 这个是某dll的函数,现在delphi要调用的话,把你的改成如下的是否可行?<br><br><br>//这样。<br>type TStartCaprocedure (dwChannelWORD);stdcall;<br><br>procedure MP4_ServerSetStart(StartCap:TStartCap); stdcall;external 'XXX.dll';<br><br>//调用时只须这样。<br>//先定义一个回调函数_StartCap<br>procedure _StartCap(dwChannelWORD);stdcall;<br>begin<br> ShowMessage('调用了_StartCap函数');<br> ShowMessage(Format('dwChannel的值是:%u',[dwChannel]));<br>end;<br>//然后这样调用就行了<br>MP4_ServerSetStart(_StartCap);
但是现在有个问题, void MP4_ServerSetStart(void(CALLBACK *StartCap)(DWORD dwChannel)) 这个是某dll的函数,现在delphi要调用的话,把你的改成如下的是否可行?<br><br><br>//这样。<br>type TStartCaprocedure (dwChannelWORD);stdcall;<br><br>procedure MP4_ServerSetStart(StartCap:TStartCap); stdcall;external 'XXX.dll';<br><br>//调用时只须这样。<br>//先定义一个回调函数_StartCap<br>procedure _StartCap(dwChannelWORD);stdcall;<br>begin<br> ShowMessage('调用了_StartCap函数');<br> ShowMessage(Format('dwChannel的值是:%u',[dwChannel]));<br>end;<br>//然后这样调用就行了<br>MP4_ServerSetStart(_StartCap);
X [xiaopei] Unregistered / Unconfirmed GUEST, unregistred user! 2008-02-21 #9 改正:<br>procedure MP4_ServerSetStart(StartCap:TStartCap);<br>VC默认调用是cdecl约定。所以上面那一句应该再在后面加一句cdecl关键字才是正确的。<br>procedure MP4_ServerSetStart(StartCap:TStartCap); cdecl;external 'DllName.dll';<br><br>MP4_ServerSetStart函数VC并没有声明为stdcall,所以默认应该是cdecl调用约定。
改正:<br>procedure MP4_ServerSetStart(StartCap:TStartCap);<br>VC默认调用是cdecl约定。所以上面那一句应该再在后面加一句cdecl关键字才是正确的。<br>procedure MP4_ServerSetStart(StartCap:TStartCap); cdecl;external 'DllName.dll';<br><br>MP4_ServerSetStart函数VC并没有声明为stdcall,所以默认应该是cdecl调用约定。