(SDK)全局钩子问题 大神指点下
DLL代码;(.H)#defineMYLIBAPI__declspec(dllexport)MYLIBAPILRESULTCALLBACKhookpro(intnCode...
DLL代码;(.H)
#define MYLIBAPI __declspec(dllexport)
MYLIBAPI LRESULT CALLBACK hookpro(int nCode,WPARAM wParam,LPARAM lParam);
(.CPP )
#include "windows.h"
#include "mylib.h"
LRESULT CALLBACK hookpro(int nCode,WPARAM wParam,LPARAM lParam)
{ DeleteFile("D\\:heshan.txt");
return 0;
}
exe代码:
#include <windows.h>
#pragma comment(lib,"dll制作.lib")
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR szCmdLine,int iCmdShow)
{
HINSTANCE dllhinst=LoadLibrary("dll制作.dll");
SetWindowsHookEx(WH_KEYBOARD,(HOOKPROC)hookpro,dllhinst,0);
return 0;
}
问题:为什么不能编译啊D:\vc\MSDev98\MyProjects\dll制作\mylib\g.cpp(12) : error C2065: 'hookpro' : undeclared identifier 展开
#define MYLIBAPI __declspec(dllexport)
MYLIBAPI LRESULT CALLBACK hookpro(int nCode,WPARAM wParam,LPARAM lParam);
(.CPP )
#include "windows.h"
#include "mylib.h"
LRESULT CALLBACK hookpro(int nCode,WPARAM wParam,LPARAM lParam)
{ DeleteFile("D\\:heshan.txt");
return 0;
}
exe代码:
#include <windows.h>
#pragma comment(lib,"dll制作.lib")
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR szCmdLine,int iCmdShow)
{
HINSTANCE dllhinst=LoadLibrary("dll制作.dll");
SetWindowsHookEx(WH_KEYBOARD,(HOOKPROC)hookpro,dllhinst,0);
return 0;
}
问题:为什么不能编译啊D:\vc\MSDev98\MyProjects\dll制作\mylib\g.cpp(12) : error C2065: 'hookpro' : undeclared identifier 展开
1个回答
展开全部
你也没有定义这个函数,你用的是静态加载,你吧头文件包含进去
//注意.lib,.dll都放在工程目录下
#include <windows.h>
#inlude"mylib.h"
#pragma comment(lib,"dll制作.lib")
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR szCmdLine,int iCmdShow)
{
SetWindowsHookEx(WH_KEYBOARD,(HOOKPROC)hookpro,dllhinst,0);
return 0;
}
//注意.lib,.dll都放在工程目录下
#include <windows.h>
#inlude"mylib.h"
#pragma comment(lib,"dll制作.lib")
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR szCmdLine,int iCmdShow)
{
SetWindowsHookEx(WH_KEYBOARD,(HOOKPROC)hookpro,dllhinst,0);
return 0;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询