50分求个获取问题
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可以获取列数,现在想获取行数并获取行数内容