public bool SetRegistryKey(Microsoft.Win32.RegistryKey regHive, string regKey, string regName, string regValue)
{
bool response = false;
Microsoft.Win32.RegistryKey key = regHive.OpenSubKey(regKey);
if (key == null)
{
regHive.CreateSubKey(regKey, Microsoft.Win32.RegistryKeyPermissionCheck.ReadWriteSubTree);
}
key = regHive.OpenSubKey(regKey,true);
key.SetValue(regName, (string)regValue);
//regHive.Flush(); //Try not to use Flush(): http://msdn2.microsoft.com/en-us/library/microsoft.win32.registrykey.flush.aspx
response = true;
return response;
}
No comments:
Post a Comment
Please use your common sense before making a comment, and I truly appreciate your constructive criticisms.