你好,我这里注册的很长一段时间,但我只是一些教程和意见或新的主题激活。我有一个问题,我解决不了几天。我提出的申请,安装全局钩子的键盘,但它不能在控制台应用程序和浏览器的键盘味精勾。我需要一些帮助找出问题,我想,我希望我在这里可以找到此帮助。
DLL的代码与GNU GCC编译器和codeblocks为IDE copiled:
钩设立与MS VS 2008编译代码:
//dllmain
#include "main.h"
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <cstdio>
#include <fstream>
using namespace std;
#ifdef __cplusplus
extern "C"
{
#endif
void DLL_EXPORT SomeFunction(const LPCSTR sometext)
{
MessageBoxA(0, sometext, "DLL Message", MB_OK | MB_ICONINFORMATION);
}
LRESULT CALLBACK DLL_EXPORT KeyboardProc(int code, WPARAM wParam, LPARAM lParam) {
SomeFunction("test"); //here is just an example not all code in this function the big ideea is that this callback is not called when a console app or a browser application have focus
LRESULT RetVal = CallNextHookEx( 0, code, wParam, lParam );
return RetVal;
}
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
switch (fdwReason)
{
case DLL_PROCESS_ATTACH:
// attach to process
// return FALSE to fail DLL load
break;
case DLL_PROCESS_DETACH:
// detach from process
break;
case DLL_THREAD_ATTACH:
// attach to thread
break;
case DLL_THREAD_DETACH:
// detach from thread
break;
}
return TRUE; // succesful
}
#ifdef __cplusplus
}
#endif
//main.h
#ifndef __MAIN_H__
#define __MAIN_H__
#include <windows.h>
/* To use this exported function of dll, include this header
* in your project.
*/
#ifdef BUILD_DLL
#define DLL_EXPORT __declspec(dllexport)
#else
#define DLL_EXPORT __declspec(dllimport)
#endif
#ifdef __cplusplus
extern "C"
{
#endif
void DLL_EXPORT SomeFunction(const LPCSTR sometext);
LRESULT CALLBACK DLL_EXPORT KeyboardProc(
int code,
WPARAM wParam,
LPARAM lParam
);
#ifdef __cplusplus
}
#endif
#endif // __MAIN_H__
</windows.h></fstream></cstdio></windows.h>
{C}
我使用Windows Vista X32的最终版
LE:没有人能帮助我吗?
| vlasceanu