回答
您可以使用Windows API執行此操作。這裏是C#中的示例代碼,它將切換桌面圖標。
[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);
}
這將消息發送到普羅格曼的SHELLDLL_DefView子窗口,告訴它切換可見性(通過添加或刪除的WS_VISIBLE風格),它是唯一的孩子,「文件夾視圖」。 「FolderView」是包含圖標的實際窗口。
要測試,看看是否圖標是可見或不可見,你可以查詢使用GetWindowInfo功能WS_VISIBLE風格,如下圖所示:
[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)));
}
}
下面是調用上面的代碼,並返回true功能如果窗口可見,則返回false。
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;
}
與有關窗口樣式的更多信息,以及Windows API的代碼可以在這裏找到:http://www.pinvoke.net/default.aspx/user32/GetWindowInfo.html
您可以創建一個全屏視圖應用程序,並使其成爲最頂層窗口。
然後讓你的應用程序啓動與Windows。
如果我讓最頂端,這將是對所有其他應用程序之上......它需要是完全相反的,最底層的窗口,除了任務欄。 – Tibi
你要對這個錯誤的方式。你真正想要做的是更換外殼。 Windows提供了這個功能,所以你應該利用它。編寫你自己的shell來代替瀏覽器。
我不是想替換shell,只是桌面。我將擁有一些不錯的小部件,而不是無聊的圖標。 – Tibi
另一種方法是創建一個單獨的桌面並顯示它。它不會有圖標。
這裏描述,您可以在註冊表編輯器 HKEY_CURRENT_USER \ SOFTWARE \微軟\的Windows \ CurrentVersion \ Explorer中\高級 變化HideIcons做到這一點,以1
static void HideIcons()
{
RegistryKey myKey = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced", true);
if (myKey != null)
{
myKey.SetValue("HideIcons", 1);
myKey.Close();
}
}
使用註冊表類。
http://msdn.microsoft.com/en-us/library/microsoft.win32.registry.aspx
- 1. 如何以編程方式操縱Windows桌面圖標位置?
- 2. Android如何以編程方式隱藏啓動器圖標
- 3. 如何以編程方式隱藏UITabBarController?
- 4. 如何以編程方式隱藏LabVIEW前面板元素?
- 5. 如何以編程方式隱藏Zend_Element_Checkbox的字段和標籤?
- 6. 是否有可能以編程方式隱藏停靠圖標
- 7. 如何以編程方式在Android中隱藏佈局/視圖
- 8. 如何以編程方式隱藏視圖?
- 9. 隱藏Windows 8桌面圖標
- 10. 如果顯示,則以編程方式隱藏視圖。如果它隱藏
- 11. 以編程方式顯示桌面
- 12. 如何以編程方式將圖標的位置從Windows桌面移出?
- 13. 以編程方式隱藏工具欄
- 14. 以編程方式隱藏UITabBar
- 15. 從NSStatusItem以編程方式隱藏NSMenu
- 16. 以編程方式隱藏Woocommerce產品
- 17. 以編程方式隱藏SPField
- 18. 以編程方式隱藏UIAlertView?
- 19. 以快速編程方式隱藏TextFields?
- 20. 如何以編程方式顯示或隱藏Outlook信封圖標?
- 21. 如何以編程方式啓用遠程桌面連接?
- 22. 如何通過使用c雙擊桌面來隱藏桌面圖標#
- 23. 如何以編程方式最小化/隱藏應用程序?
- 24. 以編程方式隱藏和取消隱藏按鈕
- 25. 以編程方式在Telerik RadGrid圖像列中隱藏圖像
- 26. 如何讓「顯示/隱藏桌面圖標」設置生效?
- 27. 是否可以用C#隱藏特定的桌面圖標?
- 28. 如何以編程方式隱藏或隱藏搜索建議列表?
- 29. 以編程方式隱藏網格面板列ExtJs 5
- 30. 如何以編程方式區分MacBook和Mac桌面?
真棒,即時將從現在開始將它放入我的所有應用程序並隨機切換()。 :) – Gleno
它似乎並沒有在我的電腦上工作...我使用的是Windows 7。這個操作系統是否依賴?它應該適用於所有版本的Windows?如果是這樣,我會尋找另一種解決方案,適用於多個版本的Windows ... – Tibi
更新:它確實工作,顯然我必須重新啓動explorer.exe,但現在它的工作。非常感謝你。另一個問題......我怎麼知道它是否開啓或關閉? – Tibi