After you finish building your application, you need to distribute it (on a CD …not floppy disks!!!) then you will need an autoplay menu that runs automatically when the CD is inserted.
The autoplay menu should have the following commands
- Install (run setup.exe)
- Browse (explore the CD)
- Read Me (open the readme file)
- Visit our web page (open the company web page)
- Exit (closes the autoplay menu)
You could use a third party software which may cost you $400. But why not build your own?
The good news is that this article will show you how to build it easily, just like building an HTML page!!!
C++ or C#/VB.NET or HTML
We cannot use .NET because it may not be installed on the target machine ... then you'll lose before you start!!!
I hear somebody saying C++…… OK that is right, because it runs using only shared DLLs which can be included on the CD.
But how do you customize the autoplay application if you do not know (or like) C++?
Even if you like C++, we still need an easy way to customize the autoplay menu.
To summarize, the sample project included in this article is a template that utilizes C++ for the running code and HTML for the interface.
Using the Code
If You do not like C++
- Copy the sample into your solution folder and add it to your solution as an existing project.
- Open the file Autoplay.cpp and modify the following lines of code according to your needs
m_bShowTitleBar = false;
m_bShowMenuBar = false;
m_bLoadFromResources = false;
m_iWidth = 600;
m_iHeight = 450;
m_strReadMeFileName = "ReadMe.htm";
m_strWebPage = "www.OurWebPage.com";
- Build the HTML page in the data folder the way you like, taking into consideration that:
- A hyper link with the link to app:install will run setup.exe
- A hyper link with the link to app:browse will explore the CD
- A hyper link with the link to app:readme will open the readme file
- A hyper link with the link to app:webpage will open the company web page
- A hyper link with the link to app:exit will close the autoplay menu
- Build the solution
- When distributing, you distribute the autoplay.exe file and the data folder containing the HTML work and the autoplay.ini and the autoplay icon and do not forget the shared MFC DLLs </strong />
If You Like C++
You will know how to use it — you will not need my explanation. But I want to point your attention to the fact that you can put (embed) the HTML files into the resources so that they become one part with the executable ... this is the way I like it.
Open Autoplay.rc in the text editor and add the resources for the files you used in the HTML page.
BK.GIF HTML "res\\bk.gif"
And do not forget to add those files in the res folder.
How it Works
It is an SDI with CHtmlView ... with some other easy modifications.
I would like to thank Paul Delaci from MSDN Magazine.
Points of Interest
In the source code you will find small tips like how to remove the title bar and the menu bar for MFC frame windows.
Also, you will find how to prevent IE shortcut keys like F5 and Ctrl+O.
March 2008 first release