Bug in Microsoft.Win32.RegistryKey.GetValue

  • Thread starter Thread starter charles
  • Start date Start date
C

charles

RegistryKey.GetValue does not work if you access
HKEY_PERFORMANCE_DATA on a remote machine, e.g.:

RegistryKey perfKey = RegistryKey.OpenRemoteBaseKey
(RegistryHive.PerformanceData, "machinename");
byte[] perfData = (byte[])perfKey.GetValue("Global");

This never returns any data, i.e. perfData is always null.

This happens because RegistryKey.InternalGetValue treats
performance data as a special case. The test is something
like:

if (this.hKey == HKEY_PERFORMANCE_DATA)
// Do special case

Of course, this test only succeeds for local performance
data, not remote performance data.

A workaround for this and a fix in the next release would
be very much appreciated.

Cheers,
Charles

P.S. I'm posting this again because I've registered since
I last posted it.
 
Hi Charles,

Thanks for your post. I reproduced the problem on my side, and I will need
some time to research this issue.

Have a nice day! :-)

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Hello Charles,

I contacted our Developer Team and it seems to be an issue in the
RegistryKey.GetValue for HKEY_PERFORMANCE_DATA. To work around this
problem, we can use P/Invoke to directly call Win32 registry APIs directly.
I belive the following MSDN article is helpful:

Consuming Unmanaged DLL Functions
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/htm
l/cpconconsumingunmanageddllfunctions.asp

Hope this helps.

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Hi,

Thanks for the info. P/Invoke works fine. A fix in a
later release would be splendid.

Cheers,
Charles
 
Back
Top