Sytem-Wide Hook: comunication dll(c++) form c# ??

fadex

Newcomer
Joined
Jan 15, 2003
Messages
5
Location
Italy
Any help it's appreciate...

I've a form that receives some value, sent from a dll in c++ that implements a message hook, but only when a messagebox is shown and I can't understand the reason.???...

this for sending data in the c++ dll:

LRESULT CALLBACK msghook(UINT nCode, WPARAM wParam, LPARAM lParam) {

if (nCode < 0) {
CallNextHookEx(g_hHook, nCode, wParam, lParam);
return 0;
}

LPMSG msg = (LPMSG)lParam; // Recuperiamo i dati che ci servono

if (msg->message == WM_MOUSEMOVE || msg->message == WM_NCMOUSEMOVE) {
int iPassSomething = iCount++;
PostMessage(g_hWndServer, WM_USER, iPassSomething, 0); // Inviamo i dati alla Form

return CallNextHookEx(g_hHook, nCode, wParam, lParam);
}
return CallNextHookEx(g_hHook, nCode, wParam, lParam);
}

this in the c# form:

protected override void WndProc(ref Message message)
{
if (message.Msg == WM_USER) {
this.Text = message.WParam.ToString();
}
base.WndProc(ref message);
}

in the attached file there are both source....and sorry for my english !!
 

Attachments

Back
Top