Home > Software engineering >  To obtain the TreeView content problem
To obtain the TreeView content problem

Time:09-16

Want to iterate through access to a resource manager each item in the title, baidu for a long time, made a small piece of code, but I still couldn't take the similar "the position of a recent visit to this title,"
Class - SysTreeView32,
HTreeView=1379188 spy++ found out the handle, directly in the first,
I Excel in a computer problems, the main code in the notepad, please the teacher to give directions,




 
Option Explicit
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal HWND As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (ByVal Destination As String, ByVal Source As Long, ByVal Length As Long)
Private Declare Function GlobalAlloc Lib "kernel32" (ByVal wFlags As Long, ByVal dwBytes As Long) As Long
Private Declare Function GlobalFree Lib "kernel32" (ByVal hMem As Long) As Long
Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal HWND As Long, lpdwProcessId As Long) As Long
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessID As Long) As Long
Private Declare Function TerminateProcess Lib "kernel32" (ByVal hProcess As Long, ByVal uExitCode As Long) As Long
Private Declare Function VirtualAllocEx Lib "kernel32. DLL" (ByVal hProcess As Long, lpAddress As Any, ByRef dwSize As Long, ByVal flAllocationType As Long, ByVal flProtect As Long) As Long
Private Declare Function VirtualFreeEx Lib "kernel32. DLL" (ByVal hProcess As Long, lpAddress As Any, ByRef dwSize As Long, ByVal dwFreeType As Long) As Long
Private Declare Function WriteProcessMemory Lib "kernel32" (ByVal hProcess As Long, ByVal lpBaseAddress As Long, 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 Long, llpBufferfer As Any, ByVal nSize As Long, lpNumberOfBytesWritten As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
'~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
Private Const TVGN_ROOT=& amp; H0 'first child, root specified item is a part of the root item
Private Const TVGN_CHILD=& amp; H4 'first child
Private Const TVGN_Next=& amp; H1 'brother next item
Private Const TVGN_Caret=& amp; The selected project
H9 '
Private Const TVGN_Previous=& amp; H2 'before a brother item
Private Const TVGN_Parent=& amp; H3 'to specify a parent
Private Const TVGN_FirstVisible=& amp; H5 'the first visible item
Private Const TVGN_NextVisible=& amp; H6 'follow after the specified item under a visual item
Private Const TVGN_PreviousVisible=& amp; H7 'before the specified item of the first visible item
Private Const TVGN_LastVisible=& amp; H10

Private Const TVGN_DropHilite=& amp; H8 'last drag-and-drop target item

Private Const TV_FIRST=& amp; H1100
Private Const TVM_GETITEMRECT As Long=(TV_FIRST + 4)
Private Const TVM_GETNEXTITEM As Long=(TV_FIRST + 10)
Private Const TVM_SELECTITEM As Long=(TV_FIRST + 11)
Private Const TVM_DELETEITEM As Long=(TV_FIRST + 1)
Private Const TVM_GETCOUNT=(TV_FIRST + 5)


Private Const TVM_HITTEST=(TV_FIRST + 17)
Private Const TVM_GETITEM=(TV_FIRST + 12)
Private Const TVM_GETITEMA=(TV_FIRST + 12)
Private Const TVM_GETITEMW=(TV_FIRST + 12)


Private Const TVHT_ONITEMLABEL=& amp; H4
Private Const TVIF_TEXT=& amp; H1
Private Const GMEM_FIXED=& amp; H0
Private Const TVM_EXPAND As Long=& amp; H1102
Private Const WM_SETREDRAW As Long=& amp; HB

Private Const PROCESS_ALL_ACCESS=& amp; H1F0FFF
Private Const MEM_DECOMMIT=& amp; H4000
Private Const MEM_RELEASE=& amp; H8000
Private Const MEM_COMMIT=& amp; H1000
Private Const PAGE_EXECUTE_READWRITE=& amp; H40
Private Const MAX_LVMSTRING As Long=255
'~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
Private Type TVITEM
Mask As Long
HTreeItem As Long
The state As Long
StateMask As Long
PszText As Long
CchTextMax As Long
IImage As Long
ISelectedImage As Long
CChildren As Long
LParam As Long
End Type

Sub test2 ()
Dim Flag As Long 'whether an
Dim hTreeView As Long 'TreeView control handle
Dim hTVRoot As Long handle 'root node
Dim hTVItem As Long handle 'child node

Dim vProcessId As Long
Dim vProcess As Long
Dim vPointer As Long
Dim vItemCount As Long
Dim pMyItemMemory As Long

Dim As Long I
Dim the result As Long
Dim bytes As Long
Dim vItem As TVITEM
Dim tmpItem As TVITEM
Dim strBuffer () As Byte
Dim tmpString As String
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  •  Tags:  
  • API
  • Related