dllCoRupT626
Programmer
Right to the point... I'm trying to List all of the Top LvL Window's, Everything works fine until it try's to get the ClassName of the Window and the Window Text (Title Bar).
This is all in a module:
'Declare's
Public Declare Function GetClassName Lib "user32.dll" Alias "GetClassNameA" (ByVal hWnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Integer
Public Declare Function GetWindowText Lib "user32.dll" Alias "GetWindowTextA" (ByVal hWnd As Long, ByVal lpString As String, ByVal nMaxCount As Long) As Integer
Public Declare Function GetWindowTextLength Lib "user32.dll" Alias "GetWindowTextLengthA" (ByVal hWnd As Long) As Integer
Public Declare Function EnumWindows Lib "user32.dll" (ByVal lpEnumFunc As Long, ByVal lParam As Integer) As Boolean
'Function's
Public Function fGetTopLvLWindowsEnumProc(hWnd As Long, ByVal lParam As Long) As Boolean
Dim tmpWinLen, tmpClassLen As Long
On Error GoTo error_Handler
If topWindowNames(1) <> "¬ÑÉÑáѦÖÑä¬" Then
ReDim Preserve topWindowNames((UBound(topWindowNames) + 1))
End If
If topWindowClassNames(1) <> "¬ÑÉÑáѦÖÑä¬" Then
ReDim Preserve topWindowClassNames((UBound(topWindowClassNames) + 1))
End If
If topWindowHandles(1) <> 0 Then
ReDim Preserve topWindowHandles((UBound(topWindowHandles) + 1))
End If
tmpWinLen = GetWindowTextLength(hWnd)
Call GetWindowText(hWnd, topWindowNames(UBound(topWindowNames)), tmpWinLen + 1)
topWindowHandles(UBound(topWindowHandles)) = hWnd
tmpClassLen = GetClassName(hWnd, topWindowClassNames(UBound(topWindowClassNames)), 151)
If topWindowNames(UBound(topWindowNames)) = "" Then topWindowNames(UBound(topWindowNames)) = "No-Name"
frmMain.View1.ListItems.Add , , hWnd
frmMain.View1.ListItems.Item(I).SubItems(1) = topWindowClassNames(UBound(topWindowClassNames))
frmMain.View1.ListItems.Item(I).SubItems(2) = topWindowNames(UBound(topWindowNames))
I = I + 1
fGetTopLvLWindowsEnumProc = True 'Tell's EnumWindows to continue
Exit Function
error_Handler:
fGetTopLvLWindowsEnumProc = False 'Tell's EnumWindows to stop
End Function
Public Function fGetTopLvLWindows() As Boolean
On Error GoTo error_Handler
fGetTopLvLWindows = True
ReDim topWindowNames(1) 'Clear's the array
ReDim topWindowClassNames(1) 'Clear's the array
ReDim topWindowHandles(1) 'Clear's the array
topWindowNames(1) = "¬ÑÉÑáѦÖÑä¬"
topWindowClassNames(1) = "¬ÑÉÑáѦÖÑä¬"
topWindowHandles(1) = 0
I = 1
frmMain.View1.ColumnHeaders.Add , , "Handle", ((frmMain.View1.Width / 3) - 110)
frmMain.View1.ColumnHeaders.Add , , "Class Name", ((frmMain.View1.Width / 3) - 110)
frmMain.View1.ColumnHeaders.Add , , "Window", ((frmMain.View1.Width / 3) - 110)
EnumWindows AddressOf fGetTopLvLWindowsEnumProc, False
Exit Function
error_Handler:
fGetTopLvLWindows = False
End Function
topWindowHandles, topWindowNames, and topWindowClassNames are all dimed at the start of the program
'
Public topWindowHandles() As Long
Public topWindowNames() As String
Public topWindowClassNames() As String
'
fGetTopLvLWindows() is called at Form_Load
Everything actually work's but GetClassName put's NULL in topWindowClassNames(UBound(topWindowClassNames)) even though i put nMaxCount to 151, GetWindowText put's NULL in topWindowNames(UBound(topWindowNames)) to, and GetWindowTextLength Return's 0.
That never change's
And i know the Handle to the window is right cause i checked it with another program.
Plz help
This is all in a module:
'Declare's
Public Declare Function GetClassName Lib "user32.dll" Alias "GetClassNameA" (ByVal hWnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Integer
Public Declare Function GetWindowText Lib "user32.dll" Alias "GetWindowTextA" (ByVal hWnd As Long, ByVal lpString As String, ByVal nMaxCount As Long) As Integer
Public Declare Function GetWindowTextLength Lib "user32.dll" Alias "GetWindowTextLengthA" (ByVal hWnd As Long) As Integer
Public Declare Function EnumWindows Lib "user32.dll" (ByVal lpEnumFunc As Long, ByVal lParam As Integer) As Boolean
'Function's
Public Function fGetTopLvLWindowsEnumProc(hWnd As Long, ByVal lParam As Long) As Boolean
Dim tmpWinLen, tmpClassLen As Long
On Error GoTo error_Handler
If topWindowNames(1) <> "¬ÑÉÑáѦÖÑä¬" Then
ReDim Preserve topWindowNames((UBound(topWindowNames) + 1))
End If
If topWindowClassNames(1) <> "¬ÑÉÑáѦÖÑä¬" Then
ReDim Preserve topWindowClassNames((UBound(topWindowClassNames) + 1))
End If
If topWindowHandles(1) <> 0 Then
ReDim Preserve topWindowHandles((UBound(topWindowHandles) + 1))
End If
tmpWinLen = GetWindowTextLength(hWnd)
Call GetWindowText(hWnd, topWindowNames(UBound(topWindowNames)), tmpWinLen + 1)
topWindowHandles(UBound(topWindowHandles)) = hWnd
tmpClassLen = GetClassName(hWnd, topWindowClassNames(UBound(topWindowClassNames)), 151)
If topWindowNames(UBound(topWindowNames)) = "" Then topWindowNames(UBound(topWindowNames)) = "No-Name"
frmMain.View1.ListItems.Add , , hWnd
frmMain.View1.ListItems.Item(I).SubItems(1) = topWindowClassNames(UBound(topWindowClassNames))
frmMain.View1.ListItems.Item(I).SubItems(2) = topWindowNames(UBound(topWindowNames))
I = I + 1
fGetTopLvLWindowsEnumProc = True 'Tell's EnumWindows to continue
Exit Function
error_Handler:
fGetTopLvLWindowsEnumProc = False 'Tell's EnumWindows to stop
End Function
Public Function fGetTopLvLWindows() As Boolean
On Error GoTo error_Handler
fGetTopLvLWindows = True
ReDim topWindowNames(1) 'Clear's the array
ReDim topWindowClassNames(1) 'Clear's the array
ReDim topWindowHandles(1) 'Clear's the array
topWindowNames(1) = "¬ÑÉÑáѦÖÑä¬"
topWindowClassNames(1) = "¬ÑÉÑáѦÖÑä¬"
topWindowHandles(1) = 0
I = 1
frmMain.View1.ColumnHeaders.Add , , "Handle", ((frmMain.View1.Width / 3) - 110)
frmMain.View1.ColumnHeaders.Add , , "Class Name", ((frmMain.View1.Width / 3) - 110)
frmMain.View1.ColumnHeaders.Add , , "Window", ((frmMain.View1.Width / 3) - 110)
EnumWindows AddressOf fGetTopLvLWindowsEnumProc, False
Exit Function
error_Handler:
fGetTopLvLWindows = False
End Function
topWindowHandles, topWindowNames, and topWindowClassNames are all dimed at the start of the program
'
Public topWindowHandles() As Long
Public topWindowNames() As String
Public topWindowClassNames() As String
'
fGetTopLvLWindows() is called at Form_Load
Everything actually work's but GetClassName put's NULL in topWindowClassNames(UBound(topWindowClassNames)) even though i put nMaxCount to 151, GetWindowText put's NULL in topWindowNames(UBound(topWindowNames)) to, and GetWindowTextLength Return's 0.
That never change's
And i know the Handle to the window is right cause i checked it with another program.
Plz help