UnauthorizedAccessException in ComRegisterFunction when accessing registry on Win 7 64.
Posted
by sanbornc
on Stack Overflow
See other posts from Stack Overflow
or by sanbornc
Published on 2010-03-12T19:30:40Z
Indexed on
2010/03/12
19:37 UTC
Read the original article
Hit count: 282
I have a [ComRegisterFunction] that I am using to register a BHO Internet explorer extension. During registration on 64-bit windows 7 machines, a UnauthorizedAccessException is thrown on the call to subKey.SetValue("NoExplorer", 1).
The registry appears to have BHO's located @ \HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\explorer\Browser Helper Objects, however, I get them same exception when trying to register there. Any Help would be appreciated.
[ComRegisterFunction]
public static void RegisterBho(Type type) {
string BhoKeyName= "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Browser Helper Objects";
RegistryKey registryKey = Registry.LocalMachine.OpenSubKey(BhoKeyName, true) ??
Registry.LocalMachine.CreateSubKey(BhoKeyName);
if(registryKey == null) throw new ApplicationException("Unable to register Bho");
registryKey.Flush();
string guid = type.GUID.ToString("B");
RegistryKey subKey = registryKey.OpenSubKey(guid) ?? registryKey.CreateSubKey(guid);
if (subKey == null) throw new ApplicationException("Unable to register Bho");
subKey.SetValue("NoExplorer", 1);
registryKey.Close();
subKey.Close();
}
© Stack Overflow or respective owner