int CDPlayServer :: StartServer(char *name)
{
DPSESSIONDESC2 dpsd; // session desc
HRESULT hr;
ZeroMemory( &dpsd, sizeof(dpsd) );
dpsd.dwSize = sizeof(dpsd);
dpsd.guidApplication = TicTacToeApp;
dpsd.dwMaxPlayers = 2;
dpsd.dwFlags = DPSESSION_DIRECTPLAYPROTOCOL;
if(FAILED(hr = lpdp->Open( &dpsd, DPOPEN_CREATE ))) // fails here
{
switch (hr)
{
case DPERR_UNINITIALIZED:
{
cout << "Err"; // this is printed
} break;
default:break;
}
return FAIL;
}
CPlayer p;
sprintf("HOST", p.name);
CreateLocalPlayer(p);
return SUCCESS;
}
[/source]
[source]
int CDPlay :: Init()
{
LPDIRECTPLAYLOBBYA old_lpdplobbyA = NULL; // old lobby pointer
CoInitialize(NULL); // registering COM
CO_UsedBy++;
// creating directplay object
if ( CoCreateInstance(CLSID_DirectPlay, NULL, CLSCTX_INPROC_SERVER,
IID_IDirectPlay4A,(LPVOID*)&lpdp ) != S_OK)
{
// return a messagebox error
CoUninitialize(); // unregister the comp
return(0);
}
// creating lobby object
DirectPlayLobbyCreate(NULL, &old_lpdplobbyA, NULL, NULL, 0);
// get new interface of lobby
old_lpdplobbyA->QueryInterface(IID_IDirectPlayLobby3A, (LPVOID *)&lpdplobby);
old_lpdplobbyA->Release(); // release old interface since we have new one
return SUCCESS;
}
My Geekcode: "GCS d s: a14 C++$ P+(++) L+ E-- W+++$ K- w++(+++) O---- M-- Y-- PGP- t X
R- tv+ b++ DI+(+++) D- G e* h!"
Decode my geekcode!
Geekcode.com
Visit our web site: Asylum Entertainment