VB:DX7 DirectPlay Connecting directly to an IP (no dialog)
From GPWiki
The wiki is now hosted by GameDev.NET at wiki.gamedev.net. All gpwiki.org content has been moved to the new server. However, the GPWiki forums are still active! Come say hello. When you start using DirectPlay7, you will probably start to wonder how to stop DirectPlay7 from showing the connection box asking for the destination IP to search for sessions. There is an easy way to stop this box from showing, but it has been quite undocumented in the past, and it still is. A while back someone started a topic on this issue at the GPWiki forum. It took some searching in the old forums to find the solution to the problem (talk about undocumented!). It comes down that you have to make a lobby object, and initialize the connection with this: Standard DirectX code (originating from the earlier mentioned topic): Public DirectX As New DirectX7
Public DPlay As DirectPlay4
Public SessionData As DirectPlaySessionData
Public EnumSessions As DirectPlayEnumSessions
Public Const GUID As String = "{ Session Guid}"
Public SessionID As Integer
Public PlayerID As Long
Initializing the connection, preventing the IP dialog box from appearing: Dim DPEC As DirectPlayEnumConnections Dim DPA As DirectPlayAddress Dim LBY As DirectPlayLobby3 Set DPlay = DirectX.DirectPlayCreate("")
Set DPEC = DPlay.GetDPEnumConnections(GUID, &H1)
Set DPA = DPEC.GetAddress(4)
Set LBY = DirectX.DirectPlayLobbyCreate
'//Initialize the connection here using the IP and port that you get from a
configuration file, or your own user input dialog:
Set DPA = LBY.CreateINetAddress("IP address", "Port")
Call DPlay.InitializeConnection(DPA)
That should do it. Now you can continue with the normal stuff: Set SessionData = DPlay.CreateSessionData SessionData.SetGuidApplication GUID SessionData.SetSessionPassword "" Note: The above code assumes everything works. No error handling at all. Please check if objects are non-nothing before proceeding at certain points. |


