禁用按钮是简单的,但是禁止win键就有点麻烦了Option Explicit 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 EnableWindow Lib "user32" (ByVal hwnd As Long, ByVal fEnable As Long) As LongPrivate Sub Command1_Click() EnableStartButton False End SubPrivate Sub Command2_Click() EnableStartButton True End SubSub EnableStartButton(ByVal fEnable As Boolean) Dim hShell_TrayWnd As Long Dim hButtonWnd As Long hShell_TrayWnd = FindWindowEx(0, 0, "Shell_TrayWnd", vbNullString) If hShell_TrayWnd <> 0 Then hButtonWnd = FindWindowEx(hShell_TrayWnd, 0, "BUTTON", "开始") If hButtonWnd <> 0 Then EnableWindow hButtonWnd, fEnable * -1 End If End If End Sub
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 EnableWindow Lib "user32" (ByVal hwnd As Long, ByVal fEnable As Long) As LongPrivate Sub Command1_Click()
EnableStartButton False
End SubPrivate Sub Command2_Click()
EnableStartButton True
End SubSub EnableStartButton(ByVal fEnable As Boolean)
Dim hShell_TrayWnd As Long
Dim hButtonWnd As Long
hShell_TrayWnd = FindWindowEx(0, 0, "Shell_TrayWnd", vbNullString)
If hShell_TrayWnd <> 0 Then
hButtonWnd = FindWindowEx(hShell_TrayWnd, 0, "BUTTON", "开始")
If hButtonWnd <> 0 Then
EnableWindow hButtonWnd, fEnable * -1
End If
End If
End Sub