Puede usar Spy ++ para encontrar qué ventana es la ventana de fondo del escritorio.
En mi sistema Veo la siguiente jerarquía:
- Ventana 000100098 "Gestor de programas" Progman
- Ventana 0001009E "" SHELLDLL_DefView
- Ventana 00100A0 "FolderView" SysListView32
Supongo que se refiere al SysListView32 - la ventana con todos los iconos. Puede usar FindWindowEx para encontrar esta ventana.
Editar Debe usar una combinación de FindWindowEx y EnumerateChildWindows. El código se presenta a continuación puede ser compilado en una caja de línea de comandos de la siguiente manera: cl /EHsc finddesktop.cpp /DUNICODE /link user32.lib
#include <windows.h>
#include <iostream>
#include <string>
BOOL CALLBACK EnumChildProc(HWND hwnd, LPARAM lParam)
{
std::wstring windowClass;
windowClass.resize(255);
unsigned int chars = ::RealGetWindowClass(hwnd, &*windowClass.begin(), windowClass.size());
windowClass.resize(chars);
if (windowClass == L"SysListView32")
{
HWND* folderView = reinterpret_cast<HWND*>(lParam);
*folderView = hwnd;
return FALSE;
}
return TRUE;
}
int wmain()
{
HWND parentFolderView = ::FindWindowEx(0, 0, L"Progman", L"Program Manager");
if (parentFolderView == 0)
{
std::wcout << L"Couldn't find Progman window, error: 0x" << std::hex << GetLastError() << std::endl;
}
HWND folderView = 0;
::EnumChildWindows(parentFolderView, EnumChildProc, reinterpret_cast<LPARAM>(&folderView));
if (folderView == 0)
{
std::wcout << L"Couldn't find FolderView window, error: 0x" << std::hex << GetLastError() << std::endl;
}
HWND desktopWindow = ::GetDesktopWindow();
std::wcout << L"Folder View: " << folderView << std::endl;
std::wcout << L"Desktop Window: " << desktopWindow << std::endl;
return 0;
}
Éstos son los resultados después de ejecutar finddesktop.exe
Folder View: 000100A0
Desktop Window: 00010014
Como se puede ver los identificadores de ventana son bastante diferentes.
Cambio la primera línea con escritorio = FindWindowEx (NULL, NULL, L "SysListView32", NULL); pero creo que tiene la misma ventana que GetDesktopWindow, ya que tiene el mismo efecto. – Razvi