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


C# RegistryValueKind类代码示例

本文整理汇总了C#中RegistryValueKind的典型用法代码示例。如果您正苦于以下问题:C# RegistryValueKind类的具体用法?C# RegistryValueKind怎么用?C# RegistryValueKind使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: RegEnumValue

		private static int RegEnumValue (IntPtr keyBase,
		int index, StringBuilder nameBuffer,
		ref int nameLength, IntPtr reserved,
		ref RegistryValueKind type, IntPtr data, IntPtr dataLength)
		{
			throw new System.NotImplementedException();
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:7,代码来源:Win32RegistryApi.Mosa.cs

示例2: set

        public bool set(String key, String val, RegistryValueKind type)
        {
            RegistryKey reg;
            int result = 1;
            string[] keysplit = (key).Split(System.IO.Path.DirectorySeparatorChar);
            string root = keysplit[0];
            string name = keysplit[keysplit.Length - 1];
            string path = key.Replace(root + @"\", "").Replace(@"\" + name, "");
            switch (root)
            {
                case "HKCU":
                    reg = Registry.CurrentUser;
                    break;
                case "HKLM":
                    reg = Registry.LocalMachine;
                    break;
                default:
                    return false;
            }

            reg = reg.CreateSubKey(path);
            if (reg == null) result = 0;
            reg.SetValue(name, val, type);
            object regObj = reg.GetValue(name);
            if (regObj == null) result = 0;
            reg.Close();
            reg = null;
            if (result == 0) return false; else return true;

        }
开发者ID:iwaim,项目名称:growl-for-windows,代码行数:30,代码来源:RegHelper.cs

示例3: ConvertValueToUIntFromRegistryIfNeeded

 public static object ConvertValueToUIntFromRegistryIfNeeded(string name, object value, RegistryValueKind kind)
 {
     try
     {
         if (kind == RegistryValueKind.DWord)
         {
             value = (int) value;
             if (((int) value) < 0)
             {
                 value = BitConverter.ToUInt32(BitConverter.GetBytes((int) value), 0);
             }
             return value;
         }
         if (kind == RegistryValueKind.QWord)
         {
             value = (long) value;
             if (((long) value) < 0L)
             {
                 value = BitConverter.ToUInt64(BitConverter.GetBytes((long) value), 0);
             }
         }
     }
     catch (IOException)
     {
     }
     return value;
 }
开发者ID:nickchal,项目名称:pash,代码行数:27,代码来源:RegistryWrapperUtils.cs

示例4: RegSetValueEx

 internal static extern int RegSetValueEx(
     SafeRegistryHandle hKey,
     String lpValueName,
     int Reserved,
     RegistryValueKind dwType,
     String lpData,
     int cbData);
开发者ID:dotnet,项目名称:corefx,代码行数:7,代码来源:Interop.RegSetValueEx.cs

示例5: ConvertValueToUIntFromRegistryIfNeeded

        public static object ConvertValueToUIntFromRegistryIfNeeded(string name, object value, RegistryValueKind kind)
        {
            try
            {
                // Workaround for CLR bug that doesn't support full range of DWORD or QWORD
                if (kind == RegistryValueKind.DWord)
                {
                    value = (int)value;
                    if ((int)value < 0)
                    {
                        value = BitConverter.ToUInt32(BitConverter.GetBytes((int)value), 0);
                    }
                }
                else if (kind == RegistryValueKind.QWord)
                {
                    value = (long)value;
                    if ((long)value < 0)
                    {
                        value = BitConverter.ToUInt64(BitConverter.GetBytes((long)value), 0);
                    }
                }
            }
            catch (System.IO.IOException)
            {
                // This is expected if the value does not exist.
            }

            return value;
        }
开发者ID:40a,项目名称:PowerShell,代码行数:29,代码来源:RegistryWrapper.cs

示例6: RegSzOddByteLength

        public void RegSzOddByteLength(RegistryValueKind kind, byte[] contents)
        {
            const string TestValueName = "CorruptData2";

            SafeRegistryHandle handle = TestRegistryKey.Handle;
            int ret = Interop.mincore.RegSetValueEx(handle, TestValueName, 0,
                kind, contents, contents.Length);
            Assert.Equal(0, ret);
            try
            {
                object o = TestRegistryKey.GetValue(TestValueName);

                string s;
                if (kind == RegistryValueKind.MultiString)
                {
                    Assert.IsType<string[]>(o);
                    var strings = (string[])o;
                    Assert.Equal(1, strings.Length);
                    s = strings[0];
                }
                else
                {
                    Assert.IsType<string>(o);
                    s = (string)o;
                }

                Assert.Equal(2, s.Length);
                Assert.Equal(0x506, s[0]);
                Assert.Equal(0x6, s[1]);
            }
            finally
            {
                TestRegistryKey.DeleteValue(TestValueName);
            }
        }
开发者ID:noahfalk,项目名称:corefx,代码行数:35,代码来源:RegistryKey_GetValue_CorruptData.cs

示例7: PutObjectValue

		public static void PutObjectValue(string key, string valuename, string value, bool bHKLM, RegistryValueKind kind = RegistryValueKind.Unknown)
        {
            using (RegistryKey regkey = bHKLM ? Registry.LocalMachine.CreateSubKey(key) : Registry.CurrentUser.CreateSubKey(key))
            {
                regkey.SetValue(valuename, value, kind);
            }
        }
开发者ID:killbug2004,项目名称:WSProf,代码行数:7,代码来源:RegUtils.cs

示例8: SetPolicyRegistryKey

        private static void SetPolicyRegistryKey(string path, string name, object value, RegistryValueKind kind)
        {
            const string keyPath = @"Software\Microsoft\Windows\CurrentVersion\Group Policy Objects";
            using (var rk = RegistryKey.OpenBaseKey(RegistryHive.CurrentUser, RegistryView.Default))
            {
                List<string> certKeys;
                using (var srk = rk.OpenSubKey(keyPath))
                {
                    if (srk == null)
                    {
                        throw new ApplicationException("无法打开注册表项:" + keyPath);
                    }
                    certKeys = srk.GetSubKeyNames().Where(x => x.EndsWith("Machine")).Select(x => string.Format("{0}\\{1}\\{2}", keyPath, x, path))
                        //.Where(x => rk.OpenSubKey(x) == null)
                        .ToList();
                }

                foreach (var key in certKeys)
                {
                    using (var skey = rk.CreateSubKey(key))
                    {
                        if (skey != null) skey.SetValue(name, value, kind);
                    }
                }
            }

        }
开发者ID:rampageX,项目名称:RevokeChinaCerts,代码行数:27,代码来源:CertPolicyAppender.cs

示例9: RegQueryValueEx

		static extern uint RegQueryValueEx(
			UIntPtr hKey,
			string lpValueName,
			IntPtr lpReserved,
			out RegistryValueKind lpType,
			StringBuilder lpData,
			ref int lpcbData);
开发者ID:UNIT6-open,项目名称:TWAIN-Web,代码行数:7,代码来源:RegistryHelper.cs

示例10: RegistryValueSnapshot

 public RegistryValueSnapshot(string name, string value, RegistryValueKind type)
     : this()
 {
     this.Name = name;
       this.Value = value;
       this.Type = type;
 }
开发者ID:cyotek,项目名称:RegistryComparer,代码行数:7,代码来源:RegistryValueSnapshot.cs

示例11: RegValueSpec

 /// <summary>
 /// Constructs a key value pair with the given valueName, valueObject, and valueKind.  
 /// Sets valueKind to RegistryValueKind.Unknown which will cause any call to RegistryKey.SetValue to attempt to dynamically derive the type from the actual type of the ValueObject.
 /// </summary>
 public RegValueSpec(string valueName, object valueObject, RegistryValueKind valueKind)
     : this()
 {
     ValueName = valueName;
     ValueObject = valueObject;
     ValueKind = valueKind;
 }
开发者ID:mosaicsys,项目名称:MosaicLibCS,代码行数:11,代码来源:Registry.cs

示例12: ConvertUIntToValueForRegistryIfNeeded

 public static object ConvertUIntToValueForRegistryIfNeeded(object value, RegistryValueKind kind)
 {
     if (kind == RegistryValueKind.DWord)
     {
         try
         {
             value = BitConverter.ToInt32(BitConverter.GetBytes(Convert.ToUInt32(value, CultureInfo.InvariantCulture)), 0);
         }
         catch (OverflowException)
         {
         }
         return value;
     }
     if (kind == RegistryValueKind.QWord)
     {
         try
         {
             value = BitConverter.ToInt64(BitConverter.GetBytes(Convert.ToUInt64(value, CultureInfo.InvariantCulture)), 0);
         }
         catch (OverflowException)
         {
         }
     }
     return value;
 }
开发者ID:nickchal,项目名称:pash,代码行数:25,代码来源:RegistryWrapperUtils.cs

示例13: AddinKeyValue

 internal AddinKeyValue(WatchController root, AddinKey parent, string valueName, RegistryValueKind valueKind, object value)
 {
     _root = root;
     _parent = parent;
     _valueName = valueName;
     _valueKind = valueKind;
     _value = value;
 }
开发者ID:swatt6400,项目名称:NetOffice,代码行数:8,代码来源:AddinKeyValue.cs

示例14: ConfigRegistryItem

 public ConfigRegistryItem(ConfigEngine engine, string itemName, string path, string name, object value, RegistryValueKind kind)
     : base(engine, itemName)
 {
     _path = path;
     _name = name;
     _value = value;
     _kind = kind;
 }
开发者ID:AlexWitteveen,项目名称:Configuration,代码行数:8,代码来源:ConfigRegistryItem.cs

示例15: RegChange

 public RegChange(RegOperations regOp, RegBasekeys regBase, string subKey, bool is32BitKey)
 {
     RegOperation = regOp;
     RegBasekey = regBase;
     SubKey = subKey;
     RegValueKind = RegistryValueKind.String;
     Is32BitKey = is32BitKey;
 }
开发者ID:shunpei-suzuki,项目名称:wyupdate,代码行数:8,代码来源:RegChange.cs


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