This topic is now archived and is closed to further replies.


Problem registering a callback function in DirectPlay

Recommended Posts

I am a newbie in DirectPlay and am following some tutorials on MSDN ( to add some simple server/client networking to my game. Everything made sense and I added it without any trouble except for registering a callback for my message handler. I can compile and run the tutorial project with no problems but the same code copied and pasted into my own project does not work. Here''s what I have:
// Here''s the relevant tutorial code

HRESULT WINAPI DirectPlayMessageHandler(PVOID pvUserContext, DWORD dwMessageId, PVOID pMsgBuffer);


g_pDPServer->Initialize(NULL, DirectPlayMessageHandler, 0 ); // This is the message handler

// Here''s my relevant code

class Network
 HRESULT WINAPI			DirectPlayMsgHandler( PVOID pvUserContext, DWORD dwMessageId, PVOID pMsgBuffer );
IDirectPlay8Server*		m_pDPServer;


m_pDPServer->Initialize( NULL, DirectPlayMsgHandler, 0 );
The error message I get is: error C2664: ''Initialize'' : cannot convert parameter 2 from ''long (void *,unsigned long,void *)'' to ''long (__stdcall *const )(void *,unsigned long,void *)'' None of the functions with this name in scope match the target type What is wrong with this? The only difference is that my code uses classes. The callback function help page on msdn ( doesn''t tell me anything I don''t already know.

Share this post

Link to post
Share on other sites