"Alexandre Julliard" julliard@winehq.org wrote:
"Maarten Lankhorst" m.b.lankhorst@gmail.com writes:
@@ -3121,9 +3133,21 @@ UINT WINAPI GetWindowModuleFileNameA( HWND hwnd, LPSTR lpszFileName, UINT cchFil */ UINT WINAPI GetWindowModuleFileNameW( HWND hwnd, LPWSTR lpszFileName, UINT cchFileNameMax) {
- FIXME("GetWindowModuleFileNameW(hwnd %p, lpszFileName %p, cchFileNameMax %u) stub!\n",
hwnd, lpszFileName, cchFileNameMax);
- return 0;
- HINSTANCE hInst;
- UINT ret;
- TRACE("hwnd %p, lpszFileName %p, cchFileNameMax %u\n", hwnd, lpszFileName, cchFileNameMax);
- hInst = (HINSTANCE)GetWindowLongPtrW(hwnd, GWLP_HINSTANCE);
- if (!hInst)
- {
if (hwnd == GetDesktopWindow() || !IsWindow(hwnd))
return 0;
hInst = GetModuleHandleW(0);
- }
- ret = GetModuleFileNameW(hInst, lpszFileName, cchFileNameMax);
- TRACE("--> %d %s\n", ret, debugstr_wn(lpszFileName, ret));
- return ret;
This won't work across processes.
Looks like GetWindowModuleFileName is not supposed to work for other process windows, at least in the following snippet both GetWindowLongPtr and GetWindowModuleFileName return 0 but don't change the last error value under XP although FindWindow returns a valid window handle:
hwnd = FindWindow("Shell_TrayWnd", NULL); SetLastError(0xdeadbeef); ret = GetWindowModuleFileNameA(hwnd, buf, sizeof(buf)); printf("hwnd %p, ret %u, buf "%s", error %u\n", hwnd, ret, buf, GetLastError());
SetLastError(0xdeadbeef); hinst = (HINSTANCE)GetWindowLongPtr(hwnd, GWLP_HINSTANCE); printf("hwnd %p, hinst %u, error %u\n", hwnd, ret, GetLastError());
GetWindowLong(hwnd, GWL_STYLE) returns a valid style. Both APIs behave the same way for the desktop window.
So the above implementation of GetWindowModuleFileName looks correct except a special case for the desktop window (GetWindowLong() should be fixed instead).