[color:green]; Reads key from registry
; Syntax:
; $regread(<key>)
; if an error occurs returns ERROR, otherwise
; OK <data>
; To retrieve a key's data, the key needs to end with a backslash. You should
; not include a backslash if you want to read a value's data
; You can use the short names for registry hives, for example
; HKCR instead of HKEY_CLASSES_ROOT[/color]
alias regread {
var %a = regread $+ $ticks
.comopen %a WScript.Shell
if $comerr { return ERROR }
if !$com(%a,RegRead,3,bstr,$1) {
.comclose %a
return ERROR
}
var %b = $com(%a).result
.comclose %a
return OK %b
}
[color:green]; Writes to the registry
; Syntax
; $regwrite(<key>/<value>,<data>,[type])
; [type] can be
; d, for REG_DWORD
; b, for REG_BINARY
; anything else (or nothing), for REG_SZ
; returns 1 if the operation was successful, otherwise 0
; Example: $regwrite(HKEY_CURRENT_USER\MyKey\,This is the key's data,s)
; Example: $regwrite(HKCU\MyKey\MyDwordValue,5,d)[/color]
alias regwrite {
var %a = regwrite $+ $ticks
.comopen %a WScript.Shell
if $comerr { return 0 }
if d isin $3 { var %3 = REG_DWORD, %type = ui4 }
elseif b isin $3 { var %3 = REG_BINARY, %type = ui4 }
else { var %3 = REG_SZ, %type = bstr }
if $com(%a,RegWrite,3,bstr,$1,%type,$2,bstr,%3) {
.comclose %a
return 1
}
.comclose %a
return 0
}