Step 5: Creating a Player

After a session has been created or joined, your application can create one or more players by using the IDirectPlay2::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 = lpDirectPlay2A->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 IDirectPlay2::GetCaps and IDirectPlay2::GetPlayerCaps methods. Your application can find other players by using the IDirectPlay2::EnumPlayers method.

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