Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7850097
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T18:44:35+00:00 2026-06-02T18:44:35+00:00

In a previous question, there was an explanation how to hide desktop items: How

  • 0

In a previous question, there was an explanation how to hide desktop items:

How to hide desktop icons programatically?

For some reason, this code doesn’t work for me.

I would have simply commented on the above link, but I don’t have enough privileges to comment on other people’s questions…

Any ideas what’s going wrong? The desktop simply doesn’t hide.

UPDATE: Additionally, I tried using the following code (as was suggested here), but still no effect:

struct SHELLSTATE
{
      bool fShowAllObjects;
      bool fShowExtensions;
      bool fNoConfirmRecycle;
      bool fShowSysFiles;
      bool fShowCompColor;
      bool fDoubleClickInWebView;
      bool fDesktopHTML;
      bool fWin95Classic;
      bool fDontPrettyPath;
      bool fShowAttribCol;
      bool fMapNetDrvBtn;
      bool fShowInfoTip1;
      bool fHideIcons1;
      bool fWebView1;
      bool fFilter1;
      bool fShowSuperHidden1;
      bool fNoNetCrawling1;
      UInt32 dwWin95Unused;
      uint uWin95Unused;
      long lParamSort;
      int   iSortDirection;
      uint version;
      uint uNotUsed;
      bool fSepProcess;
      bool fStartPanelOn;
      bool fShowStartPage;
      bool fAutoCheckSelect;
      bool fIconsOnly;
      bool fShowTypeOverlay;
      uint fSpareFlags;
}

class MyClass
{
    const UInt32 SSF_HIDEICONS = 0x00004000;

    [DllImport("Shell32.dll")]
    static extern void SHGetSetSettings(ref SHELLSTATE state, UInt32 dwMask, bool bSet);
    static void Foobar()
    {
        SHELLSTATE stateOfMind = new SHELLSTATE();
        Console.WriteLine("Set to true:");
        SHGetSetSettings(ref stateOfMind, SSF_HIDEICONS, true);
        Console.ReadKey();
        Console.WriteLine("Set to false:");
        SHGetSetSettings(ref stateOfMind, SSF_HIDEICONAS, false);
        Console.ReadKey();
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T18:44:38+00:00Added an answer on June 2, 2026 at 6:44 pm

    Here is sample code in C# that will toggle desktop icons.

    [DllImport("user32.dll", SetLastError = true)] static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
    [DllImport("user32.dll", SetLastError = true)] static extern IntPtr GetWindow(IntPtr hWnd, GetWindow_Cmd uCmd);
    enum GetWindow_Cmd : uint
    {
        GW_HWNDFIRST = 0,
        GW_HWNDLAST = 1,
        GW_HWNDNEXT = 2,
        GW_HWNDPREV = 3,
        GW_OWNER = 4,
        GW_CHILD = 5,
        GW_ENABLEDPOPUP = 6
    }
    [DllImport("user32.dll", CharSet = CharSet.Auto)] static extern IntPtr SendMessage(IntPtr hWnd, UInt32 Msg, IntPtr wParam, IntPtr lParam);
    
    private const int WM_COMMAND = 0x111;
    
    static void ToggleDesktopIcons()
    {
        var toggleDesktopCommand = new IntPtr(0x7402);
        IntPtr hWnd = GetWindow(FindWindow("Progman", "Program Manager"), GetWindow_Cmd.GW_CHILD);
        SendMessage(hWnd, WM_COMMAND, toggleDesktopCommand, IntPtr.Zero);
    }
    

    This sends a message to the SHELLDLL_DefView child window of Progman, which tells it to toggle visibility (by adding or removing the WS_VISIBLE style) of it’s only child, “FolderView”. “FolderView” is the actual window that contains the icons.

    To test to see if icons are visible or not, you can query for the WS_VISIBLE style by using the GetWindowInfo function, shown below:

    [return: MarshalAs(UnmanagedType.Bool)]
    [DllImport("user32.dll", SetLastError = true)]
    private static extern bool GetWindowInfo(IntPtr hwnd, ref WINDOWINFO pwi);
    
    [StructLayout(LayoutKind.Sequential)]
    public struct RECT
    {
        private int _Left;
        private int _Top;
        private int _Right;
        private int _Bottom;
    }
    
    [StructLayout(LayoutKind.Sequential)]
    struct WINDOWINFO
    {
        public uint cbSize;
        public RECT rcWindow;
        public RECT rcClient;
        public uint dwStyle;
        public uint dwExStyle;
        public uint dwWindowStatus;
        public uint cxWindowBorders;
        public uint cyWindowBorders;
        public ushort atomWindowType;
        public ushort wCreatorVersion;
    
        public WINDOWINFO(Boolean? filler)
            : this()   // Allows automatic initialization of "cbSize" with "new WINDOWINFO(null/true/false)".
        {
            cbSize = (UInt32)(Marshal.SizeOf(typeof(WINDOWINFO)));
        }
    
    }
    

    Here is a function that calls the above code and returns true if the window is visible, false if not.

    static bool IsVisible()
    {
        IntPtr hWnd = GetWindow(GetWindow(FindWindow("Progman", "Program Manager"), GetWindow_Cmd.GW_CHILD), GetWindow_Cmd.GW_CHILD);
        WINDOWINFO info = new WINDOWINFO();
        info.cbSize = (uint)Marshal.SizeOf(info);
        GetWindowInfo(hWnd, ref info);
        return (info.dwStyle & 0x10000000) == 0x10000000;
    }
    

    The windows API code along with more information about the window styles can be found here: http://www.pinvoke.net/default.aspx/user32/GetWindowInfo.html

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is related to my previous question, but will navigator.onLine work if there is
This question is related to a previous post . Is there something comparable to
This question is related with one of my earlier questions.. Previous Post In there
This question is related to a previous question of mine That's my current code
There was a previous question on StackOverflow about this subject (can insert the link,
My previous question about this subject was answered and I got some tests working
Related to my previous question , is there some realistic chance to extract surveillance
This is a generalized version of a previous question regarding Sphinx . Is there
This is an extension of my previous question, Application crash with no explanation .
this is a continuation of my previous question is there off-the-shelf convenient way to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.