Return to Autorun.inf Maker

Q: Is the source code for Browser Call available?

A: In a word, 'No.' But, only because I believe you would not wish to waste your time creating a generic product like Browser Call for your own use as a CD autoplay application.

It would be better to create a specific application for each autorun situation. This would allow you to create an application that launches the non-executable files you wish to start either from the autorun.inf file or when the user clicks on it from a file listing. Browser Call does not have the latter capability.

To give you a strong pointer in the correct direction, if the only function you would need your application to provide is similar to that found in Browser Call, you would only need to do the following:

Note: This assumes you are using a C/C++ compiler. But, creating this type of application in another language would use calls to the same api function. It is up to you to modify these examples from C/C++ to your language of choice.

1 Create an application free of the forms and other automatic features of your compiler suite. How to go about this varies according to your compiler suite. In general, the easiest way to get a reduced application project for this type of coding is to create a console application. Otherwise, you will need to remove everything (forms, .h, .c, .cpp, etc.) from your application's project except the projectname.cpp file.

2 In the projectname.cpp file delete all functions (including WinMain() or main() ). Delete all includes that have nothing to do with windows (if using a console application base) or that are not required for your compiler to function properly. Leaving or inserting windows.h is highly recommended. What you will need for your compiler to function properly varies by compiler. Please check your compiler's documentation.

3 In the now clean projectname.cpp file, recreate WinMain() as follows:
int PASCAL WinMain(HANDLE,HANDLE,LPSTR,int)
{
return 0;
}

4 Within WinMain(), and before the return value, make use of ShellExecute.

(Note: First, you will need to #include <shellapi.h>) before any of these examples will compile.

If you want to open an application without parameters, use:
ShellExecute(NULL,"open",appName,NULL,NULL,SW_SHOWNORMAL);
Replace the appName variable with the actual name of your application or an associated file.
Example values for appName:
index.html
myapplication.exe
mymusic.mp3
mymovie.avi

If you want to open an application with parameters, use:
ShellExecute(NULL,"open",appName,params,NULL,SW_SHOWNORMAL);
Replace the appName variable with the actual name of your application or associated file.
Replace the params variable with the actual parameters being sent to the appName file.
Example appName,params pairs:
netscape,index.html
iexplore,index.html
winamp,mymusic.mp3
mplayer32,mymovie.avi

If you want to open a directory for exploration, use:
ShellExecute(NULL,"explore",folderPath,NULL,NULL,SW_SHOWNORMAL);
Replace the folderPath variable with the actual path to the folder to explore.

5 Before compiling, make sure that your project is set to use static linking. Now, add an icon of your choice and compile.

6 Full examples:
Launches index.html in Internet Explorer:
int PASCAL WinMain(HANDLE,HANDLE,LPSTR,int)
{
ShellExecute(NULL,"open","iexplore","index.html",NULL,SW_SHOWNORMAL);
return 0;
}

Launches index.html in the user's default HTML viewer:
int PASCAL WinMain(HANDLE,HANDLE,LPSTR,int)
{
ShellExecute(NULL,"open","index.html",NULL,NULL,SW_SHOWNORMAL);
return 0;
}

7 To make the application more robust, you may wish to add error checking to the ShellExecute call. Visit ShellExecute (MSDN Library) for the official Microsoft technical information on this command.

8 Since the CD drive letter may vary on users' systems, you may wish to use GetCurrentDirectory to create full paths to files on your cd for the appName, params, and folderPath variables. Visit GetCurrentDirectory (MSDN Library) for the official Microsoft technical information on this command.

In Conclusion:
I hope you have found this FAQ/Tutorial helpful and that it has given you a good headstart on the process for creating an application to launch your non-executable files from autoplay.

Best of luck with your CD projects;
Carel

AshzFall | Autorun.inf Maker