Hide And Show Desktop Icons

'Add a module to your project (In the menu choose Project -> Add Module, Then click Open)
'Add 2 Command Buttons To Your Form.
'When you press the first button, the desktop icons will disappeared.
'When you press the second button, the desktop icons will appear again.
'Insert the following code to the module :

Declare Function ShowWindow& Lib "user32" (ByVal hwnd&, ByVal nCmdShow&)
Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal _
lpClassName As String, ByVal lpWindowName As String) As Long
Public Const SW_HIDE = 0
Public Const SW_NORMAL = 1

'Insert the following code to your form:

Private Sub Command1_Click()
Dim hHandle As Long
hHandle = FindWindow("progman", vbNullString)
Call ShowWindow(hHandle, SW_HIDE)
End Sub

Private Sub Command2_Click()
Dim hHandle As Long
hHandle = FindWindow("progman", vbNullString)
Call ShowWindow(hHandle, SW_NORMAL)
End Sub

Go Back