Right-click on desktop, uncheck view->Show Desktop icons. All icons on desktop will disappear. Is it possible to show/hide desktop icons from c++ application? Do you have an example of c++ code for it? Thanks a lot in advance for any suggestions.
Asked
Active
Viewed 4,281 times
4
-
Why do you want to do this? The desktop belongs to the user, not to your program, you should not mess with it unless the user explicitly asks you to. If you do have a good reason for changing this setting, using the API SHGetSetSettings (see answer below) is likely the best approach to use. – BrendanMcK Nov 17 '11 at 07:12
-
Oh, this was quite old question. I needed this for golf simulator. It used WindowsXP as platform, but the device was designed that user will never see and use Windows features. Immediately after system started our application was launched and it lived until "switch off" the simulator. I needed to hide the windows icons during application update. The Cogwheel's answer worked for me, but I agree that the "SHGetSetSettings fHideIcons" sounds more robust. – jing Nov 18 '11 at 11:12
-
Got it - for some reason this came up in the RSS feed as a "recent" question. For what it's worth, likely the right thing to do in this type of case is to find docs on how to implement a 'kiosk mode' or to replace the shell. The catch with just deleting the desktop icons is that a savy hacker can still use other shell features - like pressing windows-E to bring up explorer - and find ways to mess with the system. Hiding the icons may be fine for a simple classroom project, however, but not a good approach in a real-world app. – BrendanMcK Nov 18 '11 at 11:19
2 Answers
7

Sheng Jiang 蒋晟
- 15,125
- 2
- 28
- 46
-
+1 - unlike the other hacks suggested here, this is the actual Windows way of doing it. – BrendanMcK Nov 17 '11 at 07:11
-4
Everything is much easier. You can easily change Icon position or hide them all.
HWND DesktopHandle = FindWindow("ProgMan", 0);
SendMessage(DesktopHandle, LVM_DELETEALLITEMS, 0, 0);
More code how to manipulate desktop items
-
-1: The ProgMan window itself is not a listview, so LVM_ messages won't work there. It's the descendant child window you want - and there's no guarantee that it will continue to be a listview in later versions of windows- shell folders have already changed to using a different class. It also won't persist the result. – BrendanMcK Nov 17 '11 at 07:10