Following sample code can be used to get RegisteryKey value based on keyPath and KeyName
public static String GetRegistryValue(String regKeyPath, String regKeyName)
{public static String GetRegistryValue(String regKeyPath, String regKeyName)
// Create value variablestring regValue = null;
try{
// Opening the registry keyRegistryKey rk = Registry.LocalMachine;
// Open a subKey as read-onlyRegistryKey regKey = rk.OpenSubKey(regKeyPath, RegistryKeyPermissionCheck.ReadSubTree, System.Security.AccessControl.RegistryRights.FullControl);
// If the RegistrySubKey does existif (regKey != null){
// If the RegistryKey exists get its value or null is returned.regValue = (string)regKey.GetValue(regKeyName.ToUpper());}
return regValue;}
catch (Exception ex){
throw ex;}
}
Comments
Post a Comment