Ejemplo n.º 1
0
        protected static void RegKeySetValue(WinRegSystem wRegSystem, WinRegKey wRegKey, object value, RegistryValueKind valueKind = RegistryValueKind.DWord)
        {
            try
            {
                RegistryKey rk = RegGetAppKey(wRegSystem, WinRegMode.Write);

                rk.SetValue(wRegKey.ToString(), value, valueKind);
                rk.Close();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 2
0
        public static string DoRun()
        {
            string debug      = string.Empty;
            string debug_line = string.Empty;

            try
            {
                WinRegSystem wregsystem = (Environment.Is64BitOperatingSystem) ? WinRegSystem.Win64 : WinRegSystem.Win32;

                if (RegKeyGetValue(wregsystem, WinRegKey.AllowElevatedTrustAppsInBrowser) != string.Empty)
                {
                    RegKeySetValue(wregsystem, WinRegKey.AllowElevatedTrustAppsInBrowser, 1);
                    Console.WriteLine(string.Format("Registry Key {0}... updated", WinRegKey.AllowElevatedTrustAppsInBrowser.ToString()));
                }
                else
                {
                    RegKeySetValue(wregsystem, WinRegKey.AllowElevatedTrustAppsInBrowser, 1);
                    Console.WriteLine(string.Format("Registry Key {0}... created", WinRegKey.AllowElevatedTrustAppsInBrowser.ToString()));
                }

                if (RegKeyGetValue(wregsystem, WinRegKey.AllowInstallOfElevatedTrustApps) != string.Empty)
                {
                    RegKeySetValue(wregsystem, WinRegKey.AllowInstallOfElevatedTrustApps, 1);
                    Console.WriteLine(string.Format("Registry Key {0}... updated", WinRegKey.AllowInstallOfElevatedTrustApps.ToString()));
                }
                else
                {
                    RegKeySetValue(wregsystem, WinRegKey.AllowInstallOfElevatedTrustApps, 1);
                    Console.WriteLine(string.Format("Registry Key {0}... created", WinRegKey.AllowInstallOfElevatedTrustApps.ToString()));
                }

                if (RegKeyGetValue(wregsystem, WinRegKey.AllowLaunchOfElevatedTrustApps) != string.Empty)
                {
                    RegKeySetValue(wregsystem, WinRegKey.AllowLaunchOfElevatedTrustApps, 1);
                    Console.WriteLine(string.Format("Registry Key {0}... updated", WinRegKey.AllowLaunchOfElevatedTrustApps.ToString()));
                }
                else
                {
                    RegKeySetValue(wregsystem, WinRegKey.AllowLaunchOfElevatedTrustApps, 1);
                    Console.WriteLine(string.Format("Registry Key {0}... created", WinRegKey.AllowLaunchOfElevatedTrustApps.ToString()));
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            return(string.Empty);
        }
Ejemplo n.º 3
0
        protected static string RegKeyGetValue(WinRegSystem wRegSystem, WinRegKey wRegKey)
        {
            try
            {
                RegistryKey rk = RegGetAppKey(wRegSystem);

                if (rk.GetValue(wRegKey.ToString()) != null)
                {
                    return(rk.GetValue(wRegKey.ToString(), string.Empty).ToString());
                }
                else
                {
                    return(string.Empty);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 4
0
        protected static RegistryKey RegGetAppKey(WinRegSystem wRegSystem, WinRegMode mode = WinRegMode.ReadOnly)
        {
            try
            {
                string entryName = GetAppKeyBaseName();

                switch (wRegSystem)
                {
                case WinRegSystem.Win32: entryName += Properties.Settings.Default.SILVERLIGHT_REGISTER_PATH_32; break;

                case WinRegSystem.Win64: entryName += Properties.Settings.Default.SILVERLIGHT_REGISTER_PATH_64; break;
                }

                RegistryKey rk = null;

                // Create a reference to a valid key.  In order for this code to
                // work, the indicated key must have been created previously.
                // The key name is not case-sensitive.
                if (WinRegMode.ReadOnly == mode)
                {
                    rk = Registry.LocalMachine.OpenSubKey(entryName, false);
                }
                else
                {
                    rk = Registry.LocalMachine.CreateSubKey(entryName);
                }

                if (rk == null)
                {
                    throw new Exception(string.Format(Properties.Resources.REG32_ENTRY_NOT_FOUND, entryName));
                }

                return(rk);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }