Hello All,
When a Win32 API method allows AddressOf MethodName to be resolved to a Long, how do you handle that in .Net? See example code below which works fine in VB but throws an error when I try to convert it.
Old VB Code
Declare Function EnumThreadWindows Lib "user32" (ByVal dwThreadId As Long, ByVal lpfn As Long, ByVal lParam As Long) As Long
Public Sub MySub(ByVal hWnd As Long)
Dim ThreadID As Long, ProcessID As Long
ThreadID = GetWindowThreadProcessId(hWnd, ProcessID)
' Use the callback function to list all of the enumerated thread windows
Call EnumThreadWindows(ThreadID, AddressOf EnumThreadWndProc, 0)
End Sub
Public Function EnumThreadWndProc(ByVal hWnd As Long, ByVal lParam As Long) As Long
' My code goes here
' Continue the enumeration.
EnumThreadWndProc = 1
End Function
I get errors with the AddressOf EnumThreadWndProc because it cannot be converted to a Long because it is a delegate type. Thanks in advance for any ideas and/or suggestions!