You can however hook into messenger and stop them just clicking the add contact button or whatever. I almost got it working, but for some reason it freezes the messenger main window after. I sent it to a friend of mine for testing and he didn't have the problem, so I'm unsure if it will work correctly for everyone or not. The point is, it stops them from adding contacts by clicking the add contact button or going through the menu. If anyone could provide any information on why this is freezing up my messenger, please respond to this post as i spent over 4 hours trying to figure it out to no avail.
code:
var WH_CBT = 5;
var HCBT_CREATEWND = 3;
var hHook;
function OnEvent_Initialize(MessengerStart) {
hHook = Interop.Call('User32.dll', 'SetWindowsHookExW',
WH_CBT,
Interop.GetCallbackPtr('CBTProc'),
Interop.Call('Kernel32.dll', 'GetModuleHandleW', 'MsgPlusLive.dll'),
Interop.Call('Kernel32.dll', 'GetCurrentThreadId')
);
}
function OnEvent_Uninitialize(MessengerExit) {
if (hHook) Interop.Call('User32.dll', 'UnhookWindowsHookEx', hHook);
}
function CBTProc(nCode, wParam, lParam) {
// MSDN said to simply return CallNextHook with no further processing if nCode<0
if (nCode >= 0)
// Check for notification of a window being created
if (nCode == HCBT_CREATEWND) {
// Is the window in question the add contact window
if (GetClass(wParam) == 'MSNContacts_Dialog') {
// Show Error message
Interop.Call('User32.dll', 'MessageBoxW', 0, 'Erorr: You are not allowed to add a contact.', 0, 0x10);
// MSDN says that returning anything other than 0 will stop the window being created.
return 1;
}
// MSDN says that returning 0 allows the window to be created.
return 0;
}
// Call next hook...
return Interop.Call('User32.dll', 'CallNextHookEx', hHook, nCode, wParam, lParam);
}
// Returns the class name of hWnd
function GetClass(hWnd) {
var Data = Interop.Allocate(0x200);
Interop.Call('User32.dll', 'GetClassNameW', hWnd, Data, 0x200);
var Class = Data.ReadString(0);
Data.Size = 0;
return Class;
}