Hello.
I am getting error 1400 for somereason when calling GetWindowText. However GetWindowTextLenght gives me proper value. Why does GetWindowTextLenght work when GetWindowText gives error 1400? The handle is same for both so it cant be problem.
This is how I test this function:
printf("Title: %s\n", WinGetTitle(GetForegroundWindow()));
I am getting error 1400 for somereason when calling GetWindowText. However GetWindowTextLenght gives me proper value. Why does GetWindowTextLenght work when GetWindowText gives error 1400? The handle is same for both so it cant be problem.
char* WinGetTitle(HWND hWnd){ int lenght = GetWindowTextLength(hWnd); wchar_t* title = L""; GetWindowText(hWnd,title,lenght+1); printf("%d\n",GetLastError()); return (char*)title; }
This is how I test this function:
printf("Title: %s\n", WinGetTitle(GetForegroundWindow()));