创建一个主键,子键或值项.
RegWrite ( "键名" [,"值项" [, "类型" [, 数据]]] )
键名 | 要写入的注册表键.若其它参数未指定则只创建该键. |
值项 | [可选参数] 要写入的值名. |
类型 | [可选参数] 目标值项的数据类型,比如:"REG_SZ","REG_MULTI_SZ","REG_EXPAND_SZ","REG_DWORD" , "REG_QWORD" 或 "REG_BINARY". |
数据 | [可选参数] 数值数据. |
成功: | 返回值为 1. |
失败: | 返回值为 0,写入注册表键或者值发生错误. |
@error 将设为以下值之一 | |
1 如果不能打开被请求的键 | |
2 如果不能打开被请求的主键 | |
3 如果不能远程连接到注册表 | |
-1 如果不能打开被请求的值 | |
-2 如果值的类型是不支持的 |
; Write a single REG_SZ value
RegWrite("HKEY_CURRENT_USER\Software\Test", "TestKey", "REG_SZ", "Hello this is a test")
; Write the REG_MULTI_SZ value of "line1" and "line2"
RegWrite("HKEY_CURRENT_USER\Software\Test", "TestKey1", "REG_MULTI_SZ", "line1" & @LF & "line2")
; Write the REG_MULTI_SZ value of "line1"
RegWrite("HKEY_CURRENT_USER\Software\Test", "TestKey2", "REG_MULTI_SZ", "line1")
; always add and extra null string
RegWrite("HKEY_CURRENT_USER\Software\Test", "TestKey3", "REG_MULTI_SZ", "line1" & @LF & "line2" & @LF)
RegWrite("HKEY_CURRENT_USER\Software\Test", "TestKey4", "REG_MULTI_SZ", "line1" & @LF & @LF & "line2" & @LF)
; empty REG_MULTI_SZ
RegWrite("HKEY_CURRENT_USER\Software\Test", "TestKey5", "REG_MULTI_SZ", "")
; create just the key
RegWrite("HKEY_CURRENT_USER\Software\Test1")