Original Post
the directX forum is not into dplay so i took this here:
i''m using the old style DirectPlayCreate(..) to init DPlay
before i do the DirectPlayEnumarate(...) 2 get the guids. after i get the guids, i cannot init Dplay with DirectPlayCreate(...) it gives me DPERR_UNAVAILABLE
here is the code
i have DX9
i dont like the CoCreateInstance(...) it suxx coz it makes my app multi-threaded and stuff
is there a prob with my code or is the damn DX?
include "log.h"
#pragma comment (lib, "dplay.lib")
#pragma comment (lib, "dplayx.lib")
#pragma comment (lib, "dxguid.lib")
LPDIRECTPLAY dp;
bool mpIPX = false;
bool mpTCPIP = false;
bool mpSERIAL = false;
bool mpMODEM = false;
GUID mpIPXguid;
GUID mpTCPIPguid;
GUID mpSERIALguid;
GUID mpMODEMguid;
BOOL FAR PASCAL mpEnumConnections(
LPGUID lpguidSP,
LPSTR lpSPName,
DWORD dwMajorVersion,
DWORD dwMinorVersion,
LPVOID lpContext)
{
if (strcmp(lpSPName, "IPX Connection For DirectPlay") == 0)
{
mpIPX = true;
mpIPXguid = *lpguidSP;
return TRUE;
}
if (strcmp(lpSPName, "Internet TCP/IP Connection For DirectPlay") == 0)
{
mpTCPIP = true;
mpTCPIPguid = *lpguidSP;
return TRUE;
}
if (strcmp(lpSPName, "Modem Connection For DirectPlay") == 0)
{
mpMODEM = true;
mpMODEMguid = *lpguidSP;
return TRUE;
}
if (strcmp(lpSPName, "Serial Connection For DirectPlay") == 0)
{
mpSERIAL = true;
mpSERIALguid = *lpguidSP;
return TRUE;
}
return TRUE;
}
int mpGetConnections()
{
int hr;
hr = DirectPlayEnumerate(mpEnumConnections, 0);
if (hr)
{
lprintf("Cannot Enumerate SPs\n");
return SYS_ERR;
}
return SYS_OK;
}
int mpInitialize()
{
if (mpGetConnections()) return SYS_ERR;
int hr = DirectPlayCreate(&mpIPXguid, &dp, NULL);
//{685BC400-9D2C-11cf-A9CD-00AA006886E3} GUID in registry and received from Enumerate
if (hr != DP_OK)
{
switch (hr)
{
case CLASS_E_NOAGGREGATION : lprintf("CLASS_E_NOAGGREGATION "); break;
case DPERR_EXCEPTION : lprintf("DPERR_EXCEPTION ");break;
case DPERR_INVALIDPARAMS : lprintf("DPERR_INVALIDPARAMS "); break;
case DPERR_UNAVAILABLE : lprintf("UNAVAIABLE CONNECTION"); break;
}
lprintf("Cannot initialize DirectPlay\n", hr);
return SYS_ERR;
}
return SYS_OK;
}