这样的文章相当少,提供给你一个连接:
http://rookscape.com/vbgaming/tutX.php
你可以到 www.google.com 上以DirectPlay +VB做关键字查找。

解决方案 »

  1.   

    给你一个 Dx7 通信的例子:
    =================================================================
    '发消息部分
    const MyGame_ChatMessage = 0
    const MyGame_DataPacket = 1
    const MyGame_SomeOtherType = 2
    const MyGame_YetAnotherMessageType = 3
    'This object holds everything that we need to send.
    Dim Msg As DirectPlayMessage'Use DirectPlay to initialise our message object.
    Set Msg = Dp.CreateMessage
    Msg.WriteLong MyGame_ChatMessage 'The message will hold an identifier
    Msg.WriteString "Hello. I am a chat string." 'Stick the string data here
    'There are several different data types you can write into the message; and you can use more than one:
    'WriteSingle = Any valid single data type (ie. Decimal number)
    'WriteDouble = Any valid Double data type (Same as a single, but bigger)
    'WriteShort = Any valid Integer data type
    'WriteLong = Any valid Long data type (Same as integer, but bigger)
    'WriteGUID = Writes a string to the message - Almost identical to the WriteString method
    'WriteString = Write any string to the message, this can be used to send data packets
    'WriteByte = Writes a byte to the message'Now that we've compiled our message into a single structure; we can send it to a single player,
    ' or lots of players.dp.SendEx PlayerID, DPID_ALLPLAYERS, DPSEND_GUARANTEED, Msg, 0, 0, 0 .=================================================================
    '接收消息部分:
    Dim FromThisPlayer as long, ToThisPlayer as long, NumMessagesWaiting as long, MsgType as Long
    Dim Msg as DirectPlayMessageNumMessagesWaiting = Dp.GetMessageCount(PlayerID) 'check the messages for our Player ONLYDo While NumMessagesWaiting >0
    Set Msg = Dp.Recieve(FromThisPlayer, ToThisPlayer, DPRECIEVE_ALL)
    'The variables FromThisPlayer and ToThisPlayer have the ID numbers of their respective players.
    'DPRECIEVE_ALL basically means that we look at all the messages. We can now unpack the dataMsgType = Msg.ReadLong()
    'Now we process the message - we'll do this in another procedure...
    ProcessMessage MsgType, FromThisPlayer'Now we decrement the number of messages waiting - to clear the message we just read.
    NumMessagesWaiting = NumMessagesWaiting -1
    Loop 
    Sub ProcessMessage(Type as Long, From as Long)
    If From = DPID_SYSMSG then
    'We have a message from the DirectPlay system. There are a lot of System Messages; the most important ones
    'Being: 
    'DPSYS _CREATEPLAYERORGROUP - A new player or group have joined
    'DPSYS _DESTROYPLAYERORGROUP - An existing player has left
    'DPSYS_HOST - The current host has left the game; the application that recieves this is now the new host.
    'DPSYS _SESSIONLOST - The connection with the session has been lost. 
    Else
    'We Have a message of custom-Type. The best method is to use a Select Case:
    Select Case Type
    Case MyGame_ChatMessage
    'Execute code that unpacks and displays a chat message
    Case MyGame_DataPacket
    'Do Code that unpacks a data packet, and acts on it.
    End Select 'Just keep on adding Case's for the constants defined earlier.
    End If
    End Sub
      

  2.   

    强烈建议你下载微软的Direct X8.0 SDK