"Maarten Lankhorst" m.b.lankhorst@gmail.com wrote:
Probably GetWindowModuleFileNameA should simply allocate a buffer of size MAX_PATH on the stack and fail with ERROR_FILENAME_EXCED_RANGE if unicode counterpart returns a string longer than MAX_PATH. kernel32 APIs behave that way.
What's the point of saving/restoring last error value? If WideCharToMultiByte fails you need to return an error in that case, not silently continue.
Also GetWindowModuleFileNameA also should be fixed to return correct value, and not assume that the buffer is '\0' terminated.
TRACE/WARN/ERR/etc already print the caller's name, there is no need to duplicate it.
GetWindowThreadProcessId already sets the error to the correct value, there is no need to guess why it failed.
Saving/restoring last error value doesn't look correct at all.
There is no need to guess why OpenProcess failed.
Both branches above should be merged, that will simplify the code. Just '\0' terminate the result if there is enough space in the provided buffer.
Left-over from debugging?
On 08/02/2008, Dmitry Timoshkov dmitry@codeweavers.com wrote:
The usual model is something like this:
SetLastError(0xdeadbeef); WinApiCall(); ok(GetLastError() == ERROR_SUCCESS, "WinApiCall failed, expected ERROR_SUCCESS, got %d", GetLastError());
- Reece
After reading MSDN and guessing from the API name shouldn't it simply fetch GWL_HINSTANCE and call GetModuleFileName on it?
"Dmitry Timoshkov" dmitry@codeweavers.com wrote:
And after looking at GetModuleFileNameW implementation, shouldn't it treat hModule == 0 as GetModuleHandle(0) and not be 16-bit specific? Guess this all needs a test case.
Hi folks,
2008/2/8, Dmitry Timoshkov dmitry@codeweavers.com:
I've tried to do the GetWindowLongPtr GWLP_HINSTANCE thing but it seems to always return 0 in wine, which according to msdn means error, but it could just be not set in wine. Perhaps GWLP_HINSTANCE needs to be set when the window is being created?
Cheers, Maarten.
"Maarten Lankhorst" m.b.lankhorst@gmail.com wrote:
It works just fine in Wine, have a look at dlls/user32/tests/class.c, test_instances().