Hi all!
I've tried several snippets and get the same result every time.
Im using VB6 SP5, developing on WinXP SP3
Here's a simple segment that should work but gives the error:
"Invalid use of AddressOf operator."
Can someone help?
Thanks!
I've tried several snippets and get the same result every time.
Im using VB6 SP5, developing on WinXP SP3
Here's a simple segment that should work but gives the error:
"Invalid use of AddressOf operator."
Code:
Private Declare Function EnumWindows Lib "user32.dll" (ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
Private Sub Form_Load()
Call Main
End Sub
Public Sub Main()
' Main starts the enumeration, pass the address of the callback function
Debug.Print "============================="
Debug.Print " Start of enumeration:"
If EnumWindows(AddressOf EnumWindows_CallBack, 0) = 0 Then
Err.Raise 12345, , "Could not enumerate all windows!"
End If
Debug.Print "============================="
End Sub
Private Function EnumWindows_CallBack(ByVal hWnd As Long, ByVal lParam As Long) As Long
' This function is called from the EnumWindows API
Debug.Print "hWnd Found: " & hWnd
EnumWindows_CallBack = 1 ' The API ends if we return false
End Function
Thanks!