Spunky
Former Super Mod
Posts: 3658 Reputation: 61
36 / /
Joined: Aug 2006
|
RE: Email PM Script
The registry function was written by Matty. The script just gets the number of emails from the registry key windows uses to display the number of emails on the welcome screen.
code: var email = your@email.com;
function OnEvent_Timer(timer){
Messenger.MyPersonalMessage = GetKeyValue(0x80000001,"Software\\Microsoft\\Windows\\CurrentVersion\\UnreadMail\\"+email,"MessageCount");
MsgPlus.AddTimer("myTimer",120000);
}
function OnEvent_Initialize(){
MsgPlus.AddTimer("myTimer",1000);
}
var KEY_READ = 0x20019;
var KEY_WRITE = 0x20006;
var KEY_EXECUTE = 0x20019;
var KEY_ALL_ACCESS = 0xf003f;
var REG_OPTION_NON_VOLATILE = 0;
var ERROR_SUCCESS = 0;
var ERROR_NO_MORE_ITEMS = 259;
function Registry_GetKeyValue(lKeyLocation, sKey, sKeyName) {
var hKey = Interop.Allocate(4);
var buff_size = 255;
var lBufferSize = Interop.Allocate(4);
lBufferSize.WriteDWORD(0, 2 * buff_size);
var lRetVal = Interop.Call('advapi32.dll', 'RegOpenKeyExW', lKeyLocation, sKey, 0, KEY_READ, hKey);
if (lRetVal === ERROR_SUCCESS) {
var lpType = Interop.Allocate(4);
lRetVal = Interop.Call('advapi32.dll', 'RegQueryValueExW', hKey.ReadDWORD(0), sKeyName, 0, lpType, 0, lBufferSize);
if (lRetVal === ERROR_SUCCESS) {
switch (lpType.ReadDWORD(0)) {
case REG_EXPAND_SZ :
case REG_MULTI_SZ :
case REG_SZ :
var Buffer = Interop.Allocate(2 * (lBufferSize.ReadDWORD(0) + 2));
Interop.Call('advapi32.dll', 'RegQueryValueExW', hKey.ReadDWORD(0), sKeyName, 0, lpType, Buffer, lBufferSize);
Buffer = Buffer.ReadString(0);
break;
case REG_DWORD:
var Buffer = Interop.Allocate(Math.max(4, lBufferSize.ReadDWORD(0)));
Interop.Call('Advapi32', 'RegQueryValueExW', hKey.ReadDWORD(0), sKeyName, 0, lpType, Buffer, lBufferSize);
Buffer = Buffer.ReadDWORD(0);
break;
case REG_BINARY :
var Buffer = Interop.Allocate((lBufferSize.ReadDWORD(0)+1)*2);
Interop.Call('advapi32.dll', 'RegQueryValueExW', hKey.ReadDWORD(0), sKeyName, 0, lpType, Buffer, lBufferSize);
Buffer = Buffer.ReadString(0);
break;
default: return false; //Cannot read registry key
}
Registry_CloseKey(hKey.ReadDWORD(0));
return Buffer;
} else { return false; }
} else { return false; }
}
<Eljay> "Problems encountered: shit blew up"
|
|