使用VB SCRIPT读取注册表键值

时间:2015-07-28 06:09:52

标签: search plugins vbscript

我在注册表中存储了一个网站。例如:

  1. SOFTWARE\Microsoft\Internet Explorer\Default Website

  2. 键名:Website

  3. 键值:www.google.com/

  4. 然后我尝试在IE中创建搜索插件。 以下是我用于此的代码。当我对其进行硬编码时,它适用于Google, 但我想使用注册表值来设置此变量。

    <html>
    <script language="VBSCRIPT">
    
        set parentwin = external.menuArguments
        str = trim(parentwin.document.selection.createRange().text)
        bnewwindow = parentwin.event.shiftKey
    
        defaultWebsite = ????????
    
        url = defaultWebsite +"search?q=" + escape(str)
    
        if(bnewwindow) then
            window.open(url)
        else
            parentwin.window.navigate(url)
        end if
    
    </script>
    </html>
    

1 个答案:

答案 0 :(得分:0)

You can use the Shell object to read and write registry values. You may get a warning in Internet Explorer when trying to instantiate an ActiveX control, since this requires access to the client PC.

' This uses HKCU. Change to HKLM, if you need.
Dim strKey = "HKCU\Software\Microsoft\Internet Explorer\Default Website\Website"

With CreateObject("WScript.Shell")
    defaultWebsite = .RegRead(strKey)
End With