带有部分窗口标题的 FindWindow(Windows、C)

发布于 2024-08-01 14:25:01 字数 223 浏览 3 评论 0原文

是否有任何类似于 FindWindow() 但通过部分标题搜索窗口的 API? 原因是我需要一个窗口的句柄,该窗口的标题有固定部分,但其他部分不断变化。 例如,窗口标题可以是:

DataBase read: XYDB

DataBase read: WZDB

在示例中,修复部分是“DataBase read:”

代码赞赏。 谢谢

Is there any API similar to FindWindow() but that searches the windows by partial title?
The reason is that I need to the handle to a window that has a fix part on the title but the other part changes constantly.
So for example the window title could be:

DataBase read: XYDB

or

DataBase read: WZDB

in the examples the fix part is "DataBase read:"

Code appreciated.
Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

温柔一刀 2024-08-08 14:25:01

使用 EnumWindows 的示例:

BOOL CALLBACK WorkerProc(HWND hwnd, LPARAM lParam) {
    static TCHAR buffer[50];

    GetWindowText(hwnd, buffer, 50);
    if(_tcsstr(buffer, "window name goes here")) {
        // do something with hwnd here
        return FALSE;
    }

    return TRUE;
}

然后像这样调用它:

EnumWindows(WorkerProc, NULL);

An example using EnumWindows:

BOOL CALLBACK WorkerProc(HWND hwnd, LPARAM lParam) {
    static TCHAR buffer[50];

    GetWindowText(hwnd, buffer, 50);
    if(_tcsstr(buffer, "window name goes here")) {
        // do something with hwnd here
        return FALSE;
    }

    return TRUE;
}

And then call it like this:

EnumWindows(WorkerProc, NULL);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文