Took me a few hours... |
Author: |
Message: |
billyy
Full Member
Posts: 103 Reputation: 1
37 / /
Joined: Feb 2010
Status: Away
|
RE: Took me a few hours...
mkay, ty matty
I'm new at this, so don't expect me to be usefull any
time soon. But if i behaved you could rep me
|
|
02-19-2010 10:06 PM |
|
|
Yustme
Junior Member
Posts: 85
41 / – / –
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 |
|
|
whiz
Senior Member
Posts: 568 Reputation: 8
– / – /
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 |
|
|
Yustme
Junior Member
Posts: 85
41 / – / –
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 |
|
|
whiz
Senior Member
Posts: 568 Reputation: 8
– / – /
Joined: Nov 2008
|
RE: Took me a few hours...
You're welcome!
|
|
02-21-2010 04:31 PM |
|
|
Matti
Elite Member
Script Developer and Helper
Posts: 1646 Reputation: 39
32 / /
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:
js code: var ERROR_SUCCESS = 0x0;
since those are not set by Plus! itself, you need to define them yourself.
|
|
02-21-2010 10:38 PM |
|
|
matty
Scripting Guru
Posts: 8336 Reputation: 109
39 / /
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 |
|
|
Pages: (2):
« First
«
1
[ 2 ]
Last »
|
|
|