Depending on what value type is stored, I have to use one of the following methods:
GetBinaryValue
GetDWORDValue
GetExpandedStringValue
GetMultiStringValue
GetStringValue
I would like not to have to try all five if all I know about a value is the hive, the key, and the value name. Is there a way to do that? I'm using WMI, but if the only way is by using the advapi32.dll method, I'm open to that.
You can use the
StdRegProv.EnumValues
method to enumerate values of the key, find out the type of your value and determine whichGet
method to call.Something like this (sorry, I don't know C# well so this code is probably far from perfect):
How about OpenRemoteBaseKey, and then GetValue()? http://msdn.microsoft.com/en-us/library/8zha3xws(VS.100).aspx