问题
Does anybody know what would cause the FindWindow function to return the error:
ALREADY_EXISTS error (183)
I could understand a FILE_NOT_FOUND (2)
, but why would it return a 183
?
回答1:
MSDN says, that FindWindowand FindWindowEx return NULL if the function fails and that you should check GetLastError
. It seems that this documentation is wrong. Take this code fragment:
SetLastError(12345);
HWND h = FindWindow(L"class_name_that_does_not_exist", nullptr);
cout << h << ' ' << GetLastError() << endl;
It will output
00000000 12345
So as you can see FindWindow fails to set the last error. In your case this means that the ERROR_ALREADY_EXISTS
was the last error set before FindWindow
was called.
来源:https://stackoverflow.com/questions/6631089/findwindow-error-183