// Create key and if needed all parent keys private OffregLib.OffregKey CreateKeys(OffregLib.OffregHive hiveImpl, string path, string lpClass, Win32Api.RegOption dwOptions, IntPtr lpSecurityDescriptor, IntPtr lpdwDisposition) { OffregLib.OffregKey result = null; try { OffRegHive.ConvertException(() => result = hiveImpl.Root.OpenSubKey(path)); return(result); } catch (FileNotFoundException) { } // We either take the first subkey of the path, or the last string parentPath, subkey; if (KeyIdentity.PartitionPath(path, out parentPath, out subkey)) { OffregLib.OffregKey parentKey = CreateKeys(hiveImpl, parentPath, lpClass, dwOptions, lpSecurityDescriptor, lpdwDisposition); OffRegHive.ConvertException(() => parentKey.Close()); } // TODO: do something with lpClass, lpSecurityDescriptor, for now they are ignored OffRegHive.ConvertException(() => result = hiveImpl.Root.CreateSubKey( path, (OffregLib.RegOption)dwOptions)); if (lpdwDisposition != IntPtr.Zero) { Marshal.WriteInt32(lpdwDisposition, (int)Win32Api.RegKeyDisposition.REG_CREATED_NEW_KEY); } // TODO: if there is an existing key in windows registry, but we create one // in offreg hive, which disposition do we need to return? return(result); }
internal OffRegKey(OffRegHive hive, OffregLib.OffregHive hiveImpl, KeyIdentity identity, string lpClass, Win32Api.RegOption dwOptions, IntPtr lpSecurityDescriptor, IntPtr lpdwDisposition) { hive_ = hive; identity_ = identity; key_ = CreateKeys(hiveImpl, GetMainOffRegPath(identity), lpClass, dwOptions, lpSecurityDescriptor, lpdwDisposition); }
internal OffRegKey(OffRegHive hive, OffregLib.OffregKey key, KeyIdentity identity) { hive_ = hive; key_ = key; identity_ = identity; }
public void Close() { OffRegHive.ConvertException(() => key_.Close()); key_ = null; }