Shoutbox

[HELP] Reading Reg Keys - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Thread: [HELP] Reading Reg Keys (/showthread.php?tid=62826)

[HELP] Reading Reg Keys by noroom on 07-08-2006 at 03:55 PM

I'm trying to read a REG_BINARY registry key, and it just won't work.

This is the key I'm trying to read:
HKEY_CURRENT_USER\Software\Microsoft\MSNMessenger\PerPassportSettings\<NUMBER>\Sounds\MSNMSGR_Buzz\Path

And this is the code I'm using:

   

quote:
var Shell = new ActiveXObject("WScript.Shell");
   
    var path = "HKCU\\Software\\Microsoft\\MSNMessenger\\PerPassportSettings\\" + Messenger.MyUserId + "\\Sounds\\MSNMSGR_";
    var keys = Array(path+"Buzz");

        var enabled = Shell.RegRead(keys[0]+"\\Enabled");
        var test = Shell.RegRead(keys[0]+"\\Path");
       
        Debug.Trace("Path: " + test + " E: " + enabled);

"Enabled" works just fine, but Path doesn't. I found out that after trying to read that key, the typeof test is "unknown" as opposed to "undefined". I think that means it does contain some information. Help?

(Ignore the Array() part, I cut if off because it's not necessary to find/fix the problem)

Dear god, please make someone fix the code tags so indentation is preserved.
RE: [HELP] Reading Reg Keys by J-Thread on 07-08-2006 at 04:10 PM

The MSDN says the function should return an array of numbers when you read a "REG_BINARY" value.

Try debugging like this:

code:
Debug.Trace("Path: ");
Debug.Trace(test);
Debug.Trace(" E: " + enabled);


RE: [HELP] Reading Reg Keys by hmaster on 07-08-2006 at 04:11 PM

Erm doesnt "\\Path" have to be without the speech marks and capital letter:

code:
var test = Shell.RegRead(keys[0]+"\\" + path);

RE: [HELP] Reading Reg Keys by noroom on 07-08-2006 at 06:20 PM

quote:
Originally posted by J-Thread
The MSDN says the function should return an array of numbers when you read a "REG_BINARY" value.
Correct. I tried treating the variable as an array, but it doesn't work. It's not an array.

Debugging like that brings up a type mismatch. Makes sense too, a variable of type "unknown" is not a String.

quote:
Originally posted by hmaster
Erm doesnt "\\Path" have to be without the speech marks and capital letter
No. Path is the name of the key I'm trying to get the value of. Just like Enabled is the name of the other key.
RE: [HELP] Reading Reg Keys by foaly on 07-08-2006 at 06:27 PM

did you try if test really works? like:

code:
try{
var test = Shell.RegRead(keys[0]+"\\Path");
}catch(err){Debug.Trace("error in var test")}

Debug.Trace("Path: " + test + " E: " + enabled);


RE: [HELP] Reading Reg Keys by noroom on 07-08-2006 at 06:38 PM

Yes, it works. There's no exception being thrown, which means the key is there, and it's being accessed and read.

I am convinced that test somehow contains something. I just don't know how to read it. =/


RE: [HELP] Reading Reg Keys by foaly on 07-08-2006 at 06:44 PM

what about making it a string? like:

code:
var test =new String(""+Shell.RegRead(keys[0]+"\\Path"));


RE: [HELP] Reading Reg Keys by noroom on 07-08-2006 at 07:58 PM

That returns an empty String.


RE: [HELP] Reading Reg Keys by J-Thread on 07-08-2006 at 08:16 PM

The function returns a VBArray. Use the toArray() function to get a regular array:

code:
var Shell = new ActiveXObject("WScript.Shell");

var path = "HKCU\\Software\\Microsoft\\MSNMessenger\\PerPassportSettings\\" + Messenger.MyUserId + "\\Sounds\\MSNMSGR_";
var keys = Array(path+"Buzz");

var enabled = Shell.RegRead(keys[0]+"\\Enabled");
var test = Shell.RegRead(keys[0]+"\\Path");

Debug.Trace("Path: " + test.toArray() + " E: " + enabled);

RE: [HELP] Reading Reg Keys by noroom on 07-09-2006 at 11:11 AM

Thanks J-Thread, that did it! (Y) I didn't know a VBArray was a datatype.