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