以下是老马写的例子,帮我看看 pMyItemMemory = VirtualAllocEx(pHandle, 0, Len(myItem), MEM_COMMIT, PAGE_READWRITE) 为什么返回的是0呢? Dim result As Long Dim myItem As LV_ITEMA Dim pHandle As Long Dim pMyItemMemory As Long Dim pStrBufferMemory As Long Dim strBuffer() As Byte Dim index As Long Dim tmpString As String Dim strLength As Long
result = ReadProcessMemory(pHandle, pStrBufferMemory, strBuffer(0), MAX_LVMSTRING, 0) result = ReadProcessMemory(pHandle, pMyItemMemory, myItem, Len(myItem), 0) For index = LBound(strBuffer) To UBound(strBuffer) If Chr(strBuffer(index)) = vbNullChar Then Exit For tmpString = tmpString & Chr(strBuffer(index)) Next index
tmpString = Trim(tmpString)
result = VirtualFreeEx(pHandle, pStrBufferMemory, 0, MEM_RELEASE) result = VirtualFreeEx(pHandle, pMyItemMemory, 0, MEM_RELEASE)
result = CloseHandle(pHandle)
If Len(tmpString) > 0 Then GetListviewItem = tmpString
为什么返回的是0呢? Dim result As Long
Dim myItem As LV_ITEMA
Dim pHandle As Long
Dim pMyItemMemory As Long
Dim pStrBufferMemory As Long
Dim strBuffer() As Byte
Dim index As Long
Dim tmpString As String
Dim strLength As Long
ReDim strBuffer(MAX_LVMSTRING)
pColumn = 1
pRow = 20
GetWindowThreadProcessId hWnd, processID
pHandle = OpenProcess(PROCESS_ALL_ACCESS, False, processID)
pStrBufferMemory = VirtualAllocEx(pHandle, Null, MAX_LVMSTRING, MEM_COMMIT, PAGE_READWRITE)
myItem.mask = LVIF_TEXT
myItem.iSubItem = pColumn
myItem.pszText = pStrBufferMemory
myItem.cchTextMax = MAX_LVMSTRING
pMyItemMemory = VirtualAllocEx(pHandle, 0, Len(myItem), MEM_COMMIT, PAGE_READWRITE)
result = WriteProcessMemory(pHandle, pMyItemMemory, myItem, Len(myItem), 0)
ItemCount = SendMessage(hWnd, LVM_GETITEMCOUNT, 0, 0)
result = SendMessage(hWnd, LVM_GETITEMTEXT, pRow, ByVal pMyItemMemory)
result = ReadProcessMemory(pHandle, pStrBufferMemory, strBuffer(0), MAX_LVMSTRING, 0)
result = ReadProcessMemory(pHandle, pMyItemMemory, myItem, Len(myItem), 0) For index = LBound(strBuffer) To UBound(strBuffer)
If Chr(strBuffer(index)) = vbNullChar Then Exit For
tmpString = tmpString & Chr(strBuffer(index))
Next index
tmpString = Trim(tmpString)
result = VirtualFreeEx(pHandle, pStrBufferMemory, 0, MEM_RELEASE)
result = VirtualFreeEx(pHandle, pMyItemMemory, 0, MEM_RELEASE)
result = CloseHandle(pHandle)
If Len(tmpString) > 0 Then GetListviewItem = tmpString
pStrBufferMemory = VirtualAlloc(Null, MAX_LVMSTRING, MEM_COMMIT, PAGE_READWRITE)
myItem.mask = LVIF_TEXT
myItem.iSubItem = pColumn
myItem.pszText = pStrBufferMemory
myItem.cchTextMax = MAX_LVMSTRING
pMyItemMemory = VirtualAlloc(Null, Len(myItem), MEM_COMMIT, PAGE_READWRITE)
result = WriteProcessMemory(pHandle, pMyItemMemory, myItem, Len(myItem), 0)
ItemCount = SendMessage(hWnd, LVM_GETITEMCOUNT, 0, 0)
result = SendMessage(hWnd, LVM_GETITEMTEXT, pRow, ByVal pMyItemMemory)'返回0 不成功
result = SendMessage(hWnd, WM_LBUTTONDBLCLK, pRow, ByVal pMyItemMemory)'返回0 不成功
result = SendMessage(pHandle, WM_LBUTTONDBLCLK, pRow, ByVal pMyItemMemory)'返回0 不成功不成功的3条怎么解决呢
ItemCount = SendMessage(hWnd, LVM_GETITEMCOUNT, 0, 0)
lngHeaderHwnd = SendMessage(hWnd, LVM_GETHEADER, 0, 0)
lngCols = SendMessage(lngHeaderHwnd, HDM_GETITEMCOUNT, 0, 0) '获取ListView表头项目数'上面3条能取到
result = SendMessage(hWnd, LVM_GETITEMTEXT, pRow, ByVal pMyItemMemory)'这条取不到 返回0
为什么呢??
pStrBufferMemory = VirtualAllocEx(pHandle, 0, MAX_LVMSTRING, MEM_COMMIT, PAGE_READWRITE) pMyItemMemory = VirtualAllocEx(pHandle, 0, Len(myItem), MEM_COMMIT, PAGE_READWRITE)2个值一样的~ 有关系吗?
dim pRow as string*256
result = SendMessage(hWnd, LVM_GETITEMTEXT, 256, pRow)