相关疑难解决方法(0)

如何让EnumWindows列出所有窗口?

我假设,我问的实际上应该是默认值,但我遇到了一些我不理解的行为.

#include "stdafx.h"

using namespace std;

BOOL CALLBACK enumWindowsProc(
  __in  HWND hWnd,
  __in  LPARAM lParam
) {
  if( !::IsIconic( hWnd ) ) {
    return TRUE;
  }

  int length = ::GetWindowTextLength( hWnd );
  if( 0 == length ) return TRUE;

  TCHAR* buffer;
  buffer = new TCHAR[ length + 1 ];
  memset( buffer, 0, ( length + 1 ) * sizeof( TCHAR ) );

  GetWindowText( hWnd, buffer, length + 1 );
  tstring windowTitle = tstring( buffer );
  delete[] buffer;

  wcout << hWnd …
Run Code Online (Sandbox Code Playgroud)

c++ windows winapi

10
推荐指数
3
解决办法
4万
查看次数

标签 统计

c++ ×1

winapi ×1

windows ×1