zoukankan      html  css  js  c++  java
  • 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);

  • 相关阅读:
    20145213《Java程序设计》第二周学习总结
    20145213《Java程序设计》第一周学习总结
    对于老师问卷调查中若干问题的回答
    问卷调查
    关于矩阵的分解的专题讨论
    关于合同变换的专题讨论
    关于初等变换的专题讨论
    关于矩阵的迹的专题讨论
    关于矩阵的秩的专题讨论
    关于含参变量反常积分一致收敛的专题讨论
  • 原文地址:https://www.cnblogs.com/jcleung/p/1435382.html
Copyright © 2011-2022 走看看