Platform SDK: DirectX

Supporting Ripple Launching

Ripple launching is the running of an application by another application that has itself been launched from a lobby. In the following discussion, the program run by the lobby is called the launcher, and the program it launches is called the application.

[C++]

In order to support ripple launching in your application, you must register it by passing the DPAPPLICATIONDESC2 structure to IDirectPlayLobby3::RegisterApplication. This structure has a member, lpszAppLauncherName, that contains the name of the launcher. The launcher must reside in the same directory as the application.

When a lobby client runs the application by calling IDirectPlayLobby3::RunApplication, DirectPlay finds the name of the launcher in the registry and runs the launcher rather than the application. It is then the responsibility of the launcher to run the application.

The launcher must pass on to the application any command-line parameters it is provided with. The application should silently ignore any command-line parameters it does not understand.

The application should always call IDirectPlayLobby3::GetConnectionSettings at least once before using IDirectPlayLobby3::WaitForConnectionSettings. (See Supporting Dynamic Lobby Connection.)

The following example shows how to register a ripple-launched application, where lpDPLobby3A points to an IDirectPlayLobby3 interface:

DPAPPLICATIONDESC2  dpad2;
 
dpad2.dwSize = sizeof (DPAPPLICATIONDESC2);
dpad2.dwFlags = 0;
dpad2.lpszApplicationNameA= "MyApp";
dpad2.guidApplication = {12345678-...};
dpad2.lpszFilenameA= "myapp.exe";
dpad2.lpszCommandLineA= "/lobbied";
dpad2.lpszPathA= "C:\\games";
dpad2.lpszCurrentDirectoryA= "C:\\games";
dpad2.lpszDescriptionA= "My Application";
dpad2.lpszDescriptionW= L"My Application";
dpad2.lpszAppLauncherNameA= "launcher.exe";
 
HRESULT hr = lpDPLobby3A->RegisterApplication(0, &dpad2);

The following example is a complete console application that launches the Duel sample:

#include <windows.h>
#include "stdio.h"
 
int main(int argc, char* argv[])
{
  PROCESS_INFORMATION ProcInfo;
  STARTUPINFO StartupInfo;
  BOOL bCreated;

  LPTSTR lpCommandLine;

  printf("Launcher application\n");

  lpCommandLine = GetCommandLineA();

  // Strip EXE name from command line, 
  // pass rest to ripple-launched app.

  while(*lpCommandLine && *lpCommandLine!= ' ') lpCommandLine++;
  
  printf("passing command line: %s\n",lpCommandLine);

  memset(&StartupInfo,0,sizeof(StartupInfo));
  StartupInfo.cb = sizeof(StartupInfo);
  
  bCreated=CreateProcessA(
    "duel.exe",
    lpCommandLine,
    NULL,
    NULL,
    TRUE,
    0,
    NULL,
    NULL,
    &StartupInfo,
    &ProcInfo);


  if(bCreated){
    printf("Waiting for application to exit\n");
    WaitForSingleObject(ProcInfo.hThread, INFINITE);
  } else {
    printf("Failed to create process\n");
  }

  printf("launcher application has left the building...\n");

  return 0;
}
[Visual Basic]

In order to support ripple launching in your application, you must register it by passing the DPAPPLICATIONDESC2 type to DirectPlayLobby3.RegisterApplication. This type has a member, strAppLauncherName, that contains the name of the launcher. The launcher must reside in the same directory as the application.

When a lobby client runs the application by calling DirectPlayLobby3.RunApplication, DirectPlay finds the name of the launcher in the registry and runs the launcher rather than the application. It is then the responsibility of the launcher to run the application.

The launcher must pass on to the application any command-line parameters it is provided with. The application should silently ignore any command-line parameters it does not understand.

The application should always call DirectPlayLobby3.GetConnectionSettings at least once before using DirectPlayLobby3.WaitForConnectionSettings. (See Supporting Dynamic Lobby Connection.)

The following example shows how to register a ripple-launched application, where DPLobby3 is a DirectPlayLobby3 object:

Dim dpad2 As DPAPPLICATIONDESC2 

With dpad2
  .lFlags = 0
  .strAppLauncherName= "launcher.exe"
  .strApplicationName= "MyApp"
  .strCommandLine= "/lobbied"
  .strCurrentDirectory= "C:\games"
  .strDescription= "My Application"
  .strFilename= "myapp.exe"
  .strGuid = "{AC330441-9B71-11D2-9AAB-0020781461AC}"
  .strPath= "C:\games"
End With
 
Call DPLobby3.RegisterApplication(dpad2)