在窗体放置command1和command2按钮
Option Explicit
Private Const SW_HIDE = 0
Private Const SW_SHOW = 5
Private Declare Function FindWindowEx Lib "user32" Alias _
"FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As _
Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Declare Function ShowWindow Lib "user32" (ByVal _
hwnd As Long, ByVal nCmdShow As Long) As Long
Private Declare Function FindWindow Lib "user32" Alias _
"FindWindowA" (ByVal lpClassName As String, ByVal _
lpWindowName As String) As Long
Public Sub ShowDesktop(bShow As Boolean)
Dim hLong As Long
Dim hwnd As Long
hwnd = FindWindow("Progman", "Program Manager")
hLong = FindWindowEx(hwnd, 0, "SHELLDLL_DefView", "")
hLong = FindWindowEx(hLong, 0, "SysListView32", "")
If bShow = True Then
ShowWindow hLong, SW_SHOW
Else
ShowWindow hLong, SW_HIDE
End If
End Sub
Private Sub Command1_Click()
ShowDesktop True
End Sub
Private Sub Command2_Click()
ShowDesktop False
End Sub