Tutorial :How to hide desktop icons by double clicking the desktop using c#


I wanted to know if there is a way to toggle desktop icon to show/hide when the desktop is double clicked. Similar to how it is done in Stardock Fences. I wanted it to be done using visual c#.


The second part of your question (when the desktop is double-clicked) is relative simple. You need to install an application-defined hook procedure into a hook chain. Sounds pretty difficult, but is explained in detail in the code sample found here. You may want to download the source here (requires a free account there).

For the first part, the hiding/unhiding of desktop icons, I found several similar code samples like this, however, none seem to work on my pc so you might want to look for another solution to that problem.


For hiding the desktop icons there is a registry key (have a look here).

I guess you will have to restart your explorer after that to apply the changes by using

        Process[] proc = Process.GetProcessesByName("Explorer");          foreach(Process p in proc)              p.Kill();            Process.Start("explorer.exe");  


i dont know how you would show/hide the desktop icons using C#, however i have read a few articles about how to do it using the resistry keys. the problem with using the registry keys method is that the "Explorer.exe" process would have to be restarted in order for the changes to take affect. luckily i found a code sample online that does just that:

On Error Resume Next    ' Kill Explorer.exe    strComputer = "."    Set objWMIService = GetObject("winmgmts:" _  & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")    Set colProcessList = objWMIService.ExecQuery _  ("Select * from Win32_Process Where Name = 'explorer.exe'")    For Each objProcess in colProcessList  objProcess.Terminate(1)  Next    ' Launch Explorer.exe    Set objShell = CreateObject("Wscript.Shell")     objShell.Run "explorer.exe"     Set objShell = Nothing    Wscript.exit  

That script will quickly restart the "Explorer.exe" process without logging the current user off.... Hope it Helps!

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »