DLL里写HOOK

来源:百度知道 编辑:UC知道 时间:2024/09/20 14:36:52
这是什么错误啊???????????
Build
[C++ Error] Unit1.cpp(40): E2034 Cannot convert 'long (*)(int,unsigned int,long)' to 'int (*)()'
[C++ Error] Unit1.cpp(40): E2342 Type mismatch in parameter 'lpfn' (wanted 'int (*)()', got 'long (*)(int,unsigned int,long)')

程序:
LRESULT CALLBACK KeyboardProc(int nCode,WPARAM wParam,LPARAM lParam)
{
return 1;
}
void _declspec(dllexport) _stdcall SetHook()
{
SetWindowsHookEx(WH_KEYBOARD,KeyboardProc,::GetModuleHandle(TEXT("DLL.dll")),0);
}
#include <vcl.h>
#include <windows.h>
#pragma hdrstop

#pragma argsused
int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void* lpReserved)
{
return 1;
}

LRESULT CALLBACK KeyboardProc(int nCode,WPARAM wParam,LPARAM lParam)
{
return 1;
}
void _declspec(dllexport) _stdcall SetHook()
{
SetWindows

我编译了,没有错误啊。
是不是你还写了其他的钩子?
貌似是个回调函数声明错误的问题……

----------------------------------------

还是没有错误,不过我用的是VC++6.0编译

你Unit1.cpp的第40行是什么代码?把第35-45行的代码贴出来看下。看上去像是GetProcAddress调用的错误