如何在不重新启动计算机的情况下隐藏桌面图标

时间:2018-08-17 14:49:46

标签: c# c++ windows winapi show-hide

我一直试图隐藏我的桌面图标,类似于右键单击“桌面”>“查看隐藏桌面图标”。我发现了一些使用C#或C ++进行操作的方法,但是直到重新启动计算机后,该方法才生效。

有没有一种方法可以像Windows一样重新启动而无需重启。我也发现一些使用winAPI和shell的软件,如果您能帮助我也使用其中之一,我将不胜感激。这是到目前为止我尝试过的许多代码:

private const int SW_HIDE = 0;
private const int SW_SHOW = 5;

[DllImport("user32.dll", CharSet = CharSet.Auto)]
static extern int SystemParametersInfo(int uAction, int uParam, string lpvParam, int fuWinIni);

[DllImport("user32.dll")]
public static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);

[DllImport("user32.dll", SetLastError = true)]
static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);

public static void Main( string[] args ){
      //.... Irrelevant code ...

      Console.Writeline(" Goodbye Icons ");
      IntPtr hWnd = FindWindowEx(IntPtr.Zero, IntPtr.Zero, "Progman", null);
      ShowWindow(hWnd, SW_HIDE);

      //.... Irrelevant code....
      // ShowWindow(hWnd, SW_SHOW); //This undoes the disable desktop
}

0 个答案:

没有答案
相关问题