GetValue() function is not retieving the value associated with the specified key from the registry using C#

  • Thread starter Thread starter aditya satya prakash
  • Start date Start date
A

aditya satya prakash

Guest
Hi All,

I am using the below function to retrieve the value associated with the specified key from the registry. Even though the value associated with the name is present in the registry, it is not returning any value.

Below is my code snippet:

public object GetRegKeyValue(String attribute,RegistryKey rKey)
{
string value = string.Empty;
object tmpObject = null;

if (rKey != null)
{
tmpObject = rKey.GetValue(attribute);

value = tmpObject as string;

if (value == null)
{
return tmpObject;
}
}
return value;
}

Is my GetRegKeyValue function is correct?

Do I need to typecaset "rkey.GetValue(attribute)" with "object" like as shown below?


tmpObject = (object)rKey.GetValue(attribute);



Y A S Prakash

Continue reading...
 
Back
Top