/*
 * DPlayRelease
 *
 * Wrapper for DirectPlay Release API.
 */
HRESULT DPlayRelease(void)
{
	HRESULT hr = E_FAIL;

	if (glpDP)
	{
		// free session desc, if any
		if (glpdpSD) 
		{
			free(glpdpSD);
			glpdpSD = NULL;
		}

		// free connection settings structure, if any (lobby stuff)
		if (glpdplConnection)
		{
			free(glpdplConnection);
			glpdplConnection = NULL;
		}
		// release dplay
		hr = IDirectPlayX_Release(glpDP);
		glpDP = NULL;
	}

	return hr;
}
Esempio n. 2
0
// ////////////////////////////////////////////////////////////////////////
// Shutdown the DPLAY interface
HRESULT DestroyDirectPlayInterface(HWND hWnd, LPDIRECTPLAY4A lpDirectPlay4A)
{
	HRESULT		hr = DP_OK;
	if (lpDirectPlay4A)
	{
		hr = IDirectPlayX_Release(glpDP);
	}
	return (hr);
}
/*
 * DPlayCreate
 *
 * Wrapper for DirectPlay Create API.
 * Retrieves a DirectPlay4/DirectPlay4A interface based on the UNICODE flag
 * 
 */
HRESULT DPlayCreate(LPVOID lpCon)
{
	HRESULT hr=E_FAIL;

	// release if already exists
	if (glpDP) IDirectPlayX_Release(glpDP);
	glpDP=NULL;


	// create a DirectPlay4(A) interface
	hr = CoCreateInstance(&CLSID_DirectPlay, NULL, CLSCTX_INPROC_SERVER,
#ifdef UNICODE
						  &IID_IDirectPlay4, (LPVOID *) &glpDP);
#else
						  &IID_IDirectPlay4A, (LPVOID *) &glpDP);
#endif
	if (FAILED(hr))
		return (hr);

#if 1
	// initialize w/address
	if (lpCon)
	{
		hr = IDirectPlayX_InitializeConnection(glpDP, lpCon, 0);
		if (FAILED(hr))
			goto FAILURE;
	}
	return hr;

FAILURE:
	IDirectPlayX_Release(glpDP);
	glpDP = NULL;
#endif

	return hr;
}
Esempio n. 4
0
//====================================================================================================
//	DPlayRelease
//====================================================================================================
HRESULT DPlayRelease(void)
{
    HRESULT hr = DP_OK;

	if (g_lpDP)
	{
		IDirectPlayX_Close(g_lpDP );

		hr = IDirectPlayX_Release(g_lpDP);
		g_lpDP = NULL;
	}
	
	CoUninitialize();

    return hr;
}