DirectX SDK |
The IDirectPlay4::Open method is used to join a session that has been enumerated by a previous call to IDirectPlay4::EnumSessions or to create a new session that other users can enumerate and join.
HRESULT Open( LPDPSESSIONDESC2 lpsd, DWORD dwFlags );
If a session is being created, then the application must completely fill out the DPSESSIONDESC2 structure with the properties of the sessions to be created. The guidInstance will be generated by DirectPlay.
Returns DP_OK if successful, or one of the following error values otherwise:
This method returns DPERR_ALREADYINITIALIZED if there is already an open session on this DirectPlay object.
It return DPERR_CANTCREATEPLAYER if the maximum number of players in the session description has already been reached.
It returns DPERR_TIMEOUT if the session did not respond to the Open request.
It returns DPERR_USERCANCEL if the user canceled the enumeration process(usually by canceling a service provider dialog box).
It returns DPERR_NOSESSIONS if it is called to join an existing session but the session isn't in the internal session list (or the session guidInstance is corrupted).
Once an application has joined a session, it can create a player and start communicating with other players in the session. The application will not receive any messages nor can it send any messages on this DirectPlay object until it creates a local player using IDirectPlay4::CreatePlayer.
In order to have two sessions open simultaneously, the application must create two DirectPlay objects and open a session on each one.
To join a session, it is only necessary to fill in the dwSize and guidInstance members of the DPSESSIONDESC2 structure. The lpszPassword member must also be filled in if the session was marked as password protected. An enumerated session will have the DPSESSION_PASSWORDREQUIRED flag set if it requires a password.
If joining a secure session, you must use SecureOpen to provide logon credentials. The enumerated session will have the DPSESSION_SECURESERVER flag set if it requires credentials.
If you specify the DPSESSION_SECURESERVER flag in the DPSESSIONDESC2 structure, the session will be opened with the default security package, NTLM (NT LAN Manager). To specify an alternate security package, use SecureOpen.
When an application attempts to join a session, the server can reject the Open request or ignore it (in which case Open will time-out). Attempting to join a session where new players are disabled, joining is disabled, the player limit has been reached, or an incorrect password is supplied will result in a DPERR_NONEWPLAYERS or DPERR_INVALIDPASSWORD error.
Windows NT/2000: Requires Windows 2000.
Windows 95/98: Requires Windows 95 or later. Available as a redistributable for Windows 95.
Header: Declared in dplay.h.
Import Library: Use dplayx.lib.
DPSESSIONDESC2, IDirectPlay4::Close, IDirectPlay4::SecureOpen, IDirectPlay4::EnumSessions