【发布时间】:2011-10-31 07:57:24
【问题描述】:
如何检查特定窗口是否打开。我只得到了窗口名称的一部分。我想在 QT 控制台应用程序中使用 EnumWindows() 但我收到一些错误,说明“main.obj:-1: error: unresolved external symbol imp__GetWindowTextW@12 referenced in function "int __stdcall EnumWindowsProc(struct HWND *,long)" (?EnumWindowsProc@@YGHPAUHWND__@@J@Z)"
下面是我的示例代码
BOOL CALLBACK EnumWindowsProc(HWND hWnd, long lParam) {
char buff[255];
if (IsWindowVisible(hWnd)) {
GetWindowText(hWnd, (LPWSTR) buff, 254);
}
return TRUE;
}
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
EnumWindows(EnumWindowsProc, 0);
return 0;
}
【问题讨论】:
-
我在这里做了几个假设,但是你链接的是 user32.lib 吗?
-
我通过添加#include
成功地编译了我的 QT 应用程序