VB的EnumChildWindows如何改 VB.net?
我尝试在VB.net中调用API EnumChildWindows 时出错,代码如下:
Public Class GetChildWindows
Dim tmpStr As String = ""
Private Declare Unicode Function EnumChildWindows Lib "user32" Alias "EnumChildWindows" _
(ByVal hWndParent As Long, _
ByVal lpEnumFunc As Long, _
ByVal lParam As Long) _
As Long
Public Function GetChildWins(ByVal pHwnd As Long, ByRef str As String) As Long
EnumChildWindows(pHwnd, AddressOf EnumChildPro, 0)'提示 AddressOf EnumChildPro 不是委托类型
str = tmpStr
Return 0
End Function
Private Function EnumChildPro(ByVal nHwnd As Long, ByVal lParam As Long) As Long
tmpStr = tmpStr & "|" & nHwnd
Return True
End Function
End Class
请教该如何修改? VB?.net?委托 VB.net 委托 API Delegate
[解决办法]
Long全部修改成Integer。
定义一个委托,EnumWindowsDelegate(Byval hwnd As Integer, Byval lParam as Integer) As Interger,然后ByVal lpEnumFunc As EnumWindowsDelegate