简体   繁体   English

使用VB SCRIPT读取注册表项值

[英]registry key value read using VB SCRIPT

I store a website in the registry. 我将网站存储在注册表中。 For example: 例如:

  1. SOFTWARE\\Microsoft\\Internet Explorer\\Default Website

  2. Key name: Website 密钥名称: Website

  3. Key value: www.google.com/ 键值: www.google.com/

Then I try to create search plugin in IE. 然后,我尝试在IE中创建搜索插件。 Below is the code I use for that. 下面是我用于此的代码。 It works for Google when I hard-code it, but i want to use the registry value to set this variable. 当我对其进行硬编码时,它适用于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>

You can use the Shell object to read and write registry values. 您可以使用Shell对象读取和写入注册表值。 You may get a warning in Internet Explorer when trying to instantiate an ActiveX control, since this requires access to the client PC. 尝试实例化ActiveX控件时,您可能会在Internet Explorer中收到警告,因为这需要访问客户端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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM