Well I am trying to create a hook here, and when I write something to catch a hook it won't even compile, it complains that it cannot convert param 2 or SetWindowsHookEx cannot be converted from
Code:
long(int, unsigned int, long)
to
Code:
int (__stdcall *)(void)
Here is a portion of the code below which I borrowed from someone who has freely distributed a msnhook program they made.
Code:
int APIENTRY DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
{
tdll = hInstance;
return TRUE;
}
void APIENTRY ShellDll_Hook()
{
g_hShellHook = SetWindowsHookEx(WH_CBT, ShellDll_MainHook, tdll, 0);
}
void APIENTRY ShellDll_Unhook()
{
if(g_hShellHook != NULL)
UnhookWindowsHookEx(g_hShellHook);
}
void phello(char *mystr)
{
strcpy(mystr, "Hello 2 you!\n");
}
LRESULT CALLBACK ShellDll_MainHook(int nCode, WPARAM wParam, LPARAM lParam)
{
TCHAR szClass[MAX_PATH] = {0};
BOOL doneonce = false;
if(nCode < 0)
return CallNextHookEx(g_hShellHook, nCode, wParam, lParam);
// Call filter everytime a new window is created
if(nCode == HCBT_CREATEWND)
{
// Get the HWND of the window
HWND hwndToNewWindow = reinterpret_cast<HWND>(wParam);
GetClassName(hwndToNewWindow, szClass, MAX_PATH);
}
return CallNextHookEx(NULL, nCode, wParam, lParam);
}
the def for ShellDll_main is
Code:
LRESULT CALLBACK ShellDll_MainHook(int nCode, WPARAM wParam, LPARAM lParam);
his code, which looks different than mine compiles fine on visual c++ 5.
Any ideas or suggestions? Need more code posted? Thanks!