WinApi GetWindowModuleFileNameW

Hi,

i have a little problem with the GetWindowModuleFileNameW. I'm enumerating all desktops and all windows on them and want to get the moduleNames of each desktop.

For some windows it works fine. But there are some window, which name i cant get and i dont know why. There are just some square-signs (unknown symbols or something like that). In Debugger:
0x01474730 L"쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌...


DO you have an idea to solve this problem?

Heres my code:


void CMFCApplication3Dlg::TestFunktion()
{
	while(true){
		Sleep(1000);
		EnumWindowStations(EnumWindowStationProc, NULL); 
	}
}

BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam)
{
    TITLEBARINFO ti;
	ti.cbSize = sizeof(ti);
    GetTitleBarInfo(hwnd, &ti);
    if(ti.rgstate[0] & STATE_SYSTEM_INVISIBLE)
        return TRUE;

    // Tool windows should not be displayed either, these do not appear in the
    // task bar.
    if(GetWindowLong(hwnd, GWL_EXSTYLE) & WS_EX_TOOLWINDOW)
        return TRUE;

	wchar_t name[100]; 
	GetWindowModuleFileNameW(hwnd, name, 100);
	if(wcslen(name)<2)
	{
		return TRUE;
	}
	if(counter <= 500)
	{
		for(int i = 0; i < 100; ++i)
		{
			names[counter][i] = name[i];
		}
	}
	++counter;
    return TRUE;
}
BOOL CALLBACK EnumDesktopProc(LPTSTR lpszDesktop, LPARAM lParam)
{
    ...
    return true;
}

BOOL CALLBACK EnumWindowStationProc( LPTSTR lpszWindowStation,LPARAM lParam)
{
    ...
    return true;
}

Last edited on
Please read this:
http://support.microsoft.com/?id=228469

Your code only works correctly in windows 95/98 :)
Last edited on
Thanks :-) this solved my problem.

But now i have a new one, which i can't easily solve via mdn or google, because i have no idea how i could start solving it, if you know what i mean ;-)

The problem is, i can check if a window is visible, if it is just a tray ... or something else... to filter out the users window.

But how can i check if the opened window is a Folder? The Title just says (for example) "abc" without a hint that it is a folder/explorer or something like this.

I tried it via
DWORD processID[] = {NULL};
	GetWindowThreadProcessId(hwnd, processID);

	HANDLE ph = OpenProcess(PROCESS_QUERY_INFORMATION, 0, *processID);
	HMODULE module = NULL;
	DWORD needed = NULL;
	wchar_t szProcessName[260] = L"<UNKNOWN>";
	EnumProcessModulesEx(ph, &module, sizeof(DWORD), &needed, false);
	{
		K32GetProcessImageFileNameW(ph,szProcessName , 260);		
    }
	DWORD lpdwHandle[] = {NULL};
	GetFileVersionInfoSizeExW(FILE_VER_GET_NEUTRAL,szProcessName, lpdwHandle);
	LPVOID data = new LPVOID();
	GetFileVersionInfoExW(FILE_VER_GET_NEUTRAL,szProcessName,0,*lpdwHandle,data);
	if( VerQueryValue( data,L"\\", (LPVOID *) &data, (PUINT)&lpdwHandle ) )


But i just get ... nothing. :(



Do you have a hint for me? Not a complete solution, just a hint :-)

best regards.
the win32 api has IsIconic() which returns TRUE if a window is minimized. GetActiveWindow() will return the current active window and GetFocus() will return the window that has keyboard focus
Topic archived. No new replies allowed.