Platform SDK: DirectX

ステップ 1 : アプリケーションの登録

ロビー クライアントからアプリケーションを認識できるようにするには、アプリケーションを登録する必要がある。ロビー対応アプリケーションを登録するには、DirectSetupの DirectXRegisterApplication C/C++ 関数を使用するか、DirectPlayLobby3.RegisterApplication メソッドを使用する独自の登録ユーティリティを提供する。以下のサンプル プロシージャは、DXVBChat.exe を登録する。このとき、DXVBChat.exe は登録を行うアプリケーションと同じフォルダになければならない。

Dim dx As New DirectX7
Dim dpl As DirectPlayLobby3
Const AppGuid = "{EB5E7E20-0303-11d3-9AAB-00104BCC1EAA}"
 
Private Sub RegisterApp()
 
  Dim dpappdesc As DPAPPLICATIONDESC2
  Dim dpl as DirectPlayLobby3
 
  With dpappdesc
    .strApplicationName = "DXVBChat"
    .strCommandLine = ""
    .strCurrentDirectory = App.Path
    .strDescription = "Chat (DirectX for Visual Basic)"
    .strFilename = "DXVBChat.exe"
    .strGuid = AppGuid
    .strPath = App.Path
  End With
 
  On Local Error GoTo ERRORS
 
  Set dpl = dx.DirectPlayLobbyCreate
  Call dpl.RegisterApplication(dpappdesc)
  Exit Sub
 
ERRORS:
  MsgBox "Failed to register application."
  Unload Me
 
End Sub

以下のプロシージャは、同じアプリケーションの登録を解除する。

Private Sub UnregisterApp()

  On Local Error GoTo FAILED
  Call dpl.UnregisterApplication(AppGuid)
  MsgBox "Unregistration successful."
  Exit Sub
 
FAILED:
  If Err.Number = DPERR_UNKNOWNAPPLICATION Then
    MsgBox "Application not registered."
  End If
  Unload Me
 
End Sub

次項 : ステップ 2 : 接続設定の取得