簡體   English   中英

Windows XP:從IE寫入注冊表?

[英]Windows XP: where to write to registry from IE?

我需要從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中首次添加的

在Vista之前,您將不得不使用其他方法...在BHO的安裝過程中,您需要告訴Windows / IE您想從BHO寫入哪些密鑰...

有一個完整的API系列可以處理此問題(WinXP SP2以及MSDN都支持):

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM