Creating the Setup Program

The DirectX Programmer's Reference includes an example setup program that you can use as a model for your application's setup program. The setup program is called Dinstall, and it is located in the \Dxsdk\Sdk\Samples\Setup directory. It installs a sample DirectX application called Rockem. It also demonstrates one way to configure the DirectXSetup function.

    To adapt the Dinstall.c program to your needs
  1. In an editor, open Dinstall.c.
  2. Search for the text "copy_list".
  3. Edit the list of files in this structure to contain the names of the files you want copied to the user's computer during installation.
  4. If necessary, modify Dinstall.c so that it installs files in subdirectories on the user's hard disk. Currently, Dinstall.c installs files only in the default directory.
  5. Search for two locations in Dinstall.c that contain the text "IDS_DISK_MSG".
  6. Add some code that checks whether there is enough free hard disk space to install your application on the user's computer. Dinstall.c does not currently check this.

The lpszRootPath parameter of DirectXSetup specifies the path to the Dsetup*.dll files (Dsetup.dll, Dsetup16.dll, and Dsetup32.dll) and the Directx directory on your distribution media. These dynamic-link libraries and this directory should be located in the same directory as the Dinstall executable after it is compiled, unless there is an overwhelming reason to do otherwise. If all these files and directories are located in the same directory, the value of the lpszRootPath parameter should be set to NULL. This ensures that if the path changes when the files are placed on a compact disc or floppy disks from the root of the application, the DirectXSetup function still works properly.

For example, suppose Dinstall.exe, Dsetup*.dll, and the Directx directory are located in an application directory called D:\Funstuff during the testing phase. Then, when you burn the files on a compact disc, suppose you put them in the root. If the lpszRootPath parameter is set to "\FUNSTUFF", the setup program (Dinstall.exe) will not function from the compact disc. However, if the lpszRootPath parameter is set to NULL, the setup program will function in both cases, because the path to Dsetup*.dll, and the Directx directory are still in the current directory.

If you decide to place the Dsetup*.dll files and the Directx directory somewhere other than in the directory that contains Dinstall.exe, you must pass the appropriate parameters to DirectXSetup and load Dsetup.dll correctly. The lpszRootPath parameter of DirectXSetup should contain the full path to Dsetup.dll. In addition, you need to use the LoadLibrary and GetProcAddress Win32 functions in your setup program to locate Dsetup.dll.

The content of the Setup dialog box is determined by data supplied in the Dinstall.rc resource file.

    To display your application's name and graphics
  1. In an editor, open Dinstall.rc.
  2. Search for all occurrences of "Rockem" and change them to the name of your application.
  3. The graphics that are displayed in the Setup and Reboot dialog boxes are called Signon.bmp and Reboot.bmp in the resource file. Either rename your bitmap files these names, or change the names in the resource file to match the names of your bitmaps.
  4. The icon for the Dinstall executable is called Setup.ico in the resource file, and it is specified by SETUP_ICON. Either set the name of your icon file to Setup.ico, or change the name in the resource file to match the name of your icon file.
  5. If appropriate for your application, change the default directory in which your application is installed. To do this, search for "IDS_DEFAULT_GAME_DIR" (it is located in two places in the resource file) and change the path of the default directory.

After you have modified the Dinstall.c and Dinstall.rc files to fit your application's needs, compile them into the Dinstall.exe executable file. You can rename this executable file to anything you want (Setup.exe, for example).