Manipulating the positions of desktop icons

南笙酒味 提交于 2020-07-28 04:58:14

问题


I am currently trying to retrieve the list of icons from my desktop to change their locations and / or hide them as well as display others.

I tried to get the FolderView in the code below but it doesn't even show the number of icons I have on the desktop because 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;

I did tests on the variables and is noticed that hDefView is NULL.
Probably the reason why count return 0.

EDIT : After replace GetDesktopWindow by GetShellWindow the result is always the same, 0


回答1:


The shell window hierarchy is not documented nor stable. "ProgMan" is usually the parent of "SHELLDLL_DefView" but if you change to slideshow wallpaper it can also be "WorkerW".

It is much better to inspect/manipulate the desktop with the documented shell COM interfaces: IShellWindows, IShellBrowser, IFolderView and IShellFolder.



来源:https://stackoverflow.com/questions/49964260/manipulating-the-positions-of-desktop-icons

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!