Microsoft DirectX 8.1 (C++) |
Lobby clients are either launched by a lobby server or directly by a user. Once a lobby client is launched, it must be initialized before it can launch an application. Initialization involves the following tasks.
The first two steps create the lobby client object, and set up a communication link between that object and your lobby client. The final step determines what lobbyable applications are available on the user's system. You need this information in order to launch the selected application.
The following code sample illustrates how to enumerate local applications. It is a simplified version of the EnumRegisteredApplications function in the SDK's LobbyClient sample. Error handling and dialog-box-related code has been deleted for clarity. See the LobbyClient sample in the SDK for the complete code.
HRESULT EnumRegisteredApplications() { HRESULT hr; DWORD dwSize = 0; DWORD dwPrograms = 0; DWORD iProgram; BYTE* pData = NULL; //g_pLobbyClient is a pointer to an IDirectPlay8LobbyClient interface //Start with a NULL data buffer. The required buffer size is //returned through dwSize. hr = g_pLobbyClient->EnumLocalPrograms( NULL, pData, &dwSize, &dwPrograms, 0 ); if( dwSize == 0 ) { //No registered applications. } //Set the data buffer to the appropriate size pData = new BYTE[dwSize]; hr = g_pLobbyClient->EnumLocalPrograms( NULL, pData, &dwSize, &dwPrograms, 0 ) //Cast the returned data to the appropriate structure type DPL_APPLICATION_INFO* pAppInfo = (DPL_APPLICATION_INFO*) pData; //Enumerate the names of the registered applications for( iProgram=0; iProgram<dwPrograms; iProgram++ ) { TCHAR strAppName[MAX_PATH]; DXUtil_ConvertWideStringToGeneric( strAppName, pAppInfo->pwszApplicationName ); } SAFE_DELETE_ARRAY( pData ); return S_OK; }
You should store the application GUIDs of the registered applications because you need them to launch the application.
Depending on the design of your lobby client, you may also want to do one or more of the following tasks.