Hi people,
I have this code for check EnumWindows:
Its work with a "button" for refresh, but i like convert it to array and adding a items to array every time iam open a new window. Its possible? if yes, can you help me please?
Best Regards,
I have this code for check EnumWindows:
VB.NET:
Public Delegate Function EnumWindowsProc(ByVal hwnd As IntPtr, ByVal lParam As Int32) As Int32
Public Declare Function EnumWindows Lib "user32.dll" _
(ByVal lpEnumFunc As EnumWindowsProc, ByVal lParam As Int32) As Int32
Public Declare Function GetWindowTextLength Lib "user32.dll" Alias "GetWindowTextLengthA" _
(ByVal hwnd As IntPtr) As Int32
Public Declare Function GetWindowText Lib "user32.dll" Alias "GetWindowTextA" _
(ByVal hwnd As IntPtr, ByVal lpString As String, ByVal cch As Int32) As Int32
'Callback function to enum windows
Public Function EnumWindowsCallBack(ByVal hwnd As IntPtr, ByVal lParam As Int32) As Int32
Dim sSave As String
'Get the windowtext length
sSave = Space(GetWindowTextLength(hwnd) + 1)
'get the window text
GetWindowText(hwnd, sSave, Len(sSave))
'remove the last Chr(0)
sSave = Microsoft.VisualBasic.Left(sSave, Len(sSave) - 1)
'Error below: Reference to a non-shared member requires an Object Reference
ListBox1.Items.Add(sSave)
If sSave.Trim <> "" Then
ListBox1.Items.Remove("")
End If
Return 1 'continue enumeration
End Function
Best Regards,
Last edited by a moderator: