Option Explicit
Private Const SWP_HIDEWINDOW = &H80
Private Const SWP_SHOWWINDOW = &H40
Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Sub Command1_Click()
Dim fhWnd As Long
fhWnd = FindWindow("SHELL_traywnd", vbNullString)
'找到任务栏
'Debug.Print fhWnd
'看看有没有找到
SetWindowPos fhWnd, 0, 0, 0, 0, 0, SWP_HIDEWINDOW
'隐藏任务栏
End Sub
Private Sub Command2_Click()
Dim hhWnd As Long
hhWnd = FindWindow("SHELL_traywnd", vbNullString)
SetWindowPos hhWnd, 0, 0, 0, 0, 0, SWP_SHOWWINDOW
'恢复任务栏
End Sub
可以把command1_click的代码弄到form_load中,这样就可以一启动就能隐藏任务栏了
我弄两个按钮是为了一个隐藏,一个恢复
不知道是不是你要的效果