操纵桌面图标的位置

Manipulating the positions of desktop icons

我目前正在尝试从我的桌面检索图标列表以更改它们的位置和/或隐藏它们以及显示其他图标。

我试图在下面的代码中获取 FolderView,但它甚至没有显示桌面上的图标数量,因为 count return 0.

HWND hDesktop = GetDesktopWindow();
HWND hDefView = FindWindowEx(hDesktop, NULL, L"SHELLDLL_DefView", NULL);
HWND folderView = FindWindowEx(hShellWnd, NULL, L"SysListView32", NULL);

int count = (int) SendMessage(folderView, LVM_GETITEMCOUNT, 0, 0);
cout << count << endl;

我对变量进行了测试,发现 hDefViewNULL
大概是count return 0.

的原因

编辑:GetDesktopWindow 替换为 GetShellWindow 结果始终相同,0

shell window 层次结构没有记录也没有稳定。 "ProgMan" 通常是 "SHELLDLL_DefView" 的父级,但如果您更改为幻灯片墙纸,它也可以是 "WorkerW"。

inspect/manipulate the desktop with the documented shell COM interfaces: IShellWindowsIShellBrowserIFolderViewIShellFolder要好得多。