键盘钩子为什么不行啊?
//钩子头文件:keybdhook.h
#define DllExport extern "C"__declspec(dllexport)
DllExport void WINAPI InstallHook(void);
//DllImport void EndHook(void);
LRESULT CALLBACK KeyBoardProc(int nCode,WPARAM wParam, LPARAM lParam );
//钩子实现文件:keybdhook.cpp
// keybdhook.cpp : Defines the entry point for the DLL application.
//
#include "stdafx.h"
#include "windows.h"
#include "keybdhook.h"
#include "string.h"
#include "stdio.h"
HINSTANCE hInst = NULL;
static HHOOK hkb=NULL;
//HINSTANCE hins; //钩子函数所在模块的句柄
//HHOOK oldkeyhook = NULL;
#pragma data_seg("hookdata")
HHOOK oldkeyhook=0;
#pragma data_seg()
#pragma comment(linker,"/SECTION:hookdata,RWS")
//#define DllExport extern "C"__declspec(dllexport)
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
return TRUE;
}
void WINAPI InstallHook(void)
{
oldkeyhook = SetWindowsHookEx(WH_KEYBOARD,(HOOKPROC)KeyBoardProc,hInst,0);
}
LRESULT CALLBACK KeyBoardProc(int nCode,WPARAM wParam, LPARAM lParam )
{
WPARAM j;
FILE *fp;
fp=fopen("c:\\hookkey.txt","a");
fwrite("test",4,1,fp);
if(lParam&0x80000000)
{
j = wParam;
fwrite("test",4,1,fp);
fprintf(fp,"%4d",j);
fclose(fp);
}
return CallNextHookEx(oldkeyhook,nCode,wParam,lParam);
}
*************************************************************************
测试keybdhooktest.h
#include "windows.h"
#include "../keybdhook/keybdhook.h"
#define DllImport extern"C"__declspec(dllimport)
DllImport void WINAPI InstallHook();
////////////////////////
keybdhooktest.cpp
//////////////////////
// keybdhooktest.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "keybdhooktest.h"
int main(int argc, char* argv[])
{
printf("Hello World!\n");
InstallHook();
// SetKeyboardHook(0,0);
while(1)
{
Sleep(50);
}
return 0;
}
[解决办法]
接分
[解决办法]
接分
[解决办法]
--b
jf.
[解决办法]
wo jie
[解决办法]
接。。。
[解决办法]
分?是什么?
[解决办法]
接分