Click here to Skip to main content
11,490,973 members (65,873 online)
Click here to Skip to main content
Add your own
alternative version

Implement an Autoplay Handler

, 18 Sep 2006 CPOL 73.5K 1.4K 77
Implementing an Autoplay handler in C#.
autoplaydemo_demo.zip
Almdal.RegistryScript.dll
Almdal.SharedPipes.dll
AutoPlayDemo.exe
AutoPlayListener.dll
autoplaydemo_src.zip
AutoPlayDemo
Autoplay.ico
AutoPlayDemo.csproj.user
bin
Properties
Settings.settings
Resources
AutoPlayListener
Autoplay.ico
AutoPlayListener.snk
bin
Properties
Resources
Autoplay.ico
RegistryScript
Almdal.RegistryScript.snk
bin
Properties
SharedPipies
Almdal.SharedPipes.snk
bin
Properties
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Windows.Forms;

using Almdal.AutoPlayDemo.Properties;
using Almdal.RegistryScript;

using System.Reflection;

namespace Almdal.AutoPlayDemo {

    /*****************************************************************************************
     *  Copyright (c) 2006 T. ALmdal
     *
     *  Permission is hereby granted, free of charge, to any person obtaining 
     *  a copy of this software and associated documentation files (the "Software"),
     *  to deal in the Software without restriction, including without limitation 
     *  the rights to use, copy, modify, merge, publish, distribute, sublicense, 
     *  and/or sell copies of the Software, and to permit persons to whom the 
     *  Software is furnished to do so, subject to the following conditions:
     *
     *  The above copyright notice and this permission notice shall be included 
     *  in all copies or substantial portions of the Software.
     *  
     *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 
     *  OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
     *  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
     *  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
     *  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
     *  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
     * 
    /*******************************************************************************************/
    static class Program {
		/// <summary>
		/// The main entry point for the application.
		/// If the parameter is /r it will register the location of the executable
        /// as HKLM\Software\%Company%\%AppID%\%Location% = %LOCATION%
        /// 
        /// A parameter of /u will unregister it.
		/// </summary>
		[STAThread]
		static void Main(string [] cmds) {
            if (cmds.Length == 1) {
				CRegistryScript script = new CRegistryScript();
				string regScript = Almdal.AutoPlayDemo.Properties.Resources.RegisterScript;
				script.AddVariable("Company", Application.CompanyName);
				script.AddVariable("AppID", Application.ProductName);
				script.AddVariable("LOCATION", Application.ExecutablePath);
				script.AddVariable("Location", "{0F08197F-AF66-4198-9673-C5B5A33AACED}");

                if ("/r".Equals(cmds[0])) {
                    script.Register(regScript);
                    System.Console.WriteLine("Registration of Autoplay Demo Application completed successfully");
					return;
                }
                else {
                    script.Unregister(regScript);
                    System.Console.WriteLine("Unregistration of Autoplay Demo Application completed successfully");
                    return;
                }
            }

            Application.EnableVisualStyles();
			Application.SetCompatibleTextRenderingDefault(false);
			Application.Run(new Form1());
		}
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

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

Share

About the Author

Tim Almdal

Canada Canada
No Biography provided

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.150520.1 | Last Updated 18 Sep 2006
Article Copyright 2006 by Tim Almdal
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid