Well for me im just kind of experimenting with the treeview and with the process class, Now it was all working grand until I tried to go 3 nodes in etc etc..
Can anyone help me, I need to have it add all the classes+hwnds of the children into the Classes node of each parent node
Is where it goes wrong..
Can anyone help me, I need to have it add all the classes+hwnds of the children into the Classes node of each parent node
VB.NET:
For z = 0 To bStr.GetUpperBound(0) - 1
.Nodes(i).Nodes(0).Nodes.Add(bStr(z))
Next
Is where it goes wrong..
In form1
VB.NET:
Option Strict On
Option Explicit On
Imports System.text
Public Class Form1
Private Structure tProc
Dim Name As String
Dim MainWindowTitle As String
Dim Handle As String
Dim vMemory As String
End Structure
Dim tProcess As tProc
Dim sBuild As New StringBuilder(256)
Dim ChildHandles As String
Dim proc As New EnumWindProc(AddressOf EnumChild)
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim tProc() As Process = Process.GetProcesses
Dim i As Int32, z As Int32, bStr() As String
With TreeView1
For i = 0 To tProc.GetUpperBound(0)
tProcess.Name = tProc(i).ProcessName
tProcess.MainWindowTitle = tProc(i).MainWindowTitle
tProcess.Handle = tProc(i).MainWindowHandle.ToString
tProcess.vmemory = tProc(i).VirtualMemorySize64.ToString
.Nodes.Add(tProcess.Name)
.Nodes(i).Nodes.Add("Virtual Memory:" & tProcess.vMemory)
If Convert.ToInt32(tProcess.Handle) <> 0 Then
EnumChildWindows(CType(tProcess.Handle, IntPtr), proc, IntPtr.Zero)
bStr = ChildHandles.Split(","c)
If bStr.GetUpperBound(0) > 0 Then .Nodes(i).Nodes.Add("Classes")
For z = 0 To bStr.GetUpperBound(0) - 1
.Nodes(i).Nodes(0).Nodes.Add(bStr(z))
Next
ChildHandles = String.Empty
End If
If tProcess.MainWindowTitle <> String.Empty Then
.Nodes(i).Nodes.Add("WindowTitle:" & tProcess.MainWindowTitle)
Else
.Nodes(i).Text = .Nodes(i).Text.ToUpper
End If
If Convert.ToInt32(tProcess.Handle) <> 0 Then
.Nodes(i).Nodes.Add("Handle:" & tProcess.Handle)
Else
.Nodes(i).Text = .Nodes(i).Text.ToUpper
End If
Next
.Sort()
End With
Timer1.Stop()
End Sub
Private Function EnumChild(ByVal hWnd As Int32, ByVal lParam As Int32) As Boolean
GetClassName(hWnd, sBuild, sBuild.Capacity)
ChildHandles += (sBuild.ToString & "-" & hWnd & ",")
EnumChild = True
End Function
End Class
VB.NET:
Imports system.text
Module Module1
Declare Function EnumChildWindows Lib "user32" ( _
ByVal hWnd As IntPtr, _
ByVal lpEnumFunc As EnumWindProc, _
ByRef lParam As IntPtr) As Int32
Delegate Function EnumChildWindProc( _
ByVal hWnd As Int32, _
ByVal lParam As Int32) As Boolean
Delegate Function EnumWindProc( _
ByVal hWnd As Int32, _
ByVal lParam As Int32) As Boolean
Public Declare Function GetClassName Lib "user32.dll" Alias "GetClassNameA" ( _
ByVal hwnd As Int32, _
ByVal lpClassName As StringBuilder, _
ByVal nMaxCount As Int32) As Int32
End Module