What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Registry Class

Pages: (2): « First « 1 [ 2 ] Last »
Registry Class
Author: Message:
LifelesS
Full Member
***


Posts: 115
Reputation: 4
31 / Male / Flag
Joined: Dec 2006
O.P. RE: Registry Class
I can try to turn it into a class if you like:)

I think it would be VERY NICE to have a class like that. It would save the scripters a lot of work.

That and a class for using ini files for settings too, I was thinking of building it when I finished regsclass
Best Regards,
Joćo Godinho
08-03-2007 08:53 PM
Profile E-Mail PM Find Quote Report
Ezra
Veteran Member
*****

Avatar
Forgiveness is between them and God

Posts: 1960
Reputation: 31
37 / Male / Flag
Joined: Mar 2003
RE: Registry Class
quote:
Originally posted by LifelesS
I can try to turn it into a class if you like
Does it really need to be a class?

Sometimes classes can be very handy, but sometimes also over-complicate matters.

quote:
Originally posted by matty
I forgot to mention over the weekend or sometime next week I will be extending the functionality

That's great, maybe you could publicly release your class somewhere so that other scripters can easily find and use it.

Same goes for some other very good classes/functions made by other people, eg -dt-'s classes
[Image: 1-0.png]
             
08-03-2007 10:41 PM
Profile PM Web Find Quote Report
LifelesS
Full Member
***


Posts: 115
Reputation: 4
31 / Male / Flag
Joined: Dec 2006
O.P. RE: RE: Registry Class
quote:
Originally posted by Ezra
quote:
Originally posted by LifelesS
I can try to turn it into a class if you like
Does it really need to be a class?

Sometimes classes can be very handy, but sometimes also over-complicate matters.

It all depends on how the code is written..
Best Regards,
Joćo Godinho
08-03-2007 10:47 PM
Profile E-Mail PM Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: Registry Class
LifelesS, honestly if I wanted it to be made a class I would have made it one, however something like this doesn't need multiple instances therefore is not needed.
08-04-2007 12:19 AM
Profile E-Mail PM Find Quote Report
LifelesS
Full Member
***


Posts: 115
Reputation: 4
31 / Male / Flag
Joined: Dec 2006
O.P. RE: RE: Registry Class
quote:
Originally posted by matty
LifelesS, honestly if I wanted it to be made a class I would have made it one, however something like this doesn't need multiple instances therefore is not needed.


Yeah :P I agree, totally
Best Regards,
Joćo Godinho
08-04-2007 12:36 AM
Profile E-Mail PM Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: Registry Class
I got a PM asking how to use the Registry Enum components well this is how it is done.

code:
function OnEvent_Initialize(MessengerStart) {
    var objSubKeys = {}
    Registry_EnumSubkeys(HKCU, 'Software\\Patchou\\Messenger Plus! Live', objSubKeys);
   
    for (var objSubKey in objSubKeys) {
        Debug.Trace(objSubKey);
        var objValues  = {};
        Registry_EnumKeys(HKCU, 'Software\\Patchou\\Messenger Plus! Live\\'+objSubKey+'\\Preferences', objValues);
        for (var objValue in objValues) {
            Debug.Trace('  > '+objValue+' : '+objValues[objValue]);
        }
    }
}

Another function you can do in the script is to print out a registry tree.

code:
function OnEvent_Initialize(MessengerStart) {
    Debug.Trace('Software\\Patchou\\Messenger Plus! Live');
    GetRegistryTree(HKCU, 'Software\\Patchou\\Messenger Plus! Live', '  ');
}

function GetRegistryTree(Location, Key, prefix) {
    var objSubKeys = {};
    var objValues  = {};

    Registry_EnumKeys(Location, Key, objValues);
    for (var objValue in objValues) {
        Debug.Trace(prefix+'> '+objValue+'\t: '+objValues[objValue]);
    }
    Registry_EnumSubkeys(Location, Key, objSubKeys);
    for (var objSubKey in objSubKeys) {
        Debug.Trace(prefix+Key+'\\'+objSubKey);
        GetRegistryTree(Location, Key+'\\'+objSubKey, prefix+'  ');
    }
}

And a Delete Tree function

code:
function OnEvent_Initialize(MessengerStart) {
    Registry_DeleteTree(HKEY_LOCAL_MACHinE, 'Software\\Patchou');
        Debug.Trace('Registry_DeleteKey[\'Software\\Patchou]\' : '+Registry_DeleteKey(HKEY_LOCAL_MACHINE, 'Software\\Patchou'));
}

function Registry_DeleteTree(Location, Key) {
    var objSubKeys = {};
    var objValues  = {};

    Registry_EnumKeys(Location, Key, objValues);
    for (var objValue in objValues) {
        Debug.Trace('Registry_DeleteKeyValue['+Key+'\\'+objValue+'] : '+Registry_DeleteKeyValue(Location, Key, objValue));
    }
    Registry_EnumSubkeys(Location, Key, objSubKeys);
    for (var objSubKey in objSubKeys) {
        Registry_DeleteTree(Location, Key+'\\'+objSubKey);
        Debug.Trace('Registry_DeleteKey['+Key+'\\'+objSubKey+'] : '+Registry_DeleteKey(Location, Key+'\\'+objSubKey));
    }
}

This post was edited on 08-04-2007 at 04:37 AM by matty.
08-04-2007 12:42 AM
Profile E-Mail PM Find Quote Report
Matti
Elite Member
*****

Avatar
Script Developer and Helper

Posts: 1646
Reputation: 39
31 / Male / Flag
Joined: Apr 2004
RE: Registry Class
I've downloaded your latest registry library, but there seems to be a bug in the Registry_KeyValueExist function.

The function code says:
code:
function Registry_KeyValueExist(lKeyLocation, sKey, sKeyName){
   var hKey = Interop.Allocate(4);
   var sTmp = Interop.Allocate(4);
   var lActualType = Interop.Allocate(4);
   
   var lRetVal = Interop.Call('advapi32.dll', 'RegOpenKeyExW', lKeyLocation, sKey, 0, KEY_READ, hKey);
   if (lRetVal === ERROR_SUCCESS){
      lRetVal = Interop.Call('advapi32.dll', 'RegQueryValueExW', hKey.ReadDWORD(0), sKeyName, 0, lActualType, sTmp, 0);
      Registry_CloseKey(hKey.ReadDWORD(0));
      return lRetVal === ERROR_SUCCESS;
   }else{ return false; }
}
However, the function always returned false. This caused my script to restore the defaults every time the script started up, and so I simply had to get this fixed. When I debugged this, I found that after the RegQueryValueExW call, lRetVal was equal to 87. After looking up this value, I found that this was the ERROR_INVALID_PARAMETER constant. So, I checked the parameters section of this function's MSDN page and found this:
quote:
Originally posted by MSDN: RegQueryValueEx
lpcbData
    [in, out] A pointer to a variable that specifies the size of the buffer pointed to by the lpData parameter, in bytes. When the function returns, this variable contains the size of the data copied to lpData.

    The lpcbData parameter can be NULL only if lpData is NULL.

    ...
Now, in the function call lpcbData is 0 but lpData isn't! So, after modifying the call to:
code:
lRetVal = Interop.Call('advapi32.dll', 'RegQueryValueExW', hKey.ReadDWORD(0), sKeyName, 0, 0, 0, 0);
it worked! :O

This means, that you can replace the whole function by just this:
code:
function Registry_KeyValueExist(lKeyLocation, sKey, sKeyName){
   var hKey = Interop.Allocate(4);

   var lRetVal = Interop.Call('advapi32.dll', 'RegOpenKeyExW', lKeyLocation, sKey, 0, KEY_READ, hKey);
   if (lRetVal === ERROR_SUCCESS){
      lRetVal = Interop.Call('advapi32.dll', 'RegQueryValueExW', hKey.ReadDWORD(0), sKeyName, 0, 0, 0, 0);
      Registry_CloseKey(hKey.ReadDWORD(0));
      return lRetVal === ERROR_SUCCESS;
   }else{ return false; }
}
This leaves with just one (!) instead of three buffers used. :P
Plus! Script Developer | Plus! Beta Tester | Creator of Countdown Live | Co-developer of Screenshot Sender 5

Found my post useful? Rate me!
08-04-2007 11:27 AM
Profile E-Mail PM Web Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: Registry Class
Thanks I will fix that, I never used that function or tested it I just assumed it worked my bad. Sorry all.
08-04-2007 12:02 PM
Profile E-Mail PM Find Quote Report
-dt-
Scripting Contest Winner
*****

Avatar
;o

Posts: 1819
Reputation: 74
35 / Male / Flag
Joined: Mar 2004
RE: Registry Class
hm I created a registry class a while ago

http://websvn.thedt.net/Scripts/markup/213/codedump___registryClass.js
[Image: dt2.0v2.png]      Happy Birthday, WDZ
08-04-2007 12:16 PM
Profile PM Web Find Quote Report
ShawnZ
Veteran Member
*****

Avatar

Posts: 3146
Reputation: 43
32 / Male / Flag
Joined: Jan 2003
RE: Registry Class
javascript doesn't have classes. if you want to make it an object, you wouldn't be using multiple instances anyway. you'd just be replacing _ with ..
Spoiler:
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
08-04-2007 12:18 PM
Profile PM Web Find Quote Report
Pages: (2): « First « 1 [ 2 ] Last »
« 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