1

我需要从我的 BHO 读取/写入 Windows 注册表中的一些信息。在 Windows Vista/7 上,我在 HKEY_CURRENT_USER\Software\AppDataLow\Software 下创建了一个新密钥。即使在保护模式下,这也可以正常工作。

但是,它不适用于 XP。我试图将注册表更改为 HKEY_CURRENT_USER\Software\Classes\Software 或 HKEY_CURRENT_USER\Software,没有运气。

BHO 在 Windows XP 上使用的正确注册表项是什么?

IEGetWriteableHKCU 在 Windows XP 上不存在,它最初是在Windows Vista中添加的

4

2 回答 2

4

在 Vista 之前,您将不得不使用不同的方法...在安装 BHO 期间,您需要告诉 Windows/IE 您希望从 BHO 中写入哪些密钥...

有一个完整的 API 系列来处理这个问题(根据 MSDN 支持 WinXP SP2 及更高版本):

于 2012-02-28T18:57:21.603 回答
3

IE 7,8,9,(desktop)10 在“保护模式”下运行选项卡,这将注册表写入限制为特殊的“可写”部分。您需要向 IE 询问指向它的指针。

(C#)

// C# PInvoke declaration for needed IE method.
[DllImport("ieframe.dll")]
public static extern int IEGetWriteableHKCU(ref IntPtr phKey); 

// ...
        // somewhere inside other method:
        IntPtr phKey = new IntPtr();
        var answer = IEGetWriteableHKCU(ref phKey);
        RegistryKey writeable_registry = RegistryKey.FromHandle(
            new Microsoft.Win32.SafeHandles.SafeRegistryHandle(phKey, true)
        );
        RegistryKey registryKey = writeable_registry.OpenSubKey(RegistryPathString, true);
        if (registryKey == null) {
            registryKey = writeable_registry.CreateSubKey(RegistryPathString);
        }
        registryKey.SetValue("Mode", mode);
        writeable_registry.Close();

看:

关于保护模式: http: //www.codeproject.com/Articles/18866/A-Developer-s-Survival-Guide-to-IE-Protected-Mode

关于增强保护模式:http: //blogs.msdn.com/b/ieinternals/archive/2012/03/23/understanding-ie10-enhanced-protected-mode-network-security-addons-cookies-metro-desktop.aspx

于 2012-10-17T15:46:10.667 回答