怎么捕获外部程序LISTVIEW鼠标单击事件,获取该LISTVIEW当前选中行的某列的值

如何捕获外部程序LISTVIEW鼠标单击事件,获取该LISTVIEW当前选中行的某列的值
现有一个外部程序,其界面上有个LISTVIEW控件,里面有若干行数据,我想通过自己的程序,捕获该外部程序中LISTVIEW的鼠标点击事件,同时获取其当前选中行的某列的值。

现在的初步思路是使用 SetWindowsHookEx 进行注入,但是不确定是使用 WH_MOUSE,还是 WH_CALLWNDPROC 来实现。

或者,我本身的思路就问题,请大家多指教,谢谢。

------解决方案--------------------
WH_MOUSE,并判断点击的是否为TListView,然后进一步可以做其他处理
------解决方案--------------------
探讨
每天回帖即可获得10分可用分!小技巧

------解决方案--------------------
learning......
------解决方案--------------------
转一个伴水的帖子:

获取不同进程ListView的内容~~

(*//

标题:获取不同进程ListView的内容

说明:适用于WindowsNT

日期:2003-02-27

设计:Zswang

//*)

 

unit Unit1;

 

interface

 

uses

Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

Dialogs, StdCtrls, ComCtrls;

 

type

TForm1 = class(TForm)

MemoText: TMemo;

EditCount: TEdit;

LabelNote: TLabel;

procedure FormCreate(Sender: TObject);

procedure FormDestroy(Sender: TObject);

private

{ Private declarations }

procedure WMHOTKEY(var Msg: TWMHOTKEY); message WM_HOTKEY;

public

{ Public declarations }

end;

 

var

Form1: TForm1;

 

implementation

 

{$R *.dfm}

 

uses CommCtrl;

 

function VirtualAllocEx(hProcess: Cardinal; lpAddress: Pointer;

dwSize, flAllocationType, flProtect: Cardinal): Pointer; stdcall;

external kernel32 name ''VirtualAllocEx'';

function VirtualFreeEx(hProcess: Cardinal; lpAddress: Pointer;

dwSize, dwFreeType: Cardinal): Boolean; stdcall;

external kernel32 name ''VirtualFreeEx'';



const cHotKeyWinF2 = 1;

 

procedure TForm1.FormCreate(Sender: TObject);

begin

Application.Title := ''获取ListView内容 1.0'';

Caption := Application.Title;

RegisterHotKey(Handle, cHotKeyWinF2, MOD_WIN, VK_F2);

end;

 

procedure TForm1.WMHOTKEY(var Msg: TWMHOTKEY);

var

I, J: Integer;

S: string;

vItem: TLVItem;

vCount: Integer;

vHandle: THandle;

vBuffer: array[0..255] of Char;

pBuffer: PChar;

vProcess: THandle;

vProcessId: DWORD;

vPointer: Pointer;

vNumberOfBytesRead: Cardinal;

begin

case Msg.HotKey of

cHotKeyWinF2: begin

MemoText.Clear;

FillChar(vBuffer, 256, 0);

vHandle := WindowFromPoint(Point(Mouse.CursorPos.X, Mouse.CursorPos.Y));

vCount := ListView_GetItemCount(vHandle);

if vCount = 0 then Exit;

GetWindowThreadProcessId(vHandle, @vProcessId);

vProcess := OpenProcess(PROCESS_VM_OPERATION or PROCESS_VM_READ or

PROCESS_VM_WRITE, False, vProcessId);

vPointer := VirtualAllocEx(vProcess, nil, 4096, MEM_RESERVE or MEM_COMMIT,

PAGE_READWRITE);

try

for I := 0 to vCount - 1 do begin

S := '''';

for J := 0 to StrToIntDef(EditCount.Text, 0) - 1 do begin

with vItem do begin

mask := LVIF_TEXT;

iItem := I;

iSubItem := J;