質問

私は[ComRegisterFunction]私はBHOインターネットエクスプローラの拡張子を登録するには使用していていることがあります。 64ビットのWindows 7マシン、UnauthorizedAccessExceptionに登録中 subKey.SetValueへの呼び出し( "NoExplorer"、1)にスローされます。

レジストリは、\ HKLM \ SOFTWARE \ WOW6432NODE \マイクロソフト\ Windowsの\ CurrentVersionの\ Explorerの\ブラウザヘルパーオブジェクト@ BHOのに位置しているように見えますが登録しようとした場合には、しかし、私は彼らに同じ例外を取得します。任意の助けいただければ幸います。

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

}
役に立ちましたか?

解決 2

それを考え出しました。私はそれを動作させるために、以下を追加する必要がありました。それは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);

他のヒント

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

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top