Jump to content
  • Advertisement


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


Problem registering a callback function in DirectPlay

This topic is 5794 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am a newbie in DirectPlay and am following some tutorials on MSDN (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dx8_c/directx_cpp/Play/CPP_Tut/Tutorial9_ClientServer.asp) 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 (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dx8_c/directx_cpp/Play/Using/ImplementingCallbackFunction.asp) doesn''t tell me anything I don''t already know.

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!