Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I programmatically manipulate Windows desktop icon locations?

Several years back, I innocently tried to write a little app to save my tactically placed desktop icons because I was sick of dragging them back to their locations when some event reset them. I gave up after buring WAY too much time having failed to find a way to query, much less save and reset, my icons' desktop position.

Anyone know where Windows persists this info and if there's an API to set them?

Thanks, Richard

like image 607
ZeroBugBounce Avatar asked Sep 25 '08 06:09

ZeroBugBounce


People also ask

How do I automatically organize desktop icons?

To arrange icons by name, type, date, or size, right-click a blank area on the desktop, and then click Arrange Icons. Click the command that indicates how you want to arrange the icons (by Name, by Type, and so on). If you want the icons to be automatically arranged, click Auto Arrange.

How do I move Windows icons freely?

Try this: right click on the desktop and click "View" from the resulting menu. Then uncheck "auto-arrange icons" You should now be able to move the icons freely.


1 Answers

If I'm not mistaken the desktop is just a ListView, and you'll have to send the LVM_SETITEMPOSITION message to the handle of the desktop.

I googled a bit for some c# code and couldn't find a example, but I did found the following article. Torry: ...get/set the positions of desktop icons?. It's delphi code, but I find it very readable and with some P/Invokes you'll be able to translate it to c#.

like image 170
Davy Landman Avatar answered Sep 18 '22 13:09

Davy Landman