DirectX SDK |
This tutorial pertains only to applications written in C++. See DirectPlay Visual Basic Tutorials.
If the user wants to create a new session, your application can create it by using the IDirectPlay4::Open method and specifying the DPOPEN_CREATE flag. Again, the service provider might display a dialog box requesting information from the user before it can create the session.
The following example shows how to create a new session:
ZeroMemory( &dpsd, sizeof(dpsd) ); dpsd.dwSize = sizeof(dpsd); dpsd.guidApplication = g_AppGUID; dpsd.lpszSessionNameA = g_strSessionName; dpsd.dwMaxPlayers = 10; // The DPSESSION_KEEPALIVE flag keeps the session alive // if players abnormally exit. dpsd.dwFlags = DPSESSION_KEEPALIVE | DPSESSION_MIGRATEHOST; if ( g_bUseProtocol ) dpsd.dwFlags |= DPSESSION_DIRECTPLAYPROTOCOL; // Create a new session. g_bHostPlayer = TRUE; if ( FAILED( hr = g_pDP->Open( &dpsd, DPOPEN_CREATE ) ) ) return hr;