Platform SDK: DirectX

IDirectPlayLobby3::ConnectEx

The IDirectPlayLobby3::ConnectEx method connects an application to the session specified by the DPLCONNECTION structure currently stored with the DirectPlayLobby object.

This method is an extended version of the Connect method. This version allows the application to specify which version of the DirectPlay\ COM interface to return.

By default, ConnectEx returns after a connection is made or the connection has timed out. If you use the DPCONNECT_RETURNSTATUS flag, ConnectEx returns immediately with a DPERR_CONNECTING error code indicating the connection is in progress. The application must continue calling this method periodically until DP_OK or a failure code is returned. The application can cancel the connection by releasing the IDirectPlayLobby3 interface.

HRESULT ConnectEx(
  DWORD dwFlags,
  REFIID riid,
  LPVOID *lplpDP,
  IUnknown FAR *pUnk
);

Parameters

dwFlags
Flags indicating how the connection is to be done. By default (dwFlags = 0), the method returns after a connection has been established or the operation has timed out.
DPCONNECT_RETURNSTATUS
Returns immediately with the status of the connection. The application must continue calling ConnectEx until a success or error code is returned.
riid
The IID of the specific DirectPlay COM interface to be returned; for example, IID_IDirectPlay4A.
lplpDP
Pointer to a pointer to be initialized with the DirectPlay interface as specified by the riid parameter.
pUnk
Pointer to the containing IUnknown interface. This parameter is provided for future compatibility with COM aggregation features. Presently, however, IDirectPlayLobby3::ConnectEx returns an error if this parameter is anything but NULL.

Return Values

Returns DP_OK if successful, or one of the following error values otherwise:

DPERR_CONNECTING
DPERR_INVALIDFLAGS
DPERR_INVALIDPARAMS

The method returns DPERR_CONNECTING while the connection operation is in progress. Call the methods again to get an updated status.

Remarks

There is an upper limit of one minute on connection time-out.

After this method is successfully completed, the application can skip the process of calling IDirectPlay4::InitializeConnection, IDirectPlay4::EnumSessions, and IDirectPlay4::Open. The application should not ask the user a name but instead create a player using the player name information in the DPLCONNECTION structure.

Before calling this method, the application can examine the connection settings that will be used to start the application by using the IDirectPlayLobby3::GetConnectionSettings method. The application then can modify these settings and set them by using the IDirectPlayLobby3::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.

Requirements

  Windows NT/2000: Requires Windows 2000.
  Windows 95/98: Requires Windows 95 or later. Available as a redistributable for Windows 95.
  Header: Declared in dplobby.h.
  Import Library: Use dplayx.lib.

See Also

IDirectPlayLobby3::ConnectEx