Get the text of Statusbar in other processes

xiaoxiao2021-03-06  42

(* //

Title: Get text in STATUSBAR in other processes

Description: WINDOW2000 Delphi6 debugging

Design: zswang

Support: wjhu111@21cn.com

Date: 2005-02-22

// *)

Uses commctrl;

Function GetStatusbartext (Mhandle: Thandle): String;

VAR

VBuffer: array [0. $ 1000] of char;

vsize: integer;

I: integer;

Vcount: integer;

VProcessID: DWORD;

..

Vpointer: Pointer;

VNUMBEROFBYTESREAD: Cardinal

Begin

Result: = '';

vcount: = sendMessage (Mhaldle, SB_GETPARTS, 0, 0);

IF vcount <= 0.

GetWindowThreadProcessId (Mhaldle, @vprocessid);

vprocess: = openprocess (Process_VM_Operation or Process_vm_read OR

Process_vm_write, false, vprocessid;

Vpointer: = Virtualalocex (vProcess, NIL, $ 1000, MEM_RESERVE or MEM_COMMIT,

Page_readwrite;

Try

For i: = 0 to vcount - 1 do

Begin

vsize: = sendMessage (MHANDLE, SB_GETTEXT, I, 0) 1;

SendMessage (MHANDLE, SB_GETTEXT, I, Integer (vpointer));

ReadProcessMemory (vprocess, vpointer, @vbuffer [0],

vsize, vnumberofbytesread;

Result: = Result # 9 VBuffer;

END;

DELETE (Result, 1, 1);

Finally

VirtualFreeex (vProcess, Vpointer, 0, MEM_RELEASE);

CloseHandle (vProcess);

END;

End; {getStatusbartext}

// esample

Procedure TFORM1.FormCreate (Sender: TOBJECT);

Begin

RegisterhotKey (Handle, 1, MOD_WIN, VK_F2);

END;

Procedure TFORM1.FORMDESTROY (Sender: TOBJECT);

Begin

UnregisterhotKey (Handle, 1);

END;

Procedure TFORM1.WMHOTKEY (VAR MSG: TWMHOTKEY);

Begin

Case msg.hotKey of

1: edit1.text: = getStatusbartext

WindowFromPoint (Point (mouse.cursorpos.x, mouse.cursorpos.y)))));

END;

END;

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

New Post(0)