Search code examples
c#desktopbackground-colorwallpaper

How to hide Windows Desktop and change desktop background color in c#?


I need to know how to hide Windows Desktop and change desktop background color in c# and restore the previous configuration.

Any idea?

BR


Solution

  • Enumerate all desktop window with EnumWindows. Collect every visible window handle.

    Call ShowWindow with appropriate arguments to make the collected windows to be visible/invisible.

    Take note that all created windows after this operation will be visible. To hide desktop icons you shall spy the window structure (with a tool like Spy++), get specific window handle by its class name and then call ShowWindow on the obtained widnow handle.

    Of course, EnumWindows and ShowWindow must be P/Invoked. See www.pinvoke.net for getting the correct declaration.