Platform SDK: DirectX

Step 5: Create a New Player

[Visual Basic]

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

[C++]

After a session has been created or joined, your application can create one or more players by using the IDirectPlay4::CreatePlayer method. The following code shows how this is done in the SimpleConnect Sample.

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;

Your application can determine a player's communication capabilities by using the IDirectPlay4::GetCaps and IDirectPlay4::GetPlayerCaps methods. Your application can find other players by using the IDirectPlay4::EnumPlayers method.

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