quote:
Originally posted by Matti
quote:
Originally posted by CookieRevised
You don't need to read it as a REG_BINARY if that binary string represents a DWORD (4 bytes). Just read it as a REG_DWORD in that case.
As such, a full blown registry libary for just checking 1 value is also very much over the top. Reading that registry key can also be done using the build-in regkey functions.
I fully agree with you, but the RegRead function provided by WScript.Shell will return a VBArray of integers when reading from a REG_BINARY. It doesn't provide a way to override how the value is read, thus one will need to fall back on the Windows API functions to read as a different type. I don't know how a VBArray would look like in JScript though but it doesn't sound too great.
Correct though (I forgot there was no second parameter to specify the type when you read a key). However, there is nothing difficult about a VBArray. In fact using
toArray() is all it takes to convert it.
js code:
try {
var oShell = new ActiveXObject("WScript.Shell");
var bTabsEnabled = oShell.RegRead("HKCU\\Software\\Microsoft\\MSNMessenger\\PerPassportSettings\\" + Messenger.MyUserID + "\\DisableTabs");
bTabsEnabled = new Boolean(bTabsEnabled.toArray().join(""));
} catch(e) {
var bTabsEnabled = false;
}
the join is just a trick to join all 'integers' elements together like a string to form one number (it doesn't matter what the joined value would be, since we're only interested in true or false, or "0000" or not "0000".
Note that new Boolean(bTabsEnabled.toArray()[0]) could also be used, but then again, that wont work when the binary value would be something like '00 00 33 00'.