Home > Software engineering >  Questions about the vb6 to extract the ListView content
Questions about the vb6 to extract the ListView content

Time:09-20

See the zeal of a lot of shrimp, still failed to solve, the problem is this:
The following code downloaded from the Internet, access to "program manager" is no problem; I made a contains the ListView control program, and can get the content in the ListView (I use SPY directly to the ListView control Handle), but, just can't get in the flush of "tractor single monitoring" content (I confirmed the right to obtain the Handle, the name of the class is SysListView32, Caption is "List1,"
Prawns please help, thank!!!!!!


==================================the original program code to=======================================
 Option Explicit 

Private Const LVM_FIRST=& amp; H1000
Private Const LVM_GETITEMCOUNT=(LVM_FIRST + 4)

Private Const LVM_GETITEM=(LVM_FIRST + 5)
Private Const LVM_GETSTRINGWIDTH=(LVM_FIRST + 17)
Private Const LVM_GETCOLUMN=(LVM_FIRST + 25)
Private Const LVM_GETITEMTEXT=(LVM_FIRST + 45)
Private Const LVM_GETHEADER=LVM_FIRST + 31
Private Const WC_HEADERA="SysHeader32"
Private Const WC_HEADER=WC_HEADERA
Private Const HDM_FIRST=& amp; H1200 '//Header messages
Private Const HDM_GETITEMCOUNT=(HDM_FIRST + 0)
Private Const HDM_ORDERTOINDEX=(HDM_FIRST + 15)

Private Const PROCESS_QUERY_INFORMATION=1024
Private Const PROCESS_VM_OPERATION=& amp; H8
Private Const PROCESS_VM_READ=& amp; H10
Private Const PROCESS_VM_WRITE=& amp; H20
Private Const STANDARD_RIGHTS_REQUIRED=& amp; HF0000
Private Const MAX_LVMSTRING As Long=255 'root tree read data length can be set appropriate numerical
Private Const MEM_COMMIT=& amp; H1000
Private Const MEM_RELEASE=& amp; H8000
Private Const PAGE_READWRITE=& amp; H4
Private Const LVIF_TEXT As Long=& amp; H1

Private Type LV_ITEMA
Mask As Long
IItem As Long
ISubItem As Long
The state As Long
StateMask As Long
PszText As Long
CchTextMax As Long
IImage As Long
LParam As Long
IIndent As Long
End Type

Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcId As Long) As Long
Private Declare Function VirtualAllocEx Lib "kernel32" (ByVal hProcess As Long, ByVal lpAddress As Long, ByVal dwSize As Long, ByVal flAllocationType As Long, ByVal flProtect As Long) As Long
Private Declare Function VirtualFreeEx Lib "kernel32" (ByVal hProcess As Long, ByVal lpAddress As Long, ByVal dwSize As Long, ByVal dwFreeType As Long) As Long
Private Declare Function WriteProcessMemory Lib "kernel32" (ByVal hProcess As Long, ByVal lpBaseAddress As Any, ByRef lpBuffer As Any, ByVal nSize As Long, lpNumberOfBytesWritten As Long) As Long
Private Declare Function ReadProcessMemory Lib "kernel32" (ByVal hProcess As Long, ByVal lpBaseAddress As Any, ByRef lpBuffer As Any, ByVal nSize As Long, lpNumberOfBytesWritten As Long) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal HWND As Long, ByVal wMsg As Long, ByVal wParam As Long, ByRef lParam As Any) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal HWND As Long, lpdwProcessId As Long) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long

Private Sub Command1_Click ()
Dim lngHwnd As Long
Dim lngHwnd1 As Long
Dim lngHeaderHwnd As Long
Dim lngPId As Long
Dim lngRows As Long
Dim lngCols As Long
Dim lngRow As Long
Dim lngCol As Long
Dim strItem As String

LngHwnd1=FindWindow (vbNullString, "Windows task manager") 'to get the task manager window handle
LngHwnd1=FindWindowEx (lngHwnd1, 0, "# 32770", "") 'access TAB handle
LngHwnd=FindWindowEx (lngHwnd1, 0, "SysListView32", "process") 'acquisition process list box handle
The Debug. Print lngHwnd

LngHeaderHwnd=SendMessage (lngHwnd LVM_GETHEADER, 0, 0) 'handle for ListView header
LngRows=SendMessage (lngHwnd LVM_GETITEMCOUNT, 0, 0) 'for ListView item number

If lngHeaderHwnd & gt; 0 Then
LngCols=SendMessage (lngHeaderHwnd HDM_GETITEMCOUNT, 0, 0) 'number for ListView header
The Else
LngCols=1
End the If
GetWindowThreadProcessId lngHwnd, lngPId 'linked together with a specified window for a process and thread identifier
For lngRow=0 To lngRows - 1
StrItem=""
For lngCol=0 To lngCols - 1
StrItem=strItem & amp; VbTab & amp; GetListviewItem (lngHwnd lngPId, lngCol lngRow)
Next
The Debug. Print strItem
Next
End Sub

The Public Function GetListviewItem (ByVal hWindow As Long, ByVal ProcessID As Long, ByVal pColumn As Long, ByVal pRow As Long) As String
Dim the Result As Long
Dim myItem As LV_ITEMA
Dim pHandle As Long
Dim pStrBufferMemory As Long
Dim pMyItemMemory As Long
Dim strBuffer () As Byte
Dim Index As Long
Dim tmpString As String
Dim strLength As Long

'* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
'for the dynamic array variable to allocate storage space
'* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  •  Tags:  
  • API
  • Related