コード例 #1
0
        internal void OpenKey(IntPtr hKey,
                              string lpSubKey,
                              int ulOptions,
                              Win32Api.KeySecurity samDesired,
                              out IntPtr phkResult)
        {
            // ulOptions are ignored as this is a reserved parameter
            phkResult = IntPtr.Zero;
            KeySecurity keySecurity;

            Win32Api.RegWow64Options wowOptions;
            KeySecurity.ExtractWow64Options(samDesired, out keySecurity, out wowOptions);
            KeyIdentity baseIdentity = GetKey(hKey).Identity;

            OpenKey(baseIdentity, new KeyIdentity(baseIdentity, wowOptions, lpSubKey),
                    keySecurity, out phkResult);
        }
コード例 #2
0
        internal void CreateKey(IntPtr hKey,
                                string lpSubKey,
                                int Reserved,
                                string lpClass,
                                Win32Api.RegOption dwOptions,
                                Win32Api.KeySecurity samDesired,
                                IntPtr lpSecurityAttributes,
                                out IntPtr phkResult,
                                IntPtr lpdwDisposition)
        {
            phkResult = IntPtr.Zero;
            // Reserved is ignored as this is a reserved parameter

            try
            {
                OpenKey(hKey, lpSubKey, 0, samDesired, out phkResult);
                if (lpdwDisposition != IntPtr.Zero)
                {
                    Marshal.WriteInt32(lpdwDisposition,
                                       (int)Win32Api.RegKeyDisposition.REG_OPENED_EXISTING_KEY);
                }
                return;
            }
            catch (FileNotFoundException) {}
            KeySecurity keySecurity;

            Win32Api.RegWow64Options wowOptions;
            KeySecurity.ExtractWow64Options(samDesired, out keySecurity, out wowOptions);
            VirtualKey key = factory_.CreateKey(
                new KeyIdentity(GetKey(hKey).Identity, wowOptions, lpSubKey), lpClass, dwOptions,
                lpSecurityAttributes);

            if (lpdwDisposition != IntPtr.Zero)
            {
                Marshal.WriteInt32(lpdwDisposition,
                                   (int)Win32Api.RegKeyDisposition.REG_CREATED_NEW_KEY);
            }
            phkResult = keyStorage_.Add(key);
        }