Step 2: Retrieving the Connection Settings
After the DirectPlayLobby object has been created, use the IDirectPlayLobby2::GetConnectionSettings method to retrieve the connection settings returned from the lobby. If this method returns DPERR_NOTLOBBIED, the lobby did not start this application and the user will have to configure the connection manually. If any other error occurs, your application should report an error that indicates that lobbying the application failed.
The following example shows how to retrieve the connection settings:
// Retrieve the connection settings from the lobby.
// If this routine returns DPERR_NOTLOBBIED, then a lobby did not
// start this application and the user needs to configure the
// connection.
// Pass a NULL pointer to retrieve only the size of the
// connection settings
hr = lpDirectPlayLobbyA->GetConnectionSettings(0, NULL, &dwSize);
if (DPERR_BUFFERTOOSMALL != hr)
goto FAILURE;
// Allocate memory for the connection settings.
lpConnectionSettings = (LPDPLCONNECTION) GlobalAllocPtr(GHND, dwSize);
if (NULL == lpConnectionSettings)
{
hr = DPERR_OUTOFMEMORY;
goto FAILURE;
}
// Retrieve the connection settings.
hr = lpDirectPlayLobbyA->GetConnectionSettings(0,
lpConnectionSettings, &dwSize);
if FAILED(hr)
goto FAILURE;