用c#怎样读、写、删除注册表信息?

解决方案 »

  1.   


       // 在HKEY_LOCAL_MACHINESoftware下建立一新键,起名为MCBInc
                RegistryKey key = Registry.LocalMachine.OpenSubKey("Software", true);
             // 增加一个子键
                RegistryKey newkey = key.CreateSubKey("MCBInc");    // 设置此子键的值
                newkey.SetValue("MCBInc", "NET Developer");  // 从注册表的其他地方获取数据  // 找出你的CPU
                RegistryKey pRegKey = Registry.LocalMachine;
                pRegKey = pRegKey.OpenSubKey("HARDWAREDESCRIPTIONSystemCentralProcessor");
                Object val = pRegKey.GetValue("VendorIdentifier");
                Debug.WriteLine("The central processor of this machine is:"+ val);
             // 删除键值
                RegistryKey delKey = Registry.LocalMachine.OpenSubKey("Software", true);
                delKey.DeleteSubKey("MCBInc");
        }