/// <summary>
        /// Installiert einen Dienst.
        /// </summary>
        /// <param name="configuration">Die Konfiguration des Dienstes.</param>
        /// <param name="fileName">Der volle Pfad zur Konfigurationsdatei.</param>
        /// <param name="install">Gesetzt, wenn eine Installation ausgeführt werden soll.</param>
        private static void Install( RecordingServiceConfiguration configuration, string fileName, bool install )
        {
            // Create the service installer
            var service =
                new ServiceInstaller
                {
                    Description = "Generic Recorder / Tuner Service based on JMS Argus TV SDK",
                    DisplayName = configuration.Name + " (Argus TV Recorder)",
                    ServiceName = CreateServiceName( configuration ),
                    StartType = ServiceStartMode.Manual,
                    Context = new InstallContext(),
                };

            // Create the process installer
            var process =
                new ServiceProcessInstaller
                {
                    Account = ServiceAccount.LocalService,
                    Context = service.Context,
                };

            // Link together
            process.Installers.Add( service );

            // Create service path
            var exePath = "\"" + new Uri( Assembly.GetExecutingAssembly().CodeBase ).LocalPath.Replace( "\"", "\"" ) + "\"";
            var configPath = "\"" + fileName + "\"";

            // Configure service path
            process.Context.Parameters["assemblypath"] = exePath + " " + configPath;

            // Create state
            var pathToState = fileName + ".install";
            var serializer = new BinaryFormatter();

            // Try it
            if (install)
            {
                // Create the state
                var state = new Hashtable();

                // Do the installation
                process.Install( state );

                // Save the state
                using (var stateFile = new FileStream( pathToState, FileMode.Create, FileAccess.Write, FileShare.None ))
                    serializer.Serialize( stateFile, state );
            }
            else
            {
                // Load the state
                using (var stateFile = new FileStream( pathToState, FileMode.Open, FileAccess.Read, FileShare.Read ))
                {
                    // Reconstruct the state
                    var state = (Hashtable) serializer.Deserialize( stateFile );

                    // Do the installation
                    process.Uninstall( state );
                }

                // Done
                File.Delete( pathToState );
            }
        }
            /// <summary>
            /// Erstellt einen neuen Windows Dienst.
            /// </summary>
            /// <param name="configuration">Die zu verwendende Configuration.</param>
            public static void Run( RecordingServiceConfiguration configuration )
            {
                // Create the new service
                using (var service = new Service( configuration ))
                    if (DebugMode)
                    {
                        // Start host
                        service.CreateRecordingService();

                        // Wait
                        Console.WriteLine( "Running, press ENTER to End" );
                        Console.ReadLine();

                        // Done with host
                        service.RemoveRecordingService();
                    }
                    else
                    {
                        // Full processing
                        Run( service );
                    }
            }
 /// <summary>
 /// Erstellt den eindeutigen Namen des Dienstes.
 /// </summary>
 /// <param name="configuration">Die verwendete Konfiguration.</param>
 /// <returns>Der gewünschte Name.</returns>
 private static string CreateServiceName( RecordingServiceConfiguration configuration )
 {
     // Construct
     return "ArgusTVRecorder" + configuration.Name;
 }
            /// <summary>
            /// Erstellt einen neuen Windows Dienst.
            /// </summary>
            /// <param name="configuration">Die zu verwendende Configuration.</param>
            private Service( RecordingServiceConfiguration configuration )
            {
                // Remember
                m_configuration = configuration;

                // Forward
                ServiceName = CreateServiceName( configuration );
                AutoLog = false;
                CanStop = true;
            }