RegSetValueEx() private méthode

private RegSetValueEx ( IntPtr keyBase, string valueName, IntPtr reserved, RegistryValueKind type, byte rawData, int rawDataLength ) : int
keyBase System.IntPtr
valueName string
reserved System.IntPtr
type RegistryValueKind
rawData byte
rawDataLength int
Résultat int
        public void SetValue(RegistryKey rkey, string name, object value)
        {
            Type   type   = value.GetType();
            IntPtr handle = Win32RegistryApi.GetHandle(rkey);
            int    num2;

            if (type == typeof(int))
            {
                int num = (int)value;
                num2 = Win32RegistryApi.RegSetValueEx(handle, name, IntPtr.Zero, RegistryValueKind.DWord, ref num, 4);
            }
            else if (type == typeof(byte[]))
            {
                byte[] array = (byte[])value;
                num2 = Win32RegistryApi.RegSetValueEx(handle, name, IntPtr.Zero, RegistryValueKind.Binary, array, array.Length);
            }
            else if (type == typeof(string[]))
            {
                string[]      array2        = (string[])value;
                StringBuilder stringBuilder = new StringBuilder();
                foreach (string value2 in array2)
                {
                    stringBuilder.Append(value2);
                    stringBuilder.Append('\0');
                }
                stringBuilder.Append('\0');
                byte[] bytes = Encoding.Unicode.GetBytes(stringBuilder.ToString());
                num2 = Win32RegistryApi.RegSetValueEx(handle, name, IntPtr.Zero, RegistryValueKind.MultiString, bytes, bytes.Length);
            }
            else
            {
                if (type.IsArray)
                {
                    throw new ArgumentException("Only string and byte arrays can written as registry values");
                }
                string text = string.Format("{0}{1}", value, '\0');
                num2 = Win32RegistryApi.RegSetValueEx(handle, name, IntPtr.Zero, RegistryValueKind.String, text, text.Length * this.NativeBytesPerCharacter);
            }
            if (num2 == 1018)
            {
                throw RegistryKey.CreateMarkedForDeletionException();
            }
            if (num2 != 0)
            {
                this.GenerateException(num2);
            }
        }