http://bbs.bccn.net/thread-349755-1-1.html
https://msdn.microsoft.com/en-us/library/windows/desktop/ms633548(v=vs.85).aspx
注意:该方法与桌面右键里的隐藏图标功能是不一样的。
Declare Function ShowWindow Lib "user32" Alias "ShowWindow" (ByVal hwnd As IntPtr, ByVal nCmdShow As Integer) As Integer
Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As IntPtr, ByVal hWnd2 As IntPtr, ByVal lpsz1 As String, ByVal lpsz2 As String) As IntPtr
Const SW_HIDE = 0
Const SW_SHOW = 5
Public Shared Sub HideDeskIcon()
Dim intParentWindows As IntPtr '保存父窗体句柄
Dim intBoyWindows As IntPtr '保存子窗体句柄
intParentWindows = FindWindowEx(0, 0, "WorkerW", vbNullString) '查找WorkerW类,Win7中有很多个这样的类,需要进行遍历
Do
intBoyWindows = FindWindowEx(intParentWindows, 0, "SHELLDLL_DefView", vbNullString) '找子类
intParentWindows = FindWindowEx(0, intParentWindows, "WorkerW", vbNullString)
Loop While intParentWindows <> 0 And intBoyWindows = 0 '有父类时同时没有找到子类循环查找
intBoyWindows = FindWindowEx(intBoyWindows, 0, "SysListView32", vbNullString) '查找下一个子类
ShowWindow(intBoyWindows, SW_HIDE) '隐藏类
End Sub
Public Shared Sub ShowDeskIcon()
Dim intParentWindows As IntPtr
Dim intBoyWindows As IntPtr
intParentWindows = FindWindowEx(0, 0, "WorkerW", vbNullString)
Do
intBoyWindows = FindWindowEx(intParentWindows, 0, "SHELLDLL_DefView", vbNullString)
intParentWindows = FindWindowEx(0, intParentWindows, "WorkerW", vbNullString)
Loop While intParentWindows <> 0 And intBoyWindows = 0
intBoyWindows = FindWindowEx(intBoyWindows, 0, "SysListView32", vbNullString)
ShowWindow(intBoyWindows, SW_SHOW)
End Sub