JScript中的注册表操作

JScript中WScipt.Shell对象有三个关于注册表操作的函数,即RegRead,RegWrite和RegDelete.(以下内容摘自MSDN,另外我加上了一些示例和注释)

1,RegRead

Returns the value of a key or value-name from the registry.

object.RegRead(strName) 
Arguments
object

WshShell object.

strName

String value indicating the key or value-name whose value you want.

 Remarks

The RegRead method returns values of the following five types.

 

Type

Description

In the Form of

REG_SZ

A string

A string

REG_DWORD

A number

An integer

REG_BINARY

A binary value

A VBArray of integers

REG_EXPAND_SZ

An expandable string (e.g., "%windir%\\calc.exe")

A string

REG_MULTI_SZ

An array of strings

A VBArray of strings

You can specify a key-name by ending strName with a final backslash. Do not include a final backslash to specify a value-name. A value entry has three parts: its name, its data type, and its value. When you specify a key-name (as opposed to a value-name), RegRead returns the default value. To read a key's default value, specify the name of the key itself. Fully qualified key-names and value-names begin with a root key. You may use abbreviated versions of root key names with the RegRead method. The five possible root keys are listed in the following table.

Root key Name

Abbreviation

HKEY_CURRENT_USER

HKCU

HKEY_LOCAL_MACHINE

HKLM

HKEY_CLASSES_ROOT

HKCR

HKEY_USERS

HKEY_USERS

HKEY_CURRENT_CONFIG

HKEY_CURRENT_CONFIG

示例:

var shell = new ActiveXObject("WScript.Shell");    
//If the value name or key name does not exist,then an exception will throwed!
var key1 = shell.RegRead("HKEY_CURRENT_USER\\Liang\\bvalue");//suppose bvalue is of type REG_BINARY
var array1=new VBArray(key1);
var array=array1.toArray();
var msg="";
for(var i=0;i<array.length;i++)
    msg += array[i].toString(16)+"  ";
WScript.Echo(msg);

转载于:https://www.cnblogs.com/jcleung/archive/2009/04/14/1435382.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值