IDirectPlay::EnumSessions

HRESULT EnumSessions(LPDPSESSIONDESC lpSDesc,

DWORD dwTimeout,

LPDPENUMSESSIONSCALLBACK lpEnumSessionsCallback,

LPVOID lpContext, DWORD dwFlags);

Enumerates the game sessions connected to this DirectPlay object.

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

DPERR_INVALIDOBJECT DPERR_INVALIDPARAMS

DPERR_NOSESSIONS

lpSDesc

Address for a DPSESSIONDESC structure describing the sessions to be enumerated. If a list of all connected sessions, regardless of GUID, is desired, then the guidSession member in the DPSESSIONDESC structure should be set to NULL. If the DPENUMSESSIONS_AVAILABLE flag is going to be used with a password, then the szPassword member should be set accordingly.

dwTimeout

Total amount of time, in milliseconds, that DirectPlay will allow for the enumeration to complete (not the time between each enumeration).

lpEnumSessionsCallback

Address for the EnumSessionsCallback function to be called for each DirectPlay session responding.

lpContext

Address for a user-defined context that is passed to each enumeration callback.

dwFlags

Specifies the optional control flags.

DPENUMSESSIONS_AVAILABLE

Enumerates all sessions with a matching password (if provided), opens player slots, and sets the IDirectPlay::EnableNewPlayers method to TRUE.

DPENUMSESSIONS_PREVIOUS

Enumerates sessions previously stored in the registry.

This method is usually called immediately after the DirectPlay object is instantiated; it cannot be called while a game is connected to a session or after a game has created a session. IDirectPlay::EnumSessions broadcasts an enumeration request and collects replies from the DirectPlay objects that respond. The amount of time DirectPlay spends listening for these replies is controlled by the dwTimeout parameter. When this time interval has expired, your callback will be notified using the DPESC_TIMEDOUT flag, and a NULL value will be passed for the lpDPSGameDesc parameter. At this point, you may choose to continue the enumeration by setting dwTimeOut to a new value and returning TRUE, or returning FALSE to cancel the enumeration.