实现步骤
第一步 获取进程的句柄
通过Windows API获取窗口句柄。
代码如下:
// 定义枚举回调函数
BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam)
{
if (!IsWindowVisible(hwnd))
{
return TRUE;
}
std::vector<wstring>& titles = *reinterpret_cast<std::vector<wstring>*>(lParam);
wchar_t titleBuf[512];
if (GetWindowText(hwnd, titleBuf, _countof