[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Dotgnu-pnet-commits] CVS: pnetlib/runtime/Microsoft/Win32 IRegistryKeyP
From: |
Rhys Weatherley <address@hidden> |
Subject: |
[Dotgnu-pnet-commits] CVS: pnetlib/runtime/Microsoft/Win32 IRegistryKeyProvider.cs,NONE,1.1 MemoryKeyProvider.cs,NONE,1.1 Registry.cs,NONE,1.1 RegistryHive.cs,NONE,1.1 RegistryKey.cs,NONE,1.1 Win32KeyProvider.cs,NONE,1.1 |
Date: |
Thu, 03 Apr 2003 08:37:34 -0500 |
Update of /cvsroot/dotgnu-pnet/pnetlib/runtime/Microsoft/Win32
In directory subversions:/tmp/cvs-serv25444/runtime/Microsoft/Win32
Added Files:
IRegistryKeyProvider.cs MemoryKeyProvider.cs Registry.cs
RegistryHive.cs RegistryKey.cs Win32KeyProvider.cs
Log Message:
Emulate the Win32 registry classes using an in-memory database
that is discarded when the program exits.
--- NEW FILE ---
/*
* IRegistryKeyProvider.cs - Implementation of the
* "Microsoft.Win32.IRegistryKeyProvider" class.
*
* Copyright (C) 2003 Southern Storm Software, Pty Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
namespace Microsoft.Win32
{
#if !ECMA_COMPAT
using System;
// This interface is used internally to represent a registry key
// provider interface. There may be different providers for
// different operating systems.
internal interface IRegistryKeyProvider
{
// Close a reference to this key and flush any modifications to disk.
void Close(bool writable);
// Create a subkey underneath this particular registry key.
IRegistryKeyProvider CreateSubKey(String subkey);
// Delete this key entry.
void Delete();
// Delete this key entry and all of its descendents.
void DeleteTree();
// Delete a particular value underneath this registry key.
// Returns false if the value is missing.
bool DeleteValue(String name);
// Flush all modifications to this registry key.
void Flush();
// Get the names of all subkeys underneath this registry key.
String[] GetSubKeyNames();
// Get a value from underneath this registry key.
Object GetValue(String name, Object defaultValue);
// Get the names of all values underneath this registry key.
String[] GetValueNames();
// Open a subkey.
IRegistryKeyProvider OpenSubKey(String name, bool writable);
// Set a value under this registry key.
void SetValue(String name, Object value);
// Get the name of this registry key provider.
String Name { get; }
// Get the number of subkeys underneath this key.
int SubKeyCount { get; }
// Get the number of values that are associated with this key.
int ValueCount { get; }
}; // interface IRegistryKeyProvider
#endif // !ECMA_COMPAT
}; // namespace Microsoft.Win32
--- NEW FILE ---
/*
* MemoryKeyProvider.cs - Implementation of the
* "Microsoft.Win32.MemoryKeyProvider" class.
*
* Copyright (C) 2003 Southern Storm Software, Pty Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
namespace Microsoft.Win32
{
#if !ECMA_COMPAT
using System;
using System.Collections;
// This class implements a registry in memory. The contents
// are discarded when the program exits.
internal sealed class MemoryKeyProvider : IRegistryKeyProvider
{
// Internal state.
private MemoryKeyProvider parent;
private String fullName;
private String name;
private Hashtable subkeys;
private Hashtable values;
private bool deleted;
// Constructor.
public MemoryKeyProvider(MemoryKeyProvider parent, String fullName,
String name)
{
this.parent = parent;
this.fullName = fullName;
this.name = name;
this.subkeys = null;
this.values = null;
this.deleted = false;
}
// Close a reference to this key and flush any modifications to disk.
public void Close(bool writable)
{
// Nothing to do here - there is no disk copy.
}
// Create a subkey underneath this particular registry key.
public IRegistryKeyProvider CreateSubKey(String subkey)
{
lock(this)
{
if(deleted)
{
throw new ArgumentException
(_("IO_RegistryKeyNotExist"));
}
if(subkeys == null)
{
subkeys = new Hashtable
(CaseInsensitiveHashCodeProvider.Default,
CaseInsensitiveComparer.Default);
}
Object value = subkeys[subkey];
if(value == null)
{
value = new MemoryKeyProvider
(this, name + "\\" +
subkey, subkey);
subkeys[subkey] = value;
}
return (IRegistryKeyProvider)value;
}
}
// Delete this key entry.
public void Delete()
{
MemoryKeyProvider parent;
// Delete the information in this entry.
lock(this)
{
if(deleted)
{
// This key was already deleted.
throw new ArgumentException
(_("IO_RegistryKeyNotExist"));
}
else if(subkeys != null &&
subkeys.Count != 0)
{
throw new
InvalidOperationException
(_("IO_RegistryHasSubKeys"));
}
else
{
deleted = true;
subkeys = null;
if(values != null &&
values.Count != 0)
{
values.Clear();
}
values = null;
}
parent = this.parent;
}
// Remove the name from the parent provider.
if(parent != null)
{
lock(parent)
{
if(parent.subkeys != null)
{
parent.subkeys.Remove(name);
}
}
}
}
// Delete this key entry and all of its descendents.
public void DeleteTree()
{
// Collect up all of the children.
IRegistryKeyProvider[] children;
lock(this)
{
if(deleted)
{
// Ignore the operation if we
are already deleted.
return;
}
if(subkeys != null)
{
children = new
IRegistryKeyProvider [subkeys.Count];
IDictionaryEnumerator e =
subkeys.GetEnumerator();
int index = 0;
while(e.MoveNext())
{
children[index++] =
(IRegistryKeyProvider)(e.Value);
}
}
else
{
children = null;
}
}
// Recursively delete the children.
if(children != null)
{
int posn;
for(posn = 0; posn < children.Length;
++posn)
{
children[posn].DeleteTree();
}
}
// Delete this key entry. If new subkeys were
// added in the meantime, then simply ignore
them.
lock(this)
{
deleted = true;
if(subkeys != null && subkeys.Count !=
0)
{
subkeys.Clear();
}
subkeys = null;
if(values != null && values.Count != 0)
{
values.Clear();
}
values = null;
}
}
// Delete a particular value underneath this registry key.
// Returns false if the value is missing.
public bool DeleteValue(String name)
{
lock(this)
{
if(deleted)
{
throw new ArgumentException
(_("IO_RegistryKeyNotExist"));
}
if(values != null &&
values.Contains(name))
{
values.Remove(name);
return true;
}
else
{
return false;
}
}
}
// Flush all modifications to this registry key.
public void Flush()
{
// Nothing to do here - there is no disk copy.
}
// Create an array of names from a hash table's keys.
private static String[] CreateNameArray(Hashtable table)
{
String[] array = new String [table.Count];
IDictionaryEnumerator e = table.GetEnumerator();
int index = 0;
while(e.MoveNext())
{
array[index++] = (String)(e.Key);
}
return array;
}
// Get the names of all subkeys underneath this registry key.
public String[] GetSubKeyNames()
{
lock(this)
{
if(deleted)
{
throw new ArgumentException
(_("IO_RegistryKeyNotExist"));
}
if(subkeys != null)
{
return CreateNameArray(subkeys);
}
else
{
return new String [0];
}
}
}
// Get a value from underneath this registry key.
public Object GetValue(String name, Object defaultValue)
{
lock(this)
{
if(deleted)
{
throw new ArgumentException
(_("IO_RegistryKeyNotExist"));
}
if(values == null)
{
return defaultValue;
}
Object value = values[name];
if(value != null)
{
return value;
}
else
{
return defaultValue;
}
}
}
// Get the names of all values underneath this registry key.
public String[] GetValueNames()
{
lock(this)
{
if(deleted)
{
throw new ArgumentException
(_("IO_RegistryKeyNotExist"));
}
if(values != null)
{
return CreateNameArray(values);
}
else
{
return new String [0];
}
}
}
// Open a subkey.
public IRegistryKeyProvider OpenSubKey(String name, bool writable)
{
lock(this)
{
if(deleted)
{
throw new ArgumentException
(_("IO_RegistryKeyNotExist"));
}
if(subkeys != null)
{
return
(IRegistryKeyProvider)(subkeys[name]);
}
else
{
return null;
}
}
}
// Set a value under this registry key.
public void SetValue(String name, Object value)
{
lock(this)
{
if(deleted)
{
throw new ArgumentException
(_("IO_RegistryKeyNotExist"));
}
if(values == null)
{
values = new Hashtable
(CaseInsensitiveHashCodeProvider.Default,
CaseInsensitiveComparer.Default);
}
values[name] = value;
}
}
// Get the name of this registry key provider.
public String Name
{
get
{
return fullName;
}
}
// Get the number of subkeys underneath this key.
public int SubKeyCount
{
get
{
lock(this)
{
if(deleted)
{
throw new
ArgumentException
(_("IO_RegistryKeyNotExist"));
}
if(subkeys != null)
{
return subkeys.Count;
}
else
{
return 0;
}
}
}
}
// Get the number of values that are associated with this key.
public int ValueCount
{
get
{
lock(this)
{
if(deleted)
{
throw new
ArgumentException
(_("IO_RegistryKeyNotExist"));
}
if(values != null)
{
return values.Count;
}
else
{
return 0;
}
}
}
}
}; // class MemoryKeyProvider
#endif // !ECMA_COMPAT
}; // namespace Microsoft.Win32
--- NEW FILE ---
/*
* Registry.cs - Implementation of the
* "Microsoft.Win32.Registry" class.
*
* Copyright (C) 2003 Southern Storm Software, Pty Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
namespace Microsoft.Win32
{
#if !ECMA_COMPAT
using System;
public sealed class Registry
{
// Constructor.
private Registry() {}
// Standard registries on the local machine.
public static readonly RegistryKey ClassesRoot;
public static readonly RegistryKey CurrentUser;
public static readonly RegistryKey LocalMachine;
public static readonly RegistryKey Users;
public static readonly RegistryKey PerformanceData;
public static readonly RegistryKey CurrentConfig;
public static readonly RegistryKey DynData;
// Initialize the standard registries.
static Registry()
{
ClassesRoot = RegistryKey.OpenRemoteBaseKey
(RegistryHive.ClassesRoot,
String.Empty);
CurrentUser = RegistryKey.OpenRemoteBaseKey
(RegistryHive.CurrentUser,
String.Empty);
LocalMachine = RegistryKey.OpenRemoteBaseKey
(RegistryHive.LocalMachine,
String.Empty);
Users = RegistryKey.OpenRemoteBaseKey
(RegistryHive.Users, String.Empty);
PerformanceData = RegistryKey.OpenRemoteBaseKey
(RegistryHive.PerformanceData,
String.Empty);
CurrentConfig = RegistryKey.OpenRemoteBaseKey
(RegistryHive.CurrentConfig,
String.Empty);
DynData = RegistryKey.OpenRemoteBaseKey
(RegistryHive.DynData, String.Empty);
}
// Registry providers that have already been allocated.
private static IRegistryKeyProvider[] providers;
// Get a registry key provider for a particular hive.
internal static IRegistryKeyProvider GetProvider
(RegistryHive hKey, String name)
{
int index;
lock(typeof(Registry))
{
// Allocate the "providers" array if
necessary.
if(providers == null)
{
providers = new
IRegistryKeyProvider[7];
}
// See if we already have a provider
for this hive.
index = ((int)hKey) -
((int)(RegistryHive.ClassesRoot));
if(providers[index] != null)
{
return providers[index];
}
// Create a Win32 provider if we are on
a Windows system.
if(Win32KeyProvider.IsWin32())
{
providers[index] = new
Win32KeyProvider(name);
return providers[index];
}
// Create a memory-based provider on
all other systems.
providers[index] = new MemoryKeyProvider
(null, name, name);
return providers[index];
}
}
}; // class Registry
#endif // !ECMA_COMPAT
}; // namespace Microsoft.Win32
--- NEW FILE ---
/*
* RegistryHive.cs - Implementation of the
* "Microsoft.Win32.RegistryHive" class.
*
* Copyright (C) 2003 Southern Storm Software, Pty Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
namespace Microsoft.Win32
{
#if !ECMA_COMPAT
public enum RegistryHive
{
ClassesRoot = unchecked((int)0x80000000),
CurrentUser = unchecked((int)0x80000001),
LocalMachine = unchecked((int)0x80000002),
Users = unchecked((int)0x80000003),
PerformanceData = unchecked((int)0x80000004),
CurrentConfig = unchecked((int)0x80000005),
DynData = unchecked((int)0x80000006)
}; // enum RegistryHive
#endif // !ECMA_COMPAT
}; // namespace Microsoft.Win32
--- NEW FILE ---
/*
* RegistryKey.cs - Implementation of the
* "Microsoft.Win32.RegistryKey" class.
*
* Copyright (C) 2003 Southern Storm Software, Pty Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
namespace Microsoft.Win32
{
#if !ECMA_COMPAT
using System;
using System.IO;
using System.Security;
public sealed class RegistryKey : MarshalByRefObject, IDisposable
{
// Internal state.
private String name;
private IRegistryKeyProvider provider;
private bool writable;
// Standard hive names.
private static readonly String[] hiveNames = {
"HKEY_CLASSES_ROOT",
"HKEY_CURRENT_USER",
"HKEY_LOCAL_MACHINE",
"HKEY_USERS",
"HKEY_PERFORMANCE_DATA",
"HKEY_CURRENT_CONFIG",
"HKEY_DYN_DATA"
};
// Constructor.
private RegistryKey(IRegistryKeyProvider provider, bool writable)
{
this.name = provider.Name;
this.provider = provider;
this.writable = writable;
}
// Destructor.
~RegistryKey()
{
Close();
}
// Implement the IDisposable interface.
void IDisposable.Dispose()
{
Close();
}
// Close this key and flush any modifications to disk.
public void Close()
{
if(provider != null)
{
provider.Close(writable);
provider = null;
}
}
// Resolve a subkey to its parent and last component.
private static RegistryKey Resolve(RegistryKey start, String subkey,
bool
create, out String last)
{
int index;
String temp;
IRegistryKeyProvider key;
while((index = subkey.IndexOf('\\')) != -1 ||
(index = subkey.IndexOf('/')) != -1)
{
// Extract the name of this component.
temp = subkey.Substring(0, index);
subkey = subkey.Substring(index + 1);
// Bail out if "start" does not have a
provider.
if(start.provider == null)
{
throw new
IOException(_("IO_RegistryKeyClosed"));
}
// Create or open a new component.
if(create)
{
key =
start.provider.OpenSubKey(temp, true);
if(key == null)
{
key =
start.provider.CreateSubKey(temp);
}
start = new RegistryKey(key,
true);
}
else
{
key =
start.provider.OpenSubKey(temp, false);
if(key == null)
{
return null;
}
start = new RegistryKey(key,
false);
}
}
last = subkey;
if(start.provider == null)
{
throw new
IOException(_("IO_RegistryKeyClosed"));
}
return start;
}
// Create a subkey underneath this particular registry key.
public RegistryKey CreateSubKey(String subkey)
{
// Validate the parameters.
if(subkey == null)
{
throw new
ArgumentNullException("subkey");
}
if(provider == null)
{
throw new
IOException(_("IO_RegistryKeyClosed"));
}
if(!writable)
{
throw new UnauthorizedAccessException
(_("IO_RegistryReadOnly"));
}
// Resolve the subkey to a parent and last
component.
String last;
RegistryKey parent;
parent = Resolve(this, subkey, true, out last);
// Open or create the subkey and make it
writable.
IRegistryKeyProvider key;
key = parent.provider.OpenSubKey(last, true);
if(key == null)
{
key =
parent.provider.CreateSubKey(last);
}
return new RegistryKey(key, true);
}
// Delete a particular subkey.
public void DeleteSubKey(String subkey, bool throwOnMissingSubKey)
{
// Validate the parameters.
if(subkey == null)
{
throw new
ArgumentNullException("subkey");
}
if(provider == null)
{
throw new
IOException(_("IO_RegistryKeyClosed"));
}
// Resolve the subkey to a parent and last
component.
String last;
RegistryKey parent;
parent = Resolve(this, subkey, false, out last);
if(parent == null)
{
if(throwOnMissingSubKey)
{
throw new ArgumentException
(_("IO_RegistryKeyNotExist"));
}
return;
}
// Find and delete the subkey.
IRegistryKeyProvider key;
key = parent.provider.OpenSubKey(last, false);
if(key == null)
{
if(throwOnMissingSubKey)
{
throw new ArgumentException
(_("IO_RegistryKeyNotExist"));
}
return;
}
key.Close(false);
key.Delete();
}
public void DeleteSubKey(String subkey)
{
DeleteSubKey(subkey, true);
}
// Delete a particular subkey and all of its descendents.
public void DeleteSubKeyTree(String subkey)
{
// Validate the parameters.
if(subkey == null)
{
throw new
ArgumentNullException("subkey");
}
if(provider == null)
{
throw new
IOException(_("IO_RegistryKeyClosed"));
}
// Resolve the subkey to a parent and last
component.
String last;
RegistryKey parent;
parent = Resolve(this, subkey, false, out last);
if(parent == null)
{
throw new
ArgumentException(_("IO_RegistryKeyNotExist"));
}
// Find and delete the subkey.
IRegistryKeyProvider key;
key = parent.provider.OpenSubKey(last, false);
if(key == null)
{
throw new
ArgumentException(_("IO_RegistryKeyNotExist"));
}
key.Close(false);
key.DeleteTree();
}
// Delete a particular value underneath this registry key.
public void DeleteValue(String name, bool throwOnMissingValue)
{
if(name == null)
{
name = String.Empty;
}
if(!writable)
{
throw new UnauthorizedAccessException
(_("IO_RegistryReadOnly"));
}
if(provider != null)
{
if(!provider.DeleteValue(name))
{
if(throwOnMissingValue)
{
throw new
ArgumentException
(_("IO_RegistryKeyNotExist"));
}
}
}
else
{
throw new
IOException(_("IO_RegistryKeyClosed"));
}
}
public void DeleteValue(String name)
{
DeleteValue(name, true);
}
// Flush all modifications to this registry key.
public void Flush()
{
if(provider != null)
{
provider.Flush();
}
}
// Get the names of all subkeys underneath this registry key.
public String[] GetSubKeyNames()
{
if(provider != null)
{
return provider.GetSubKeyNames();
}
else
{
throw new
IOException(_("IO_RegistryKeyClosed"));
}
}
// Get a value from underneath this registry key.
public Object GetValue(String name, Object defaultValue)
{
if(name == null)
{
name = String.Empty;
}
if(provider != null)
{
return provider.GetValue(name,
defaultValue);
}
else
{
throw new
IOException(_("IO_RegistryKeyClosed"));
}
}
public Object GetValue(String name)
{
return GetValue(name, null);
}
// Get the names of all values underneath this registry key.
public String[] GetValueNames()
{
if(provider != null)
{
return provider.GetValueNames();
}
else
{
throw new
IOException(_("IO_RegistryKeyClosed"));
}
}
// Open a registry key for a local or remote machine.
public static RegistryKey OpenRemoteBaseKey(RegistryHive hKey,
String machineName)
{
// Validate the parameters.
if(hKey < RegistryHive.ClassesRoot ||
hKey > RegistryHive.DynData)
{
throw new
ArgumentException(_("Arg_InvalidHive"));
}
if(machineName == null)
{
throw new
ArgumentNullException("machineName");
}
else if(machineName != String.Empty)
{
// Accessing remote registries is a big
security risk.
// Always deny the request.
throw new
SecurityException(_("Invalid_RemoteRegistry"));
}
// Open the local hive.
String name = hiveNames
[((int)hKey) -
(int)(RegistryHive.ClassesRoot)];
return new RegistryKey
(Registry.GetProvider(hKey, name),
false);
}
// Open a subkey.
public RegistryKey OpenSubKey(String name, bool writable)
{
// Validate the parameters.
if(name == null)
{
throw new ArgumentNullException("name");
}
if(provider == null)
{
throw new
IOException(_("IO_RegistryKeyClosed"));
}
// Resolve the subkey to a parent and last
component.
String last;
RegistryKey parent;
parent = Resolve(this, name, false, out last);
if(parent == null)
{
return null;
}
// Open the subkey in the specified mode.
IRegistryKeyProvider key;
key = parent.provider.OpenSubKey(last,
writable);
if(key == null)
{
return null;
}
return new RegistryKey(key, writable);
}
public RegistryKey OpenSubKey(String name)
{
return OpenSubKey(name, false);
}
// Set a value under this registry key.
public void SetValue(String name, Object value)
{
if(name == null)
{
name = String.Empty;
}
if(value == null)
{
throw new
ArgumentNullException("value");
}
if(!writable)
{
throw new UnauthorizedAccessException
(_("IO_RegistryReadOnly"));
}
if(provider != null)
{
provider.SetValue(name, value);
}
else
{
throw new
IOException(_("IO_RegistryKeyClosed"));
}
}
// Get the string form of this registry key.
public override String ToString()
{
return name;
}
// Get the name of the registry key.
public String Name
{
get
{
return name;
}
}
// Get the number of subkeys underneath this key.
public int SubKeyCount
{
get
{
if(provider != null)
{
return provider.SubKeyCount;
}
else
{
throw new
IOException(_("IO_RegistryKeyClosed"));
}
}
}
// Get the number of values that are associated with this key.
public int ValueCount
{
get
{
if(provider != null)
{
return provider.ValueCount;
}
else
{
throw new
IOException(_("IO_RegistryKeyClosed"));
}
}
}
}; // class RegistryKey
#endif // !ECMA_COMPAT
}; // namespace Microsoft.Win32
--- NEW FILE ---
/*
* Win32KeyProvider.cs - Implementation of the
* "Microsoft.Win32.Win32KeyProvider" class.
*
* Copyright (C) 2003 Southern Storm Software, Pty Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
namespace Microsoft.Win32
{
#if !ECMA_COMPAT
using System;
// This class implements registry functionality for Win32 systems.
internal sealed class Win32KeyProvider : IRegistryKeyProvider
{
// Internal state.
private String name;
// Constructor.
public Win32KeyProvider(String name)
{
this.name = name;
}
// Determine if we should use the Win32 registry.
public static bool IsWin32()
{
// TODO
return false;
}
// Close a reference to this key and flush any modifications to disk.
public void Close(bool writable)
{
// TODO
}
// Create a subkey underneath this particular registry key.
public IRegistryKeyProvider CreateSubKey(String subkey)
{
// TODO
return null;
}
// Delete this key entry.
public void Delete()
{
// TODO
}
// Delete this key entry and all of its descendents.
public void DeleteTree()
{
// TODO
}
// Delete a particular value underneath this registry key.
// Returns false if the value is missing.
public bool DeleteValue(String name)
{
// TODO
return false;
}
// Flush all modifications to this registry key.
public void Flush()
{
// TODO
}
// Get the names of all subkeys underneath this registry key.
public String[] GetSubKeyNames()
{
// TODO
return null;
}
// Get a value from underneath this registry key.
public Object GetValue(String name, Object defaultValue)
{
// TODO
return defaultValue;
}
// Get the names of all values underneath this registry key.
public String[] GetValueNames()
{
// TODO
return null;
}
// Open a subkey.
public IRegistryKeyProvider OpenSubKey(String name, bool writable)
{
// TODO
return null;
}
// Set a value under this registry key.
public void SetValue(String name, Object value)
{
// TODO
}
// Get the name of this registry key provider.
public String Name
{
get
{
return name;
}
}
// Get the number of subkeys underneath this key.
public int SubKeyCount
{
get
{
return 0;
}
}
// Get the number of values that are associated with this key.
public int ValueCount
{
get
{
return 0;
}
}
}; // class Win32KeyProvider
#endif // !ECMA_COMPAT
}; // namespace Microsoft.Win32
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Dotgnu-pnet-commits] CVS: pnetlib/runtime/Microsoft/Win32 IRegistryKeyProvider.cs,NONE,1.1 MemoryKeyProvider.cs,NONE,1.1 Registry.cs,NONE,1.1 RegistryHive.cs,NONE,1.1 RegistryKey.cs,NONE,1.1 Win32KeyProvider.cs,NONE,1.1,
Rhys Weatherley <address@hidden> <=