Platform SDK: DirectX

Step 5: Create a Player

[Visual Basic]

This tutorial pertains only to applications written in C++. See DirectPlay Visual Basic Tutorials.

[C++]

If the application was successfully started by using the IDirectPlayLobby3::ConnectEx method, it can now create one or more players. It can use the IDirectPlay4::CreatePlayer method to create a player with the name specified in the DPNAME structure (which was filled in by the IDirectPlayLobby3::GetConnectionSettings method).

The following example shows how to create a player:

DPNAME dpname;
ZeroMemory( &dpname, sizeof(DPNAME) );
dpname.dwSize  = sizeof(DPNAME);
dpname.lpszShortNameA = g_strLocalPlayerName;
 
if ( FAILED( hr = g_pDP->CreatePlayer( &g_LocalPlayerDPID, &dpname, 
        NULL, NULL, 0, 0 ) ) )
    return hr;

Now your application is connected and you are ready to play.