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.
|
|