;
; Author: FiberOPtics -- mirc.fiberoptics@gmail.com
;
; Usage: $regread(<path to key> [,exportfile])[.hex]
;
; Notes: - Reads the value of a registry key, and returns it to mIRC through the identifier,
; or exports the result to a file when specified. The reason for this is to be able
; to access values which exceed the string too long limit.
;
; - When specifying a file, it must only include the complete filepath when you want
; to save the file somewhere else than the main mIRC folder. The specified file will
; be created if it doesn't exist, else it is overwritten. $regread will return $true
; if the file contains a result, $false if it is empty.
;
; - In contrary to other $regread snippets that also use COM, this snippet can read
; REG_BINARY/REG_MULTI_SZ values. That's because those values are returned in a VBarray,
; which this snippet can handle.
;
; - The .hex property can only be used on REG_BINARY or REG_MULTI_SZ values, and
; will convert every parameter in the array to hex.
;
;
; Requirement: mIRC 5.91 and Windows ME or higher
;
;
; Installment: The snippet goes into the remote section because of its alias prefix.
; Alt+r -> tab "Remote" -> Paste there.
; You can also put it in the aliases section, provided you remove the alias prefix.
;
;
; Registry: HKEY_CLASSES_ROOT (HKCR)
; HKEY_CURRENT_USER (HKCU)
; HKEY_LOCAL_MACHINE (HKLM)
; HKEY_USERS
; HKEY_CURRENT_CONFIG
; HKEY_DYN_DATA
;
; For more info about the registry check:
; http://www.winguides.com/article.php?id=1&page=2&guide=registry
;
;
; Examples: REG_EXPAND_SZ - $regread(HKCR\txtfile\)
; REG_SZ - $regread(HKCU\software\mirc\lastrun\)
; REG_MULTI_SZ - $regread(HKLM\system\setup\clonetag)
; REG_DWORD - $regread(HKLM\software\microsoft\windows\currentversion\installtime)
; REG_BINARY - $regread(HKEY_USERS\.default\control panel\desktop\userpreferencesmask).hex
;
; //if ($regread(HKCU\control panel\appearance\customcolors,reg.txt)) run reg.txt
;
; Note that the above examples are only examples, they won't necessarily exist on your system.
;
alias regread {
var %e = return $+($chr(3),$color(info),$!regread:), %result, %t, %n = $crlf
if (!$isid) return
if ($istok(95 98,$os,32)) %e this snippet requires Windows ME or higher.
if (* !iswm $1) %e you didn't specify a path to a registry key.
if ($prop) && ($prop != hex) %e the only available property is .hex
if ($2) {
var %dir = $nofile($2), %file = $nopath($2)
if (%file != $mkfn(%file)) %e file %file contains illegal characters.
if (* !iswm %dir) %dir = $mircdir
elseif (!$isdir(%dir)) %e no such folder %dir
%t = $&
set fso = createobject("scripting.filesystemobject") %n $&
set file = fso.createtextfile(" $+ $2",true) %n $&
file.write tmp %n $&
file.close
}
var %mss = $+(mss,$ticks,$r(1111,9999))
.comopen %mss MSScriptControl.ScriptControl
if ($comerr) %e Error opening ScriptControl object.
!.echo -q $com(%mss,language,4,bstr*,vbscript)
%t = $&
set objshell = createobject("wscript.shell") %n $&
result = objshell.regread(" $+ $1 $+ ") %n $&
If (isarray(result)) then %n $&
For each param in result %n $&
tmp = tmp & $iif($prop == hex,hex(param),param) & " " %n $&
Next %n $&
Else tmp = result %n $&
End If %n %t
%t = $com(%mss,executestatement,1,bstr*,%t)
if ($2) %result = $iif($file($2),$true,$false)
else %result = $(,,$com(%mss,eval,3,bstr*,tmp)) $com(%mss).result
:error
if ($com(%mss)) .comclose %mss
return %result
}