#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
中。
我在这里做什么错了?