HRESULT WINAPI Connect(DWORD dwFlags,
LPDIRECTPLAY2 FAR *lplpDP, IUnknown FAR *pUnk);
Connects an application to a session by using the connection data supplied by the lobby client in the IDirectPlayLobby::RunApplication method, or by calling the IDirectPlayLobby::SetConnectionSettings method.
·Returns DP_OK if successful, or one of the following error values otherwise:
dwFlags
Reserved; must be zero.
lplpDP
Address of a pointer to be initialized with a valid inteface—either IDirectPlay2 (if called on IDirectPlayLobby) or IDirectPlay2A (if called on IDirectPlayLobbyA).
pUnk
Address of the containing IUnknown interface. This parameter is provided for future compability with COM aggregation features. Presently, however, IDirectPlayLobby::Connect returns an error if this parameter is anything but NULL.
Executing this method successfully creates a DirectPlay object with the correct service provider, and opens the correct session without asking the user to fill in any dialog boxes. If this method fails with the DPERR_NOTLOBBIED error value, then the application should perform the normal steps of calling DirectPlayEnumerate, DirectPlayCreate, IDirectPlay2::EnumSessions and IDirectPlay2::Open. If it fails on any other error value, then there is a problem connecting to the session.
Before calling this method, the application can examine the connection settings that will be used to start the application by using the IDirectPlayLobby::GetConnectionSettings method. The application then can modify these settings and set them by using the IDirectPlayLobby::SetConnectionSettings method. The application should pay particular attention to the DPSESSIONDESC2 structure to ensure that the proper session properties are set, especially dwFlags, dwMaxPlayers, and the dwUser members.