能给个例子吗
解决方案 »
- ???如何禁止在托盘图标上利用鼠标左键进行双击操作???
- 在DBGRIDS显示的表,怎样改字段的宽度呢?
- 怎样在程序退出后保存控件属性?
- 为什么这句的错,请问如何写才对呢?TLabel(FindComponent('submit'+inttostr(i)+'web')).Navigate('http://www.163.com')
- 一个简单的问题关于listview
- 请问:如何产生随即数
- 关于MDIchild窗体关闭出错的问题
- 各位高手有个问题,关于table.filter的问题
- 所有杭州的朋友请进来一下~!!!!!!!!!!!
- 为什么我进入BDE ADMINISTRATOR会经常死锁?
- 如何屏蔽系统按键 Alt+Tab Alt+Ctrl+Del
- 没有qq群关于讨论delphi的??
procedure TForm1.Button1Click(Sender: TObject);
var
Hand:hwnd;
otherHand:hwnd;
Count,index:integer;
lvConstructor:LV_ITEM ;
strText:TstringList;
begin
strText:=TstringList.Create;
Hand:=FindWindow(nil,'Form1');
otherHand:=FindWindowex(Hand,0,nil,'listview');
Count:=Sendmessage(otherHand,LVM_GETITEMTEXT,0,0);
if Count >0 then
for index:=0 to Count-1 do
begin
SendMessage(otherHand,LVM_GETITEMTEXT,index,lvConstructor );
strText.Add(lvConstructor.pszText);
end;
strText.free;
end;
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;
cchTextMax := 255;
pszText := Pointer(Cardinal(vPointer) + SizeOf(TLVItem));
end;
WriteProcessMemory(vProcess, vPointer, @vItem,
SizeOf(TLVItem), vNumberOfBytesRead);
SendMessage(vHandle, LVM_GETITEM, I, lparam(vPointer));
pBuffer := vBuffer;
ReadProcessMemory(vProcess, Pointer(Cardinal(vPointer) + SizeOf(TLVItem)),
pBuffer, DWORD(256), vNumberOfBytesRead);
S := S + #9 + vBuffer;
end;
Delete(S, 1, 1);
MemoText.Lines.Add(S);
end;
finally
VirtualFreeEx(vProcess, vPointer, 0, MEM_RELEASE);
CloseHandle(vProcess);
end;
end;
end;
end;procedure TForm1.FormDestroy(Sender: TObject);
begin
UnRegisterHotKey(Handle, cHotKeyWinF2);
end;