Exemplo n.º 1
0
        private void ApplyAppIds(DCOMAuthenticationLevel authenticationLevel)
        {
            AddAppID("ScopeSim.Telescope", "ScopeSim.exe", "{4597A685-11FD-47ae-A5D2-A8DC54C90CDC}", authenticationLevel);
            AddAppID("FocusSim.Focuser", "FocusSim.exe", "{289BFF60-3B9E-417c-8DA1-F96773679342}", authenticationLevel);
            AddAppID("DomeSim.Dome", "DomeSim.exe", "{C47DAA29-5788-464e-BBA7-9711FBC7A01F}", authenticationLevel);
            AddAppID("POTH.Telescope", "POTH.exe", "{0A21726F-E58B-4461-85A9-9AA739E6E42F}", authenticationLevel);
            AddAppID("POTH.Dome", "", "{0A21726F-E58B-4461-85A9-9AA739E6E42F}", authenticationLevel);
            AddAppID("POTH.Focuser", "", "{0A21726F-E58B-4461-85A9-9AA739E6E42F}", authenticationLevel);
            AddAppID("Pipe.Telescope", "Pipe.exe", "{080B23A0-3190-45e5-A7C8-53C61F22DFF2}", authenticationLevel);
            AddAppID("Pipe.Focuser", "", "{080B23A0-3190-45e5-A7C8-53C61F22DFF2}", authenticationLevel);
            AddAppID("Pipe.Dome", "", "{080B23A0-3190-45e5-A7C8-53C61F22DFF2}", authenticationLevel);
            AddAppID("Hub.Telescope", "Hub.exe", "{3213D452-2A8F-4624-9D65-E04E175E4CB2}", authenticationLevel);
            AddAppID("Hub.Focuser", "", "{3213D452-2A8F-4624-9D65-E04E175E4CB2}", authenticationLevel);
            AddAppID("Hub.Dome", "", "{3213D452-2A8F-4624-9D65-E04E175E4CB2}", authenticationLevel);
            AddAppID("ASCOMDome.Telescope", "ASCOMDome.exe", "{B5863239-0A6E-48d4-A9EA-0DDA4D942390}", authenticationLevel);
            AddAppID("ASCOMDome.Dome", "", "{B5863239-0A6E-48d4-A9EA-0DDA4D942390}", authenticationLevel);

            AddAppID("ASCOM.Simulator.FilterWheel", "ASCOM.FilterWheelSim.exe", "{AE139A96-FF4D-4F22-A44C-141A9873E823}", authenticationLevel);
            AddAppID("ASCOM.Simulator.Rotator", "ASCOM.RotatorSimulator.exe", "{5D4BBF44-2573-401A-AEE1-F9716D0BAEC3}", authenticationLevel);
            AddAppID("ASCOM.Simulator.Telescope", "ASCOM.TelescopeSimulator.exe", "{1620DCB8-0352-4717-A966-B174AC868FA0}", authenticationLevel);

            AddAppID("ASCOM.Simulator.Switch", "ASCOM.Simulator.Server.exe", "{05FA1687-DAAB-4003-BC69-5BDE762AE94C}", authenticationLevel);
            AddAppID("ASCOM.Simulator.ObservingConditions", "ASCOM.OCSimulator.Server.exe", "{861B2761-A31E-4413-82BF-BE90D2AB7AF5}", authenticationLevel);
            AddAppID("ASCOM.OCH.ObservingConditions", "ASCOM.OCH.Server.exe", "{DF5B974C-385A-437F-BC0D-F67111F12452}", authenticationLevel);
        }
Exemplo n.º 2
0
        private void AddAppID(string progID, string exeName, string sAPPID, DCOMAuthenticationLevel authenticationLevel)
        {
            RegistryKey rkCLSID    = null;
            RegistryKey rkAPPID    = null;
            RegistryKey rkAPPIDExe = null;

            try
            {
                LogMessage("AddAppID", "ProgID: " + progID + ", ExeName: " + exeName + ", Appid: " + sAPPID);

                int    hr     = CLSIDFromProgID(progID, out Guid gCLSID);
                string sCLSID = "{" + new GuidConverter().ConvertToString(gCLSID) + "}";
                LogMessage("AddAppID", "  CLSID: " + sCLSID);


                rkCLSID = Registry.ClassesRoot.OpenSubKey("CLSID\\" + sCLSID, RegistryKeyPermissionCheck.ReadWriteSubTree);
                LogMessage("AddAppID", string.Format("Registry key rkCLSID is null: {0}", rkCLSID == null));
                rkCLSID.SetValue("AppId", sAPPID);
                rkAPPID = Registry.ClassesRoot.CreateSubKey("APPID\\" + sAPPID, RegistryKeyPermissionCheck.ReadWriteSubTree);
                rkAPPID.SetValue("", rkCLSID.GetValue(""));                                            // Same description as class
                rkAPPID.SetValue("AppId", sAPPID);
                rkAPPID.SetValue("AuthenticationLevel", authenticationLevel, RegistryValueKind.DWord); // RPC_C_AUTHN_LEVEL_NONE

                if (exeName != "")                                                                     // If want AppId\Exe.name
                {
                    rkAPPIDExe = Registry.ClassesRoot.CreateSubKey("AppId\\" + exeName, RegistryKeyPermissionCheck.ReadWriteSubTree);
                    rkAPPIDExe.SetValue("", rkCLSID.GetValue(""));              // Same description as class
                    rkAPPIDExe.SetValue("AppId", sAPPID);
                }
                LogMessage("AddAppID", "OK - Completed");
            }
            catch (Exception ex)
            {
                errorCount += 1;
                LogMessage("AddAppID", string.Format("Failed to add AppID info for {0}", progID));
                TL.LogMessageCrLf("AddAppID", "Exception: " + ex.ToString());
            }
            finally
            {
                if (rkCLSID != null)
                {
                    rkCLSID.Close();
                }
                if (rkAPPID != null)
                {
                    rkAPPID.Close();
                }
                if (rkAPPIDExe != null)
                {
                    rkAPPIDExe.Close();
                }
            }
        }