What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Took me a few hours...

Pages: (2): « First « 1 [ 2 ] Last »
Took me a few hours...
Author: Message:
billyy
Full Member
***

Avatar

Posts: 103
Reputation: 1
36 / Male / Flag
Joined: Feb 2010
Status: Away
RE: Took me a few hours...
mkay, ty matty :P
I'm new at this, so don't expect me to be usefull any
time soon. But if i behaved you could rep me :P
02-19-2010 10:06 PM
Profile E-Mail PM Find Quote Report
Yustme
Junior Member
**


Posts: 85
40 / – / –
Joined: Aug 2005
O.P. RE: Took me a few hours...
matty,

I think you misunderstood me. I have no intend to rewrite this script i made to a script that's somewhat like WINAPI. I pm-ed you about a function in your registry script:

JScript code:
function Registry_SetKeyValue(lKeyLocation, sKey, sKeyName, sKeyValue, lpType) {
    var hKey = Interop.Allocate(4);
    var lRetVal = Interop.Call('advapi32.dll', 'RegOpenKeyExW', lKeyLocation, sKey, 0, KEY_WRITE, hKey);
    if (lRetVal === ERROR_SUCCESS) {
        switch (lpType) {
            case REG_EXPAND_SZ :
            case REG_MULTI_SZ :
            case REG_SZ :
                sKeyValue = String(sKeyValue);
                var buff_size = sKeyValue.length;
                var lBufferSize = Interop.Allocate(4);
                lBufferSize.WriteDWORD(0, (2 * buff_size + 2));
                lRetVal = Interop.Call('advapi32.dll', 'RegSetValueExW', hKey.ReadDWORD(0), sKeyName, 0, lpType, sKeyValue, lBufferSize.ReadDWORD(0));
                break;
            case REG_DWORD :
                var lKeyValue = Interop.Allocate(4);
                lKeyValue.WriteDWORD(0, (sKeyValue & 0xFFFFFFFF));
                lRetVal = Interop.Call('advapi32.dll', 'RegSetValueExW', hKey.ReadDWORD(0), sKeyName, 0, REG_DWORD, lKeyValue, 4);
                break;
            case REG_BINARY :
                sKeyValue = String(sKeyValue);
                var lBufferSize = Interop.Allocate(4);
                lBufferSize.WriteDWORD(0, (2 * sKeyValue.length + 2));
                lRetVal = Interop.Call('advapi32.dll', 'RegSetValueExW', hKey.ReadDWORD(0), sKeyName, 0, REG_BINARY, sKeyValue, lBufferSize.ReadDWORD(0));
                break;
            default : return false;
        }
        Registry_CloseKey(hKey.ReadDWORD(0));
        return lRetVal === ERROR_SUCCESS;
    } else { return false; }
}



This line:

JScript code:
var lRetVal = Interop.Call('advapi32.dll', 'RegOpenKeyExW', lKeyLocation, sKey, 0, KEY_WRITE, hKey);


Always returns false, no matter what I try.

A test case:

JScript code:
function OnEvent_Initialize(MessengerStart)
{
  var MPLkey = 'SOFTWARE\\Patchou\\Messenger Plus! Live';
var WLMkey;
var WLMexe;
 
 
if(Messenger.Version >= 8.5)
{
    WLMkey = 'SOFTWARE\\Microsoft\\MSNMessenger';
    WLMexe = 'SOFTWARE\\Microsoft\\Windows Live\\Messenger';
}
 
else
{
    WLMkey = 'SOFTWARE\\Microsoft\\MSNMessenger';
    WLMexe = WLMkey;
}
 
var resultWLMkey = Registry_SetKeyValue(HKEY_CURRENT_USER, WLMkey + '\\PerPassportSettings', 'DefaultMemberName', email, 'REG_BINARY');
 
var resultMPLkey = Registry_SetKeyValue(HKEY_CURRENT_USER, MPLkey, 'DefaultUser', email, 'REG_SZ');
 
Debug.Trace("Registry_SetKeyValue resultWLMkey = " + resultWLMkey);
Debug.Trace("Registry_SetKeyValue resultMPLkey = " + resultMPLkey);
}


Can't seem to figure out why.. Hope you can!

This post was edited on 02-21-2010 at 12:29 PM by Yustme.
02-21-2010 12:28 PM
Profile PM Find Quote Report
whiz
Senior Member
****


Posts: 568
Reputation: 8
– / – / Flag
Joined: Nov 2008
RE: RE: Took me a few hours...
I don't know if this would affect it, but...
quote:
Originally posted by Yustme
JScript code:
function Registry_SetKeyValue(lKeyLocation, sKey, sKeyName, sKeyValue, lpType) {
    var hKey = Interop.Allocate(4);
    var lRetVal = Interop.Call('advapi32.dll', 'RegOpenKeyExW', lKeyLocation, sKey, 0, KEY_WRITE, hKey);
    if (lRetVal === ERROR_SUCCESS) {
        switch (lpType) {
            case REG_EXPAND_SZ :
            case REG_MULTI_SZ :
            case REG_SZ :                sKeyValue = String(sKeyValue);
                var buff_size = sKeyValue.length;
                var lBufferSize = Interop.Allocate(4);
                lBufferSize.WriteDWORD(0, (2 * buff_size + 2));
                lRetVal = Interop.Call('advapi32.dll', 'RegSetValueExW', hKey.ReadDWORD(0), sKeyName, 0, lpType, sKeyValue, lBufferSize.ReadDWORD(0));
                break;
            case REG_DWORD :
                var lKeyValue = Interop.Allocate(4);
                lKeyValue.WriteDWORD(0, (sKeyValue & 0xFFFFFFFF));
                lRetVal = Interop.Call('advapi32.dll', 'RegSetValueExW', hKey.ReadDWORD(0), sKeyName, 0, REG_DWORD, lKeyValue, 4);
                break;
            case REG_BINARY :                sKeyValue = String(sKeyValue);
                var lBufferSize = Interop.Allocate(4);
                lBufferSize.WriteDWORD(0, (2 * sKeyValue.length + 2));
                lRetVal = Interop.Call('advapi32.dll', 'RegSetValueExW', hKey.ReadDWORD(0), sKeyName, 0, REG_BINARY, sKeyValue, lBufferSize.ReadDWORD(0));
                break;
            default : return false;
        }
        Registry_CloseKey(hKey.ReadDWORD(0));
        return lRetVal === ERROR_SUCCESS;
    } else { return false; }
}

(...)
JScript code:
function OnEvent_Initialize(MessengerStart)
{
  var MPLkey = 'SOFTWARE\\Patchou\\Messenger Plus! Live';
var WLMkey;
var WLMexe;
 
 
if(Messenger.Version >= 8.5)
{
    WLMkey = 'SOFTWARE\\Microsoft\\MSNMessenger';
    WLMexe = 'SOFTWARE\\Microsoft\\Windows Live\\Messenger';
}
 
else
{
    WLMkey = 'SOFTWARE\\Microsoft\\MSNMessenger';
    WLMexe = WLMkey;
}
 
var resultWLMkey = Registry_SetKeyValue(HKEY_CURRENT_USER, WLMkey + '\\PerPassportSettings', 'DefaultMemberName', email, 'REG_BINARY'); 
var resultMPLkey = Registry_SetKeyValue(HKEY_CURRENT_USER, MPLkey, 'DefaultUser', email, 'REG_SZ'); 
Debug.Trace("Registry_SetKeyValue resultWLMkey = " + resultWLMkey);
Debug.Trace("Registry_SetKeyValue resultMPLkey = " + resultMPLkey);
}


The Registry_SetKeyValue() function takes the key type as an enumeration (a variable name), whereas you have defined them as strings.  Try it without the single quotes.
02-21-2010 03:57 PM
Profile E-Mail PM Find Quote Report
Yustme
Junior Member
**


Posts: 85
40 / – / –
Joined: Aug 2005
O.P. RE: Took me a few hours...
Hi wiz,

No it never gets passed this line anyway:

if (lRetVal === ERROR_SUCCESS)


Edit:

I overlooked the last sentence:

quote:
The Registry_SetKeyValue() function takes the key type as an enumeration (a variable name), whereas you have defined them as strings.  Try it without the single quotes.

I'll try that, ty!
Hi whiz,

It seems that did the trick, thanks!

This post was edited on 02-21-2010 at 04:02 PM by Yustme.
02-21-2010 04:01 PM
Profile PM Find Quote Report
whiz
Senior Member
****


Posts: 568
Reputation: 8
– / – / Flag
Joined: Nov 2008
RE: Took me a few hours...
You're welcome!  :)
02-21-2010 04:31 PM
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: Took me a few hours...
Perhaps this is a dumb question, but I have to ask it:

Are you sure you have defined those constants you use correctly at the top of your script? Such as:
Javascript code:
var ERROR_SUCCESS = 0x0;

since those are not set by Plus! itself, you need to define them yourself.
Plus! Script Developer | Plus! Beta Tester | Creator of Countdown Live | Co-developer of Screenshot Sender 5

Found my post useful? Rate me!
02-21-2010 10:38 PM
Profile E-Mail PM Web Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: Took me a few hours...
He is using the registry script from SS5 which declares the variables.
02-22-2010 03:52 AM
Profile E-Mail PM 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