Well, you can find tons of pages with instructions on how to do this. The following works but IMO lacks some key features. For instance, it will always re-use an existing browser window. Couldn't find a way to get it to launch a new one.

Step 1: Create the autorun.inf file

...and make its contents like below. The icon entry is optional. Note that it has a command line argument, someHtmlPage.html. It will launch any file using its default application.
[autorun]
open=launcher.exe someHtmlPage.html
icon=someExeOrIconFile

Step 2: Compile this program

...and make it so that it's name is launcher.exe
#include <windows.h>
#include <shellapi.h>

int WINAPI WinMain( HINSTANCE hInstance, 
      HINSTANCE hPrevInstance, 
      LPSTR lpCmdLine, int nCmdShow )
{
   HINSTANCE result;

   // Use the desktop for the default window
   HWND hWndDesk = GetDesktopWindow();
  
   //  Launch the file specified on the command-line 
   result = ShellExecute(hWndDesk, "open", lpCmdLine, NULL, NULL, SW_SHOW);

   //  Did we have a problem?  If so, show an error, then just launch the
   //    Directory where we came from with windows explorer
   if ((int)result <= 32)
   {   MessageBox(hWndDesk, 
         "Couldn't Launch the Web Page", 
         "Launch Error", 
         MB_ICONEXCLAMATION);

      ShellExecute(hWndDesk, "explore", "", NULL, NULL, SW_SHOWNORMAL);
      return 1;
   }
   else
   {   return 0; // success !
   }
}

-- MattWalsh - 01 Sep 2002

Topic revision: r1 - 02 Sep 2002 - MattWalsh
 
This site is powered by the TWiki collaboration platformCopyright © 2008-2012 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback