#ifdef	_UNICODE
#define	 UNICODE
#endif
#include	<Windows.h>
#include	<iostream>
#include	<vector>
#include	<TChar.h>
#ifdef	_UNICODE
	#define	tout	wcout
#else
	#define	tout	cout
#endif
class	EnumWindow	{
public:
	static	int	CALLBACK	CB_EnumWindows	(HWND hwnd,LPARAM lparam) ;
protected:
public:
	std::vector<HWND>	HWNDs ;
	} ;
inline	BOOL	CALLBACK	EnumWindow::CB_EnumWindows	(HWND hwnd,LPARAM lp_this)
{
	EnumWindow*		p_this = (EnumWindow*)lp_this ;
	p_this->HWNDs.push_back(hwnd) ;
	return	TRUE ;
	}
int	_tmain	(void)
{
	EnumWindow	ew ;
	{
		::EnumWindows((WNDENUMPROC)EnumWindow::CB_EnumWindows,(LPARAM)&ew) ;
		}
	for (size_t index=0 ; index<ew.HWNDs.size() ; index++) {
		HWND	hWnd = ew.HWNDs[index] ;
		if (::IsWindowVisible(hWnd)) {
			TCHAR	title[256] ;
			if (::GetWindowText(hWnd,title, sizeof(title)) && _tcslen(title) > 0) {
				std::tout << _T("HWND: ") << hWnd << _T(", Title: ") << title << std::endl;
				}
			}
		}
	return	0 ;
	}これらを調べている時 ::GetWindowModuleFileName を見つけた.
それで ::GetWindowModuleFileName(hWnd,…) と呼び出してみたが,期待したものではなかった.
その exe 自身のファイル名が返される.::GetModuleFileName を呼び出しているのと変わらない?
INFO: GetWindowModuleFileName & GetModuleFileName Work Only with the Calling Process
FindWindow
EnumWindows
他のプログラムのウインドウハンドルを取得する
C++: プロセスを取得して色々やってみた
【C++】ウィンドウハンドルの5つの取得方法【基本と応用】
