What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » [HELP] Reading Reg Keys

[HELP] Reading Reg Keys
Author: Message:
noroom
Full Member
***

Avatar
www.noroom.tk

Posts: 107
Reputation: 4
Joined: Sep 2003
O.P. [HELP] Reading Reg Keys
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.
07-08-2006 03:55 PM
Profile E-Mail PM Find Quote Report
J-Thread
Full Member
***

Avatar

Posts: 467
Reputation: 8
– / Male / –
Joined: Jul 2004
RE: [HELP] Reading Reg Keys
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);

07-08-2006 04:10 PM
Profile E-Mail PM Find Quote Report
hmaster
Senior Member
****

Avatar

Posts: 716
Reputation: 24
33 / Male / Flag
Joined: Nov 2004
RE: [HELP] Reading Reg Keys
Erm doesnt "\\Path" have to be without the speech marks and capital letter:
code:
var test = Shell.RegRead(keys[0]+"\\" + path);

This post was edited on 07-08-2006 at 04:12 PM by hmaster.
[Image: sig.png]
07-08-2006 04:11 PM
Profile PM Web Find Quote Report
noroom
Full Member
***

Avatar
www.noroom.tk

Posts: 107
Reputation: 4
Joined: Sep 2003
O.P. RE: [HELP] Reading Reg Keys
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.
07-08-2006 06:20 PM
Profile E-Mail PM Find Quote Report
foaly
Senior Member
****

Avatar

Posts: 718
Reputation: 20
38 / Male / Flag
Joined: Jul 2006
RE: [HELP] Reading Reg Keys
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);

07-08-2006 06:27 PM
Profile E-Mail PM Find Quote Report
noroom
Full Member
***

Avatar
www.noroom.tk

Posts: 107
Reputation: 4
Joined: Sep 2003
O.P. RE: [HELP] Reading Reg Keys
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. =/
07-08-2006 06:38 PM
Profile E-Mail PM Find Quote Report
foaly
Senior Member
****

Avatar

Posts: 718
Reputation: 20
38 / Male / Flag
Joined: Jul 2006
RE: [HELP] Reading Reg Keys
what about making it a string? like:
code:
var test =new String(""+Shell.RegRead(keys[0]+"\\Path"));

07-08-2006 06:44 PM
Profile E-Mail PM Find Quote Report
noroom
Full Member
***

Avatar
www.noroom.tk

Posts: 107
Reputation: 4
Joined: Sep 2003
O.P. RE: [HELP] Reading Reg Keys
That returns an empty String.
07-08-2006 07:58 PM
Profile E-Mail PM Find Quote Report
J-Thread
Full Member
***

Avatar

Posts: 467
Reputation: 8
– / Male / –
Joined: Jul 2004
RE: [HELP] Reading Reg Keys
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);
07-08-2006 08:16 PM
Profile E-Mail PM Find Quote Report
noroom
Full Member
***

Avatar
www.noroom.tk

Posts: 107
Reputation: 4
Joined: Sep 2003
O.P. RE: [HELP] Reading Reg Keys
Thanks J-Thread, that did it! (Y) I didn't know a VBArray was a datatype.
07-09-2006 11:11 AM
Profile E-Mail PM Find Quote Report
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On