Wie kann ich EnumWindows dazu bringen, alle Fenster aufzulisten?

Ich gehe davon aus, dass das, wonach ich frage, eigentlich die Standardeinstellung sein sollte, aber ich habe ein Verhalten, das ich nicht verstehe.

<code>#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 << TEXT( ": " ) << windowTitle << std::endl;

  return TRUE;
}

int _tmain( int argc, _TCHAR* argv[] ) {
  wcout << TEXT( "Enumerating Windows..." ) << endl;
  BOOL enumeratingWindowsSucceeded = ::EnumWindows( enumWindowsProc, NULL );
  cin.get();
  return 0;
}
</code>

Wenn ich diesen Code aufrufe, werden alle minimierten Fenster aufgelistet:

Jetzt interessieren mich nicht mehr nur die minimierten Fenster, jetzt möchte ich alle. Also entferne ich dieIsIconic prüfen:

<code>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 << TEXT( ": " ) << windowTitle << std::endl;

  return TRUE;
}
</code>

Jetzt bekomme ich alle Fensteraußer die minimierten (keines der zuvor aufgelisteten Fensterhandles wird dieses Mal aufgelistet):

Der Vollständigkeit halber ist dies dasstdafx.h:

<code>#pragma once

#include "targetver.h"


#include <iostream>
#include <map>
#include <string>

namespace std {
  #if defined _UNICODE || defined UNICODE
    typedef wstring tstring;
  #else
    typedef string tstring;
  #endif
}

#include <stdio.h>
#include <tchar.h>
#include <Windows.h>
#include <psapi.h>
</code>
Was mache ich falsch?

Antworten auf die Frage(4)

Ihre Antwort auf die Frage