Author: robertj
Date: 2006-01-18 09:11:54 -0500 (Wed, 18 Jan 2006)
New Revision: 55722
Modified:
branches/mono-1-1-13/mcs/class/corlib/Microsoft.Win32/ChangeLog
branches/mono-1-1-13/mcs/class/corlib/Microsoft.Win32/RegistryKey.cs
branches/mono-1-1-13/mcs/class/corlib/Microsoft.Win32/Win32RegistryApi.cs
Log:
Merged from HEAD r55719:55720
Modified: branches/mono-1-1-13/mcs/class/corlib/Microsoft.Win32/ChangeLog
===================================================================
--- branches/mono-1-1-13/mcs/class/corlib/Microsoft.Win32/ChangeLog
2006-01-18 14:07:14 UTC (rev 55721)
+++ branches/mono-1-1-13/mcs/class/corlib/Microsoft.Win32/ChangeLog
2006-01-18 14:11:54 UTC (rev 55722)
@@ -1,3 +1,10 @@
+2006-01-14 Robert Jordan <[EMAIL PROTECTED]>
+
+ * RegistryKey.cs: Added internal IsRoot accessor.
+ * Win32RegistryApi.cs: Fixed access to RegistryKey.Data.
+ Fixes bug #77212. Thanks to Don Edvalson ([EMAIL PROTECTED])
+ for spotting this out.
+
2005-12-02 Atsushi Enomoto <[EMAIL PROTECTED]>
* Win32RegistryApi.cs : fixed invalid cast. Now mono is not to blame
Modified: branches/mono-1-1-13/mcs/class/corlib/Microsoft.Win32/RegistryKey.cs
===================================================================
--- branches/mono-1-1-13/mcs/class/corlib/Microsoft.Win32/RegistryKey.cs
2006-01-18 14:07:14 UTC (rev 55721)
+++ branches/mono-1-1-13/mcs/class/corlib/Microsoft.Win32/RegistryKey.cs
2006-01-18 14:11:54 UTC (rev 55722)
@@ -52,6 +52,10 @@
string qname; // the fully qualified registry key name
bool isRoot; // is the an instance of a root key?
+
+ internal bool IsRoot {
+ get { return isRoot; }
+ }
static readonly IRegistryApi RegistryApi;
Modified:
branches/mono-1-1-13/mcs/class/corlib/Microsoft.Win32/Win32RegistryApi.cs
===================================================================
--- branches/mono-1-1-13/mcs/class/corlib/Microsoft.Win32/Win32RegistryApi.cs
2006-01-18 14:07:14 UTC (rev 55721)
+++ branches/mono-1-1-13/mcs/class/corlib/Microsoft.Win32/Win32RegistryApi.cs
2006-01-18 14:11:54 UTC (rev 55722)
@@ -129,6 +129,13 @@
string valueName, IntPtr reserved, ref
RegistryType type,
ref int data, ref int dataSize);
+ // Returns our handle from the RegistryKey
+ static IntPtr GetHandle (RegistryKey key)
+ {
+ return key.IsRoot ? new IntPtr ((int) key.Data)
+ : (IntPtr) key.Data;
+ }
+
/// <summary>
/// Acctually read a registry value. Requires knoledge of
the
/// value's type and size.
@@ -138,7 +145,7 @@
RegistryType type = 0;
int size = 0;
object obj = null;
- IntPtr handle = (IntPtr)rkey.Data;
+ IntPtr handle = GetHandle (rkey);
int result = RegQueryValueEx (handle, name,
IntPtr.Zero, ref type, IntPtr.Zero, ref size);
if (result == Win32ResultCode.FileNotFound) {
@@ -190,7 +197,7 @@
{
Type type = value.GetType ();
int result;
- IntPtr handle = (IntPtr)rkey.Data;
+ IntPtr handle = GetHandle (rkey);
if (type == typeof (int)) {
int rawValue = (int)value;
@@ -232,7 +239,7 @@
private int GetBinaryValue (RegistryKey rkey, string name,
RegistryType type, out byte[] data, int size)
{
byte[] internalData = new byte [size];
- IntPtr handle = (IntPtr)rkey.Data;
+ IntPtr handle = GetHandle (rkey);
int result = RegQueryValueEx (handle, name,
IntPtr.Zero, ref type, internalData, ref size);
data = internalData;
return result;
@@ -248,7 +255,7 @@
{
int index, result;
byte[] stringBuffer = new byte [BufferMaxLength];
- IntPtr handle = (IntPtr)rkey.Data;
+ IntPtr handle = GetHandle (rkey);
for (index = 0; true; index ++) {
result = RegEnumKey (handle, index,
stringBuffer, BufferMaxLength);
@@ -271,7 +278,7 @@
RegistryType type;
StringBuilder buffer = new StringBuilder
(BufferMaxLength);
- IntPtr handle = (IntPtr)rkey.Data;
+ IntPtr handle = GetHandle (rkey);
for (index = 0; true; index ++) {
type = 0;
bufferCapacity = buffer.Capacity;
@@ -296,7 +303,7 @@
{
int access = OpenRegKeyRead;
if (writtable) access |= OpenRegKeyWrite;
- IntPtr handle = new IntPtr ((int) rkey.Data);
+ IntPtr handle = GetHandle (rkey);
IntPtr subKeyHandle;
int result = RegOpenKeyEx (handle, keyName,
IntPtr.Zero, access, out subKeyHandle);
@@ -312,19 +319,19 @@
public void Flush (RegistryKey rkey)
{
- IntPtr handle = (IntPtr)rkey.Data;
+ IntPtr handle = GetHandle (rkey);
RegFlushKey (handle);
}
public void Close (RegistryKey rkey)
{
- IntPtr handle = (IntPtr)rkey.Data;
+ IntPtr handle = GetHandle (rkey);
RegCloseKey (handle);
}
public RegistryKey CreateSubKey (RegistryKey rkey, string
keyName)
{
- IntPtr handle = (IntPtr)rkey.Data;
+ IntPtr handle = GetHandle (rkey);
IntPtr subKeyHandle;
int result = RegCreateKey (handle , keyName, out
subKeyHandle);
@@ -339,7 +346,7 @@
public void DeleteKey (RegistryKey rkey, string keyName, bool
shouldThrowWhenKeyMissing)
{
- IntPtr handle = (IntPtr)rkey.Data;
+ IntPtr handle = GetHandle (rkey);
int result = RegDeleteKey (handle, keyName);
if (result == Win32ResultCode.FileNotFound) {
@@ -354,7 +361,7 @@
public void DeleteValue (RegistryKey rkey, string value, bool
shouldThrowWhenKeyMissing)
{
- IntPtr handle = (IntPtr)rkey.Data;
+ IntPtr handle = GetHandle (rkey);
int result = RegDeleteValue (handle, value);
if (result == Win32ResultCode.FileNotFound){
@@ -369,7 +376,7 @@
public string [] GetSubKeyNames (RegistryKey rkey)
{
- IntPtr handle = (IntPtr)rkey.Data;
+ IntPtr handle = GetHandle (rkey);
byte[] buffer = new byte [BufferMaxLength];
int bufferCapacity = BufferMaxLength;
ArrayList keys = new ArrayList ();
@@ -394,7 +401,7 @@
public string [] GetValueNames (RegistryKey rkey)
{
- IntPtr handle = (IntPtr)rkey.Data;
+ IntPtr handle = GetHandle (rkey);
ArrayList values = new ArrayList ();
for (int index = 0; true; index ++)
@@ -441,7 +448,7 @@
public string ToString (RegistryKey rkey)
{
- IntPtr handle = (IntPtr)rkey.Data;
+ IntPtr handle = GetHandle (rkey);
return String.Format ("{0} [0x{1:X}]", rkey.Name,
handle.ToInt32 ());
}
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches