⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hookhost.dpr

📁 delphi编程源代码
💻 DPR
字号:
Program HookHost;

uses windows,messages,sysutils;
type
  TWin = record
    Msg:TMsg;
    wClass:TWndClass;
    hMain,hInfo,hInfo1,hInfo2,hInfo3:integer;
  end;
var
  Win:TWin;                     //结构变量
//
function WindowProc(hWnd,Msg,wParam,lParam:longint):LRESULT; stdcall;
begin
  case Msg of
  wm_command:
    begin
      if (wparam=1) and (lparam=1) then setwindowtext(win.hInfo,'Set Hook Success');
      if (wparam=1) and (lparam=0) then setwindowtext(win.hInfo,'Set Hook Faliure');
      if (wparam=2) and (lparam=1) then setwindowtext(win.hInfo,'UnSet Hook Success');
      if (wparam=2) and (lparam=0) then setwindowtext(win.hInfo,'UnSet Hook Faliure');
      if wparam=3 then setwindowtext(win.hInfo,pchar(format('count=%d',[lparam])));
      if wparam=$11 then setwindowtext(win.hInfo1,pchar(format('ProcessId=%x',[lparam])));
      if wparam=$21 then setwindowtext(win.hInfo2,pchar(format('ThreadId=%x',[lparam])));
      if wparam=$31 then setwindowtext(win.hInfo3,pchar(format('hwnd=%x',[lparam])));
    end;
  wm_destroy:
    begin
      halt;
    end;
  end;
  Result:=DefWindowProc(hWnd,Msg,wParam,lParam);
end;

//主程序的执行函数
procedure run;stdcall;
begin
  if findwindow('HookHost',nil)<>0 then exit;
  win.wClass.hInstance:=     hInstance;
  with win.wclass do
  begin
    hIcon:=         LoadIcon(hInstance,'MAINICON');
    hCursor:=       LoadCursor(0,IDC_ARROW);
    hbrBackground:= COLOR_BTNFACE+1;
    Style:=         CS_PARENTDC;
    lpfnWndProc:=   @WindowProc;
    lpszClassName:='HookHost';
  end;
  RegisterClass(win.wClass);
  win.hMain:=CreateWindow(win.wClass.lpszClassName,win.wClass.lpszClassName,WS_VISIBLE or WS_OVERLAPPEDWINDOW,220,220,240,185,0,0,hInstance,nil);
  win.hInfo:=CreateWindow('STATIC','Hello',WS_VISIBLE or WS_CHILD,0,0,220,24,win.hmain,0,hInstance,nil);
  win.hInfo1:=CreateWindow('STATIC','Hello',WS_VISIBLE or WS_CHILD,0,30,220,24,win.hmain,0,hInstance,nil);
  win.hInfo2:=CreateWindow('STATIC','Hello',WS_VISIBLE or WS_CHILD,0,60,220,24,win.hmain,0,hInstance,nil);
  win.hInfo3:=CreateWindow('STATIC','Hello',WS_VISIBLE or WS_CHILD,0,90,220,24,win.hmain,0,hInstance,nil);
  //
  while(GetMessage(win.Msg,win.hmain,0,0)) do
  begin
    TranslateMessage(win.Msg);
    DispatchMessage(win.Msg);
  end;
end;

begin
  run;   //开始运行主程序
end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -