9CBS code

xiaoxiao2021-03-06  42

If you only use Delphi's own general control, then you don't need another dynamic connection library. You don't have the option of the Project menu below Builder With Runtime Packages. The system will contain all the required BPL files to the compiled EXE.

// Check if the file opens if FileExists (FileName) THEN IF (Filename, FMSharexClusive <0) The showMessage ('file has been opened "); // Establish a global mouse hook unit unit1;

Interface

Uses Windows, Messages, Sysutils, Variants, Classes, Graphics, Controls, Forms, Dialogs, Stdctrls;

type TForm1 = class (TForm) Button1: TButton; Button2: TButton; procedure Button1Click (Sender: TObject); procedure FormClose (Sender: TObject; var Action: TCloseAction); procedure Button2Click (Sender: TObject); private {Private declarations} Procedure Hook (en: boolean = true); public {public declarations} END;

Var Form1: TForm1; HHOOK: longword; xy: tpoint;

IMPLEMentation

{$ R * .dfm}

function HookProc (iCode: Integer; wParam: wParam; lParam: lParam): (. peventmsg (lparam) ^ message = WM_LBUTTONUP) LRESULT;; stdcall begin if (. peventmsg (lparam) ^ message = WM_LBUTTONDOWN) Or Or (peventmsg (lparam ) ^. message = WM_LBUTTONDBLCLK) Or (peventmsg (lparam) ^. message = WM_MOUSEMOVE) Or (peventmsg (lparam) ^. message = WM_RBUTTONDOWN) Or (peventmsg (lparam) ^. message = WM_RBUTTONUP) Or (peventmsg (lparam) ^ .message = WM_RBUTTONDBLCLK) Or (peventmsg (lparam) ^ message = WM_MBUTTONDOWN) Or (peventmsg (lparam) ^ message = WM_MBUTTONUP) Or (peventmsg (lparam) ^ message = WM_MBUTTONDBLCLK) then begin GETCURSORPOS (XY);... form1. Caption: = INTOSTR (xy.x) '' INTOSTR (XY.Y); End; Result: = CallNexthookex (HHOOK, ICODE, WPARAM, LPARAM);

Procedure TFORM1.BUTTON1CLICK (Sender: TOBJECT); Begin Hook;

procedure TForm1.Hook (En: Boolean); begin if En then hHook: = SetwindowsHookEx (WH_JOURNALRECORD, HookProc, HInstance, 0) else UnHookWindowsHookEx (hHook); end; procedure TForm1.FormClose (Sender: TObject; var Action: TCloseAction); Begin Hook (false);

Procedure TFORM1.BUTTON2CLICK (Sender: TOBJECT); Begin Hook (false);

End.

转载请注明原文地址:https://www.9cbs.com/read-71068.html

New Post(0)