1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
|
#include <QtCore/QCoreApplication>
#include <iostream>
#include <windows.h>
#include <psapi.h>
BOOL CALLBACK EnumWindowsProcCallBack(HWND hWnd, LPARAM lParam) {
char MyTxt[255];
if (!hWnd)
return TRUE; // Not a window
if (!::IsWindowVisible(hWnd))
return TRUE; // Not visible
if (!SendMessage(hWnd, WM_GETTEXT, sizeof(MyTxt), (LPARAM)MyTxt))
return TRUE; // No window title
std::cout << "Found a window" << std::endl;
GetWindowText(hWnd, MyTxt, 255);
std::cout << MyTxt << std::endl;
return TRUE;
}
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
std::cout << "Main is running" << std::endl;
EnumWindows(EnumWindowsProcCallBack, NULL);
return a.exec();
} |
Partager