'GetFWin  枚举所有父窗口
'GetFWinZ 枚举所有子窗口
'返回数组从1开始，0表示没有
Common Shared  AddL() as HWnd,AddU as Integer,AddC as Integer
Function GetFWin(L() as HWnd) as Integer '枚举所有父窗口
   Dim I as Integer
   AddU = 0
   AddC = 0
   EnumWindows CPtr(WNDENUMPROC, @AddtoList), 0& 
   ReDim L(AddU)
   
   For I = 1 To AddU
      l(I) = addl(i)
   Next
   Erase AddL
   Function = AddU
End Function
Function GetFWinZ(sHWnd as HWnd, L() as HWnd) as Integer  '枚举所有子窗口
   Dim I as Integer
   AddU = 0
   AddC = 0
   EnumChildWindows sHWnd, CPtr(WNDENUMPROC, @AddtoList), 0& 
   ReDim L(AddU)
   For I = 1 To AddU
      l(I) = addl(i)
   Next
   Erase AddL
   Function = AddU
End Function

Function AddtoList(ByVal aHWnd as HWnd, ByVal lParam as HWnd) as Integer
   AddU = AddU + 1
   If AddU >= AddC Then
      AddC = AddC + 50
      ReDim Preserve AddL(AddC)
   End If
   AddL(AddU) = aHWnd
   Function = 1
End Function