示例#1
0
        // Returns a RegEntries struct populated with the subkeys and values in the registry key whose path is specified.
        public static HRESULT EnumerateKey(string path, out RegEntries entries)
        {
            HRESULT hr = HRESULT.S_OK;

            if (PathUtils.IsVirtualizationRoot(path))
            {
                entries = new RegEntries {
                    SubKeys = _regRootKeyMap.Keys.ToArray(), Values = new string[0]
                };
            }
            else
            {
                // The path is somewhere below the root, so try opening the key.
                hr = OpenKeyByPath(path, out var subKey);

                // If the path corresponds to a registry key, enumerate it.
                if (subKey != null)
                {
                    hr = EnumerateKey(subKey, out entries);
                    subKey.Dispose();
                }
                else
                {
                    entries = default;
                }
            }
            return(hr);
        }
示例#2
0
 // Returns a RegEntries struct populated with the subkeys and values in the specified registry key.
 private static HRESULT EnumerateKey(RegistryKey hKey, out RegEntries entries)
 {
     entries = new RegEntries {
         SubKeys = hKey.GetSubKeyNames().ToArray(), Values = hKey.GetValueNames().ToArray()
     };
     return(HRESULT.S_OK);
 }