Magmai Kai - (et all) need dplay8 help
Hey Magmai (or anyone)
I posted this in the Dx forum, and Magmai suggested I try out
this one..(thanks dude).
I''m just trying to get a simple dplay8 project going..I''m looking for some help creating a basic UDP client/server app
going but I''m not sure how to *properly* setup my dplay8
objects..
Yes I''m in the process of reading the sdk docs, and YES I do understand client/server, peer-peer theory (this will be my first
mplayer project..)
Any samples other than the sdk docs would be helpfull, or even
some suggestions as to what I need to remember (ie. any "gotchas")..
thanks for any advice/help,
Wazoo
Hi wazoo69, here is a snippet of code I use to initialize Direct Play for a peer-to-peer session.
webmaster@lostlogic.com
www.lostlogic.com
Edited by - lostlogic on March 18, 2001 11:10:40 AM
HRESULT hrInitializeDirectPlay( HWND hWindow ) { HRESULT hReturn; int i; // Initialize COM hReturn = CoInitialize( NULL ); if( FAILED(hReturn) ) { MessageBox( hWindow, "Error Initializing COM", "DirectPlay Error", MB_ICONERROR ); return hReturn; } // Initialize critical sections for multi-threading InitializeCriticalSection( &g_csModifyPlayer ); // Create IDirectPlay8Peer Object if( FAILED( hReturn = CoCreateInstance( CLSID_DirectPlay8Peer, NULL, CLSCTX_INPROC_SERVER, IID_IDirectPlay8Peer, (LPVOID*) &g_pDP ) ) ) MessageBox( hWindow, "Can't Create DPlayPeer", "DirectPlay Error", MB_ICONERROR ); // Init IDirectPlay8Peer Message Handler if( FAILED( hReturn = g_pDP->Initialize( NULL, DirectPlayMessageHandler, 0 ) ) ) { MessageBox( hWindow, "Failed to Message Handler", "DirectPlay Error", MB_ICONERROR ); return -1; } // Create a device address hReturn = CoCreateInstance( CLSID_DirectPlay8Address, NULL,CLSCTX_INPROC_SERVER, IID_IDirectPlay8Address, (LPVOID*) &g_pDeviceAddress ); if( FAILED(hReturn) ) { MessageBox( hWindow, "Failed to Create Device", "CoCreateInstance()", MB_ICONERROR ); return -1; } // Set our service provider to TCP/IP if( FAILED( hReturn = g_pDeviceAddress->SetSP( &CLSID_DP8SP_TCPIP ) ) ) { MessageBox( hWindow, "Failed to SetSP() for Device Address", "Invalid Param", MB_ICONERROR ); return -1; } // Create a host address hReturn = CoCreateInstance( CLSID_DirectPlay8Address, NULL,CLSCTX_INPROC_SERVER, IID_IDirectPlay8Address, (LPVOID*) &g_pHostAddress ); if( FAILED(hReturn) ) { MessageBox( hWindow, "Failed to Create Host Address()", "Invalid Param", MB_ICONERROR ); return -1; } // Set the host address to TCP/IP if( FAILED( hReturn = g_pHostAddress->SetSP( &CLSID_DP8SP_TCPIP ) ) ) { MessageBox( hWindow, "Failed to SetSP() for Host Address", "Invalid Param", MB_ICONERROR ); return -1; } // Create connection complete event for later use g_hConnectCompleteEvent = CreateEvent( NULL, FALSE, FALSE, NULL ); vShowText(hLB_Output,"<<--TCP INITED-->>"); // Init miscellaneous variables for( i = 0 ; i < MAX_PLAYERS ; i++ ) { PlayerInfo[i].bActive = 0; } return S_OK;}
webmaster@lostlogic.com
www.lostlogic.com
Edited by - lostlogic on March 18, 2001 11:10:40 AM
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement