'retrieve text
'   获取指定控件的文本
'   hWndControl: 控件的句柄 (例如  HWND_FORM1_COMMAND1)
'   Returns:     The actual text.
Function FF_Control_GetText(ByVal hWndControl As HWND) As CWSTR
   '检查窗口句柄是否有效
   Dim nBufferSize As Long
   Dim nBuffer() As Byte
   '检查窗口句柄是否有效
   If IsWindow(hWndControl) Then
      '得到的文本的长度
      nBufferSize = GetWindowTextLengthW(hWndControl)
      If nBufferSize = 0 Then Return ""
      nBufferSize += 1
      ReDim nBuffer(nBufferSize * 2)
      GetWindowTextW hWndControl, Cast(Wstring Ptr, @nBuffer(0)), nBufferSize
      Return *CPtr(WString Ptr, @nBuffer(0))
   Else
      Return ""
   End If
End Function

