Step 5: Creating a Player

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

The following example shows how to create a player:

// create a player with the name returned in the connection settings

hr = lpDirectPlay2A->CreatePlayer(&dpidPlayer,

lpConnectionSettings->lpPlayerName,

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

if FAILED(hr)

goto FAILURE;

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