Step 1: Enumerating the Service Providers
The first step in creating a manual connection is to request that the user select a communication medium for the application. Your application can identify the service providers installed on a personal computer by using the DirectPlayEnumerate function.
The following example shows how to enumerate the service providers:
DirectPlayEnumerate(DirectPlayEnumerateCallback, hWnd);
The first parameter in the DirectPlayEnumerate function is a callback that enumerates service providers registered with DirectPlay. The following example shows one possible way of implementing this callback function:
BOOL FAR PASCAL DirectPlayEnumerateCallback(
LPGUID lpSPGuid, LPTSTR lpszSPName, DWORD dwMajorVersion,
DWORD dwMinorVersion, LPVOID lpContext)
{
HWND hWnd = lpContext;
LRESULT iIndex;
LPGUID lpGuid;
// Store the service provider name in a combo box.
iIndex = SendDlgItemMessage(hWnd, IDC_SPCOMBO, CB_ADDSTRING,
0, (LPARAM) lpszSPName);
if (iIndex == CB_ERR)
goto FAILURE;
// Make space for the application GUID.
lpGuid = (LPGUID) GlobalAllocPtr(GHND, sizeof(GUID));
if (lpGuid == NULL)
goto FAILURE;
// Store the pointer to the GUID in a combo box.
*lpGuid = *lpSPGuid;
SendDlgItemMessage(hWnd, IDC_SPCOMBO, CB_SETITEMDATA,
(WPARAM) iIndex, (LPARAM) lpGuid);
FAILURE:
return (TRUE);
}