Step 4: Connecting to a Session

After the session description is properly configured, your application can use the IDirectPlayLobby::Connect method to start and connect itself to a session. If this method returns DP_OK, you can create one or more players. If it returns DPERR_NOTLOBBIED, the user will have to manually select a communication medium for your application. (You can identify the service providers installed on the system by using the DirectPlayEnumerate function.) If any other error value is returned, your application should report an error that indicates that lobbying the application failed.

The following example shows how to connect to a session:

// Connect to the session. Returns an ANSI IDirectPlay2A interface.

hr = lpDirectPlayLobbyA->Connect(0, &lpDirectPlay2A, NULL);

if FAILED(hr)

goto FAILURE;