Je lance le prog et je ne note pas de doublage de touche.
DLL:
#include <windows.h>
HINSTANCE thismod = 0;
HHOOK hhk = 0;
#pragma comment(linker, "/entry:myDllMain")
__declspec(naked) int __stdcall myDllMain(HINSTANCE hdll, DWORD dwReason, LPVOID Reserved)
{ // DLL_PROCESS_DETACH = 0, DLL_PROCESS_ATTACH = 1
__asm {
mov eax, [esp+8] ; dwReason
mov edx, [esp+4] ; hdll
dec eax
jne short mainRET
mov thismod, edx
mainRET:
mov eax, 1
ret 12
}
}
// TRAITEMENT ULTRA MINIMAL
LRESULT CALLBACK LowLevelKeyboardProc(int nCode, WPARAM wParam, LPARAM lParam)
{
return CallNextHookEx(0, nCode, wParam, lParam);
}
int __stdcall Intercepte()
{
if(!hhk) {
hhk = SetWindowsHookEx(WH_KEYBOARD_LL, LowLevelKeyboardProc, thismod, 0);
}
return (int) hhk;
}
void __stdcall Relache()
{
if(hhk) {
UnhookWindowsHookEx(hhk); hhk = 0;
}
}
----------------------
PROG UTILISATEUR:
#include <windows.h>
#include "resource.h"
#pragma comment(lib, "bnkbd.lib")
int __stdcall Intercepte();
void __stdcall Relache();
BOOL CALLBACK AppDlgProc(HWND hdlg, UINT mssg, WPARAM wParam, LPARAM lParam)
{
switch(mssg) {
case WM_INITDIALOG:
if(!Intercepte()) goto dlgEND;
SetClassLongPtr(hdlg, GCLP_HICON, (long)LoadIcon(0, IDI_APPLICATION));
return 1;
case WM_COMMAND:
if(wParam != IDCANCEL) break;
Relache();
dlgEND:
EndDialog(hdlg, 0);
}
return 0;
}
#pragma comment(linker, "/entry:myWinMain")
__declspec(naked) void __stdcall myWinMain()
{
__asm {
push 0
call dword ptr GetModuleHandle
push eax
push offset AppDlgProc
push 0
push IDD_APP
push eax
call dword ptr DialogBoxParam
push 0
call dword ptr ExitProcess
}
}
ciao...
BruNews, MVP VC++