50分求个获取问题

allwhy 2015-09-27 11:22:24
Public Function GetListViewTextArray(ByVal hWindow As Long) As String()
Dim myItem() As LV_ITEMA
Dim PHandle As Long
Dim ProcessId As Long
Dim PStrBufferMemory As Long
Dim PMyItemMemory As Long
Dim StrBuffer(MAX_LVMSTRING) As Byte
Dim TmpString As String
Dim Ih As Long, J As Long, HCount As Long
Dim StrArr() As String, ItemString As String
Dim Ji As Long, MyItemLength() As Long

GetWindowThreadProcessId hWindow, ProcessId
HCount = SendMessage(hWindow, LVM_GETHEADER, 0, 0) '获取列数
If HCount > 0 Then
HCount = SendMessage(HCount, HDM_GETITEMCOUNT, 0, 0) - 1
Else 'NOT HCOUNT...
HCount = 0
End If
PHandle = OpenProcess(PROCESS_VM_OPERATION Or PROCESS_VM_READ Or PROCESS_VM_WRITE, 0, ProcessId)
ReDim myItem(HCount)
ReDim MyItemLength(HCount)
PStrBufferMemory = VirtualAllocEx(PHandle, 0, MAX_LVMSTRING, MEM_COMMIT, PAGE_READWRITE)
PMyItemMemory = VirtualAllocEx(PHandle, 0, MAX_LVMSTRING, MEM_COMMIT, PAGE_READWRITE)
Ji = SendMessage(hWindow, LVM_GETITEMCOUNT, 0, 0) - 1
On Error GoTo err1
ReDim StrArr(Ji)

For Ih = 0 To HCount
myItem(Ih).mask = LVIF_TEXT
myItem(Ih).iSubItem = Ih
myItem(Ih).pszText = PStrBufferMemory
myItem(Ih).cchTextMax = MAX_LVMSTRING
MyItemLength(Ih) = Len(myItem(Ih))
Next Ih

For J = 0 To Ji
ItemString = ""
For Ih = 0 To HCount
WriteProcessMemory PHandle, PMyItemMemory, myItem(Ih), MyItemLength(Ih), 0
If SendMessage(hWindow, LVM_GETITEMTEXT, J, ByVal PMyItemMemory) > 0 Then
ReadProcessMemory PHandle, PStrBufferMemory, StrBuffer(0), MAX_LVMSTRING, 0
TmpString = StrConv(StrBuffer, vbUnicode)
TmpString = Left(TmpString, InStr(TmpString, vbNullChar) - 1)
ItemString = ItemString & TmpString & Chr(9) ' Chr$(32)
End If
Next Ih
If ItemString <> "" Then
StrArr(J) = Left(ItemString, Len(ItemString) - 1)
End If
Next J

VirtualFreeEx PHandle, PMyItemMemory, 0, MEM_RELEASE
VirtualFreeEx PHandle, PStrBufferMemory, 0, MEM_RELEASE
CloseHandle (PHandle)
ItemString = ""
GetListViewTextArray = StrArr

Exit Function
err1:
MsgBox "不是Listview类吧?", vbInformation
End Function


上面这段代码没办法获取类为:ListView20WndClass的内容啊~~~ 请问怎么修改可以获取ListView20WndClass列表内容?HCount = SendMessage(HCount, HDM_GETITEMCOUNT, 0, 0) - 1可以获取列数,现在想获取行数并获取行数内容
...全文
206 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
舉杯邀明月 2015-09-28
  • 打赏
  • 举报
回复
引用 1 楼 allwhy 的回复:
自己解决了~~~ 结贴....
恭喜楼主。 
KissVeggieg 2015-09-27
  • 打赏
  • 举报
回复
引用 1 楼 allwhy 的回复:
自己解决了~~~ 结贴....
楼主贴出来大家学习下吧
现在ing 2015-09-27
  • 打赏
  • 举报
回复
引用 1 楼 allwhy 的回复:
自己解决了~~~ 结贴....
allwhy 2015-09-27
  • 打赏
  • 举报
回复
自己解决了~~~ 结贴....

1,486

社区成员

发帖
与我相关
我的任务
社区描述
VB API
社区管理员
  • API
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧