当前位置: 首页>>代码示例>>C#>>正文


C# RegistryKey.CreateSubKey方法代码示例

本文整理汇总了C#中Microsoft.Win32.RegistryKey.CreateSubKey方法的典型用法代码示例。如果您正苦于以下问题:C# RegistryKey.CreateSubKey方法的具体用法?C# RegistryKey.CreateSubKey怎么用?C# RegistryKey.CreateSubKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.Win32.RegistryKey的用法示例。


在下文中一共展示了RegistryKey.CreateSubKey方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateRK

 private void CreateRK(RegistryKey rk)
 {
     rk = rk.CreateSubKey(sProtocol);
     rk.SetValue("URL Protocol", "");
     rk = rk.CreateSubKey("Shell");
     rk = rk.CreateSubKey("Open");
     rk = rk.CreateSubKey("Command");
     rk.SetValue(null,sExe);
 }
开发者ID:dingxinbei,项目名称:LogWin,代码行数:9,代码来源:Register.cs

示例2: initialize

        public static void initialize()
        {
            RegistryKey software = Registry.CurrentUser.OpenSubKey("Software", true);
            options = software.CreateSubKey("Changes Checker");
            list = options.CreateSubKey("list");
            hashes = options.CreateSubKey("hashes");
            //times = options.CreateSubKey("times");

            RegistryKey userMailBeep = Registry.CurrentUser.OpenSubKey("AppEvents")
                .OpenSubKey("Schemes").OpenSubKey("Apps").OpenSubKey(".Default")
                .OpenSubKey(".Default").OpenSubKey(".Current");
            soundPath = userMailBeep.GetValue("").ToString();
            userMailBeep.Close();
        }
开发者ID:maindefine,项目名称:changes-checker,代码行数:14,代码来源:Global.cs

示例3: CopyKey

        /// <summary>
        /// Copies recursivelly the registry data from the source to the destination key.
        /// </summary>
        /// <param name="srcKey">The source key.</param>
        /// <param name="srcPath">The source path.</param>
        /// <param name="dstKey">The destination key.</param>
        /// <param name="dstPath">The detination path.</param>
        /// <param name="progress">A delegate to the progress.</param>
        /// <returns><b>True</b> if the copy was successful, <b>false</b> otherwise.</returns>
        public static bool CopyKey(RegistryKey srcKey, string srcPath, RegistryKey dstKey, string dstPath, Action<string, string> progress = null)
        {
            // Open the source key.
            using (RegistryKey src = srcKey.OpenSubKey(srcPath, RegistryKeyPermissionCheck.ReadWriteSubTree))
            {
                // If the source key is null, return.
                if (null == src) return false;

                // Create the destination key.
                using (RegistryKey dst = dstKey.CreateSubKey(dstPath, RegistryKeyPermissionCheck.ReadWriteSubTree))
                {
                    // If the destination key is null, return.
                    if (null == dst) return false;

                    // If the progress delegate is not null, update the progress.
                    if (null != progress) progress(src.Name, dst.Name);

                    // Copy all values.
                    foreach (string value in src.GetValueNames())
                    {
                        // Copy the values.
                        dst.SetValue(value, src.GetValue(value), src.GetValueKind(value));
                    }

                    // Perform a recursive copy of the registry keys.
                    foreach (string subkey in src.GetSubKeyNames())
                    {
                        // Copy the registry key.
                        RegistryExtensions.CopyKey(src, subkey, dst, subkey, progress);
                    }

                    return true;
                }
            }
        }
开发者ID:alexbikfalvi,项目名称:DotNetApi,代码行数:44,代码来源:RegistryExtensions.cs

示例4: SetRegistryData

 public static void SetRegistryData(RegistryKey key, string path, string item, string value)
 {
     string[] keys = path.Split(new char[] {'/'},StringSplitOptions.RemoveEmptyEntries);
     try
     {
         if (keys.Count() == 0)
         {
             key.SetValue(item, value);
             key.Close();
         }
         else
         {
             string[] subKeys = key.GetSubKeyNames();
             if (subKeys.Where(s => s.ToLowerInvariant() == keys[0].ToLowerInvariant()).FirstOrDefault() != null)
             {
                 //Open subkey
                 RegistryKey sub = key.OpenSubKey(keys[0], (keys.Count() == 1));
                 if (keys.Length > 1)
                     SetRegistryData(sub, path.Substring(keys[0].Length + 1), item, value);
                 else
                     SetRegistryData(sub, string.Empty, item, value);
             }
             else
             {
                 SetRegistryData(key.CreateSubKey(keys[0]), path.Substring(keys[0].Length + 1), item, value);
             }
         }
     }
     catch { }
 }
开发者ID:Kayomani,项目名称:FAP,代码行数:30,代码来源:RegistryHelper.cs

示例5: Upgrade

        public bool Upgrade(IIndentGuide service, RegistryKey root, string subkeyName)
        {
            int version;
            using (var reg = root.OpenSubKey(subkeyName, false)) {
                version = (reg == null) ? 0 : (int)reg.GetValue("Version", IndentGuidePackage.DEFAULT_VERSION);
            }

            if (version == 0 || version == IndentGuidePackage.Version) {
                return false;
            }

            using (var reg = root.CreateSubKey(subkeyName)) {
                if (version >= 0x000C0903) {
                    // Nothing to upgrade
                } else if (version == 0x000C0902) {
                    UpgradeFrom_12_9_2(reg);
                } else if (version >= 0x000C0000) {
                    // Nothing to upgrade
                } else if (version >= 0x000B0901) {
                    UpgradeFrom_11_9_0(reg);
                } else if (version >= 0x000A0901) {
                    UpgradeFrom_10_9_1(reg);
                } else {
                    UpgradeFrom_Earlier(reg);
                }

                // Upgrading will make guides visible regardless of the
                // previous setting.
                reg.SetValue("Visible", 1);
            }

            return true;
        }
开发者ID:iccfish,项目名称:indent-guides-mod,代码行数:33,代码来源:UpgradeSettings.cs

示例6: initKeys

        static void initKeys()
        {
            if (mainKey != null) return;
            mainKey = Custom.BaseKey; // Registry.CurrentUser.CreateSubKey("SOFTWARE\\Repetier");
            windowKey = mainKey.CreateSubKey("window");

        }
开发者ID:JackTing,项目名称:Repetier-Host,代码行数:7,代码来源:RegMemory.cs

示例7: PlConfigSlice

        /// <summary>
        /// Creates a new configuration slice instance.
        /// </summary>
        /// <param name="slice">The slice.</param>
        /// <param name="rootKey">The root registry key.</param>
        public PlConfigSlice(PlSlice slice, RegistryKey rootKey)
        {
            // Check the arguments.
            if (null == slice) throw new ArgumentNullException("slice");

            // Set the slice.
            this.slice = slice;

            // Set the slice event handler.
            this.slice.Changed += this.OnSliceChanged;

            // Open or create the subkey for the current slice.
            if (null == (this.key = rootKey.OpenSubKey(this.slice.Id.Value.ToString(), RegistryKeyPermissionCheck.ReadWriteSubTree)))
            {
                // If the key does not exist, create the key.
                this.key = rootKey.CreateSubKey(this.slice.Id.Value.ToString());
            }

            // Check the commands directory exists.
            if (!Directory.Exists(CrawlerConfig.Static.PlanetLabSlicesFolder))
            {
                // If the directory does not exist, create it.
                Directory.CreateDirectory(CrawlerConfig.Static.PlanetLabSlicesFolder);
            }

            // Create the slice log.
            this.log = new Logger(CrawlerConfig.Static.PlanetLabSlicesLogFileName.FormatWith(this.slice.Id, "{0}", "{1}", "{2}"));

            // Create the slice commands configuration.
            this.commands = new PlConfigSliceCommands(this.key, this.slice.Id.Value);
        }
开发者ID:alexbikfalvi,项目名称:InetAnalytics,代码行数:36,代码来源:PlConfigSlice.cs

示例8: CreateKey

        /// <summary>
        /// 
        /// </summary>
        /// <param name="root"></param>
        /// <param name="subKey"></param>
        internal static void CreateKey(RegistryKey root, string subKey)
        {
            RegistryKey rk = null;

            try {

                rk = root.CreateSubKey( subKey );
                if ( rk != null ) {

                    Log.AppendString( logfile, "Created key: " + rk.ToString() + Environment.NewLine );
                    Display.UpdateStatus( "Created: " + root.ToString() + "\\..." + subKey.Substring( subKey.LastIndexOf( '\\' ) ) + "\\*" );

                }

            }
            catch ( Exception ex ) {

                // Record exceptions in the log file
                Log.AppendException( logfile, ex );

            }
            finally {

                // Finally, cleanup and prepare variables for garbage collection
                if ( rk != null ) {

                    rk.Close();
                    rk = null;

                }

                subKey = null;

            }
        }
开发者ID:AndrewBarfield,项目名称:Barfield-Cleaner,代码行数:40,代码来源:RegistryCleaner.cs

示例9: TestInitialize

        public void TestInitialize()
        {
            var counter = Interlocked.Increment(ref s_keyCount);
            _testKey += counter.ToString();
            _rk1 = Microsoft.Win32.Registry.CurrentUser;
            if (_rk1.OpenSubKey(_testKey) != null)
                _rk1.DeleteSubKeyTree(_testKey);
            if (_rk1.GetValue(_testKey) != null)
                _rk1.DeleteValue(_testKey);

            //created the test key. if that failed it will cause many of the test scenarios below fail.
            try
            {
                _rk1 = Microsoft.Win32.Registry.CurrentUser;
                _rk2 = _rk1.CreateSubKey(_testKey);
                if (_rk2 == null)
                {
                    Assert.False(true, "ERROR: Could not create test subkey, this will fail a couple of scenarios below.");
                }
                else
                    _keyString = _rk2.ToString();
            }
            catch (Exception e)
            {
                Assert.False(true, "ERROR: unexpected exception, " + e.ToString());
            }
        }
开发者ID:gitter-badger,项目名称:corefx,代码行数:27,代码来源:Registry_Getvalue_str_str_obj.cs

示例10: SetString

 public void SetString(RegistryKey hive, string key, string valueName, string value)
 {
     using (var subKey = hive.CreateSubKey(key))
     {
         subKey.SetValue(valueName, value);
     }
 }
开发者ID:B2MSolutions,项目名称:reyna-net45,代码行数:7,代码来源:Registry.cs

示例11: Guardar

 public static void Guardar(RegistryKey raiz, String nombreClave, String nombreValor, Object valor)
 {
     RegistryKey clave;
     clave = raiz.OpenSubKey(nombreClave, true);
     if (clave == null) clave = raiz.CreateSubKey(nombreClave);
     clave.SetValue(nombreValor, valor);
 }
开发者ID:pjeconde,项目名称:eFact,代码行数:7,代码来源:Registro.cs

示例12: SetQWord

 public void SetQWord(RegistryKey hive, string key, string valueName, long value)
 {
     using (var subKey = hive.CreateSubKey(key))
     {
         subKey.SetValue(valueName, value, RegistryValueKind.QWord);
     }
 }
开发者ID:B2MSolutions,项目名称:reyna-net45,代码行数:7,代码来源:Registry.cs

示例13: Configuration

        public Configuration()
        {
            OperatingSystem os = Environment.OSVersion;
            Console.WriteLine ("OS platform: " + os.Platform);
            this.platform = os.Platform.ToString ();

            if (this.platform.StartsWith ("Win")) {

                RegistryKey CurrentUserKey = Microsoft.Win32.Registry.CurrentUser;

                string OurAppKeyStr = @"SOFTWARE\moNotationalVelocity";
                OurAppRootKey = CurrentUserKey.CreateSubKey (OurAppKeyStr);
                ConfigKey = OurAppRootKey.CreateSubKey ("config");

                this.notesDirPath = ConfigKey.GetValue ("notesDirPath") as string;
                if (this.notesDirPath == null) {
                    Console.WriteLine ("No configuration");
                    this.notesDirPath = defaulNotesDirtPath;
                    ConfigKey.SetValue ("notesDirPath", this.notesDirPath, RegistryValueKind.String);
                }

                ConfigKey.Flush ();

            } else {

                this.notesDirPath = defaulNotesDirtPath;
            }
        }
开发者ID:mzehrer,项目名称:monovel,代码行数:28,代码来源:Configuration.cs

示例14: GetKey

 protected RegistryKey GetKey(RegistryKey root, string subkey, bool writeable)
 {
     RegistryKey key = root.OpenSubKey(subkey, writeable);
     if (key == null && writeable)
         key = root.CreateSubKey(subkey);
     return key;
 }
开发者ID:bacobart,项目名称:transmission-remote-dotnet,代码行数:7,代码来源:RegistryJsonLocalSettings.cs

示例15: SetRegistryValue

        public static bool SetRegistryValue(RegistryKey RootKey, string szSubKey, string szItem, string value)
        {
            bool bIsSuccessful = false;
            try
            {
                RegistryKey registryKey = RootKey.OpenSubKey(szSubKey, true);
                if (registryKey == null)
                {
                    registryKey = RootKey.CreateSubKey(szSubKey);
                }

                if (registryKey != null)
                {
                    using (registryKey)
                    {
                        registryKey.SetValue(szItem, value);
                        bIsSuccessful = true;
                    }
                }
            }
            catch (UnauthorizedAccessException)
            {
                return bIsSuccessful;
            }
            return bIsSuccessful;
        }
开发者ID:nhnchengdu,项目名称:nGit,代码行数:26,代码来源:CRegistryFunction.cs


注:本文中的Microsoft.Win32.RegistryKey.CreateSubKey方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。