//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "MouseCount.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
HMODULE hdll=NULL;
int (WINAPI*getl)();
int (WINAPI*getr)();
bool ImportDllOK=false;
extern "C" __declspec(dllexport) int __stdcall CALLBACK mouseproc(int code,WPARAM wParam,LPARAM lParam);
extern "C" __declspec(dllexport) bool WINAPI starthook();
extern "C" __declspec(dllexport) bool WINAPI stophook();
extern "C" __declspec(dllexport) int WINAPI getresultl();
extern "C" __declspec(dllexport) int WINAPI getresultr();
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
hdll=LoadLibrary("MouseRecord");
if(hdll)
{
ImportDllOK=true;
}
getl=(int(WINAPI*)())GetProcAddress(hdll,"getresultl");
getr=(int(WINAPI*)())GetProcAddress(hdll,"getresultr");
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
if(ImportDllOK)
{
Timer1->Interval=500;
Timer1->Enabled=true;
bool (WINAPI*sethook)();
sethook=(bool (WINAPI*)())GetProcAddress(hdll,"starthook");
if(sethook)
{
ShowMessage("钩子安装完毕");
}
else
{
ShowMessage("钩子安装失败");
}
}
else
Close();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
bool(WINAPI*unhook)();
unhook=(bool(WINAPI*)())GetProcAddress(hdll,"stophook");
if(unhook())
{
ShowMessage("卸载成功");
}
else
{
ShowMessage("卸载失败");
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Timer1Timer(TObject *Sender)
{
Label1->Caption="鼠标点击情况:\n左击次数:"+AnsiString(getl())+"\n"+"右击次数:"+AnsiString(getr());
}
//---------------------------------------------------------------------------
- 1
- 2
前往页