Step 5: Creating a Player

After a session has been created or joined, your application can create one or more players by using the IDirectPlay3::CreatePlayer method. The following example shows one way to create a player:

// Fill out the name structure.

ZeroMemory(&dpName, sizeof(DPNAME));

dpName.dwSize = sizeof(DPNAME);

dpName.lpszShortNameA = lpszPlayerName;

dpName.lpszLongNameA = NULL;

// Create a player with this name.

hr = lpDirectPlay3A->CreatePlayer(&dpidPlayer, &dpName,

lpDPInfo->hPlayerEvent, NULL, 0, 0);

if FAILED(hr)

goto CREATEPLAYER_FAILURE;

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

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