好友
阅读权限10
听众
最后登录1970-1-1
|
jim19
发表于 2023-7-16 07:30
本帖最后由 jim19 于 2023-7-16 10:09 编辑
自己开发的一个软件, 很多列表很长, 不注册也无法保存, 用ocr很费劲, 所以开发了这么个小软件, 原理就是通过sendmessage LVM_GETITEM获取列表数据, 使用也很简单, 对着有列表的控件, 然后按快捷键win+f2就可以了.
譬如下面这种类型的采集软件
软件对所有列表都生效, 下面用windows文件夹仅作演示.
列表小偷.rar
(568.38 KB, 下载次数: 109)
核心代码delphi:
[Delphi] 纯文本查看 复制代码 function GetListViewText(mHandle: THandle; mStrings: TStrings): Boolean;
var
vColumnCount: Integer;
vItemCount: Integer;
I, J: Integer;
vBuffer: array[0..255] of Char;
vProcessId: DWORD;
vProcess: THandle;
vPointer: Pointer;
vNumberOfBytesRead: Cardinal;
S: string;
vItem: TLVItem;
begin
Result := False;
if not Assigned(mStrings) then Exit;
vColumnCount := ListViewColumnCount(mHandle);
if vColumnCount <= 0 then Exit;
vItemCount := ListView_GetItemCount(mHandle);
GetWindowThreadProcessId(mHandle, @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);
mStrings.BeginUpdate;
try
mStrings.Clear;
for I := 0 to vItemCount - 1 do begin
S := '';
for J := 0 to vColumnCount - 1 do begin
with vItem do begin
mask := LVIF_TEXT;
iItem := I;
iSubItem := J;
cchTextMax := SizeOf(vBuffer);
pszText := Pointer(Cardinal(vPointer) + SizeOf(TLVItem));
end;
WriteProcessMemory(vProcess, vPointer, @vItem,
SizeOf(TLVItem), vNumberOfBytesRead);
SendMessage(mHandle, LVM_GETITEM, I, lparam(vPointer));
ReadProcessMemory(vProcess, Pointer(Cardinal(vPointer) + SizeOf(TLVItem)),
@vBuffer[0], SizeOf(vBuffer), vNumberOfBytesRead);
S := S + #9 + vBuffer;
end;
Delete(S, 1, 1);
mStrings.Add(S);
end;
finally
VirtualFreeEx(vProcess, vPointer, 0, MEM_RELEASE);
CloseHandle(vProcess);
mStrings.EndUpdate;
end;
Result := True;
end;
|
免费评分
-
查看全部评分
|
发帖前要善用【论坛搜索】功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。 |
|
|
|
|