0

BHOInternetExplorer拡張機能の登録に使用している[ComRegisterFunction]があります。64ビットWindows7マシンでの登録中に、subKey.SetValue( "NoExplorer"、1)の呼び出しでUnauthorizedAccessExceptionがスローされます。

レジストリにはBHOが@\HKLM \ SOFTWARE \ Wow6432Node \ Microsoft \ Windows \ CurrentVersion \ explorer \ Browser Helper Objectsにあるように見えますが、そこに登録しようとすると同じ例外が発生します。どんな助けでもいただければ幸いです。

[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();

}
4

2 に答える 2

0

管理者権限で実行する必要があります。

于 2010-03-12T19:35:44.943 に答える
0

理解した。私はそれを機能させるために以下を追加しなければなりませんでした。他のバージョンのOSで機能した理由がわからない

RegistrySecurity rs = new RegistrySecurity();

rs.AddAccessRule(new RegistryAccessRule(user,
            RegistryRights.FullControl,
            InheritanceFlags.ObjectInherit,
            PropagationFlags.InheritOnly,
            AccessControlType.Allow));

RegistryKey subKey = registryKey.OpenSubKey(guid) ??    registryKey.CreateSubKey(guid, RegistryKeyPermissionCheck.Default, rs);
于 2010-03-12T20:29:06.363 に答える