Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / web / HTML

Free Autoplay Menu for your CD/DVD Distribution

2.78/5 (16 votes)
18 Mar 2008CPOL3 min read 1   752  
How to create an autoplay menu that runs automatically when the user inserts the CD/DVD
Image 1

Introduction

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

  1. Install (run setup.exe)
  2. Browse (explore the CD)
  3. Read Me (open the readme file)
  4. Visit our web page (open the company web page)
  5. Exit (closes the autoplay menu)

Background

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.

I hear somebody saying HTML… yeah… HTML (with animated GIF and JavaScripts……).

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++

  1. Copy the sample into your solution folder and add it to your solution as an existing project.
  2. Open the file Autoplay.cpp and modify the following lines of code according to your needs

    C++
    //TODO: set those properties according to you needs
    
    m_bShowTitleBar = false;//no title bar
    
    m_bShowMenuBar = false;//no menu bar
    
    m_bLoadFromResources = false;//load from a file in the Data folder
    
     
    
    m_iWidth = 600;//the size
    
    m_iHeight = 450;
    
     
    
    m_strReadMeFileName = "ReadMe.htm";//the readme file
    
    m_strWebPage = "www.OurWebPage.com";//the company web page
  3. 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
  4. Build the solution
  5. 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

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.

For example:

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.

History

March 2008 first release

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)