GetWindowText function Null safety user32

int GetWindowText(
  1. int hWnd,
  2. Pointer<Utf16> lpString,
  3. int nMaxCount

Copies the text of the specified window's title bar (if it has one) into a buffer. If the specified window is a control, the text of the control is copied. However, GetWindowText cannot retrieve the text of a control in another application.

int GetWindowTextW(
  HWND   hWnd,
  LPWSTR lpString,
  int    nMaxCount


int GetWindowText(int hWnd, Pointer<Utf16> lpString, int nMaxCount) {
  final _GetWindowText = _user32.lookupFunction<
      Int32 Function(IntPtr hWnd, Pointer<Utf16> lpString, Int32 nMaxCount),
      int Function(
          int hWnd, Pointer<Utf16> lpString, int nMaxCount)>('GetWindowTextW');
  return _GetWindowText(hWnd, lpString, nMaxCount);