Home > Back-end >  Across processes for setting the data in a LVS_OWNERDATA SYSLISTVIEW32 control
Across processes for setting the data in a LVS_OWNERDATA SYSLISTVIEW32 control

Time:09-25

Across processes for setting the data in a LVS_OWNERDATA SYSLISTVIEW32 control

CodePudding user response:

Ask ace to help solve

CodePudding user response:

The function ListView_GetItemText_Mz (hListView: HWnd; IItem, iSubItem: Integer; PszText: PChar; CchTextMax: Integer) : Integer;
Var hProcess: THandle;
DispInfo: TLVDispInfo;
ProcessID, ThreadID: dwords.
VNumberOfBytesRead: Cardinal;
VPointer: Pointer;
Pitem: LPWSTR;
VBuffer: an array of Char [0.. 255];
The begin
DispInfo. HDR. HwndFrom:=hListView;
DispInfo. HDR. IdFrom:=GetDlgCtrlID (hListView);
DispInfo. HDR. Code:=LVN_GETDISPINFO;
ThreadID:=GetWindowThreadProcessId (hListview, @ ProcessID);
HProcess:=OpenProcess (PROCESS_VM_OPERATION or PROCESS_VM_READ or PROCESS_VM_WRITE or PROCESS_QUERY_INFORMATION, FALSE, ProcessID);
PItem:=VirtualAllocEx (hProcess, nil, 512, MEM_COMMIT, PAGE_READWRITE);
DispInfo. Item. Mask:=LVIF_TEXT;
DispInfo. Item. IItem:=iItem;
DispInfo. Item. ISubItem:=iSubItem;
DispInfo. Item. PszText:=pszText;
DispInfo. Item. CchTextMax:=cchTextMax;
DispInfo. Item. PszText:=Pointer (Cardinal (pItem) + SizeOf (TLVDispInfo));
WriteProcessMemory (hProcess, pItem. @ DispInfo, SizeOf (TLVDispInfo), vNumberOfBytesRead);
Result:=SendMessage (GetParent (hListView), WM_NOTIFY, GetDlgCtrlID (hListView), Integer (@ DispInfo));
ReadProcessMemory (hProcess, Pointer (Cardinal (pItem) + SizeOf (TLVDispInfo)),
@ vBuffer [0], SizeOf (vBuffer), vNumberOfBytesRead);
DispInfo. Item. PszText:=vBuffer;
VirtualFreeEx (hProcess, pItem, 0, MEM_RELEASE);
end;

CodePudding user response:

Look not to understand,,,,,,,,,,
  • Related