L
Lidong
Unregistered / Unconfirmed
GUEST, unregistred user!
我在计算机世界上看到一偏关于日志钩子的文章,但我自己实验的时候却怎么也编译不了,
说我安装日志钩子时错误,哪为高人有空的时候请帮忙查查错,代码如下:
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
g_hLogHook=NULL;//钩子变量
g_hLastFocus=NULL;
//记录上一次得到焦点的窗口句柄
}
//---------------------------------------------------------------------------
//钩子回调函数:
HOOKPROC __fastcall TForm1::JournalLogProc(int iCode,WPARAM wParam,LPARAM lParam)
{
if(iCode<0)
return (HOOKPROC)CallNextHookExg_hLogHook,iCode,wParam,lParam);
if(iCode==HC_ACTION)
//略
}
//---------------------------------------------------------------------------
//安装日志钩子
void __fastcall TForm1::Button1Click(TObject *Sender)
{
//
if(g_hLogHook==NULL)
g_hLogHook=SetWindowsHookEx(WH_JOURNALRECORD,(HOOKPROC)JournalLogProc,HInstance,0);
}
//---------------------------------------------------------------------------
//卸载日志钩子
void __fastcall TForm1::Button2Click(TObject *Sender)
{
if(g_hLogHook!=NULL)
{UnhookWindowsHookEx(g_hLogHook);
g_hLogHook=NULL;
}//卸载日志钩子
}
//---------------------------------------------------------------------------
说我安装日志钩子时错误,哪为高人有空的时候请帮忙查查错,代码如下:
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
g_hLogHook=NULL;//钩子变量
g_hLastFocus=NULL;
//记录上一次得到焦点的窗口句柄
}
//---------------------------------------------------------------------------
//钩子回调函数:
HOOKPROC __fastcall TForm1::JournalLogProc(int iCode,WPARAM wParam,LPARAM lParam)
{
if(iCode<0)
return (HOOKPROC)CallNextHookExg_hLogHook,iCode,wParam,lParam);
if(iCode==HC_ACTION)
//略
}
//---------------------------------------------------------------------------
//安装日志钩子
void __fastcall TForm1::Button1Click(TObject *Sender)
{
//
if(g_hLogHook==NULL)
g_hLogHook=SetWindowsHookEx(WH_JOURNALRECORD,(HOOKPROC)JournalLogProc,HInstance,0);
}
//---------------------------------------------------------------------------
//卸载日志钩子
void __fastcall TForm1::Button2Click(TObject *Sender)
{
if(g_hLogHook!=NULL)
{UnhookWindowsHookEx(g_hLogHook);
g_hLogHook=NULL;
}//卸载日志钩子
}
//---------------------------------------------------------------------------