GetWindowText始终返回空字符串

时间:2018-10-02 00:34:06

标签: c++ windows winapi

#include <iostream>
#include <Windows.h>
#include <tchar.h>
#include <atlstr.h>

using namespace std;

BOOL CALLBACK createWindow(HWND input, LPARAM lParam)
{
    if (IsWindowVisible(input))
    {
        TCHAR buf[30];

        int titleLength = GetWindowText(input, buf, 30);

        cout << titleLength << endl;
    }

    return true;
}

int main()
{
    EnumWindows(&createWindow, 0);

此代码始终输出0(表示空字符串),并且不将标题名称保存在buf中。

我在这里做什么错了?

0 个答案:

没有答案
相关问题