Può accadere che si abbia la necessità di disabilitare la pressione del pulsante "Start"!
In che caso?? .... Bella domanda!!
Mbhe! Forse accade solo a me!! ... comunque ognuno può usarla quando e come meglio crede.
Apriamo un nuovo form con una Label ed un semplice Button ed inseriamo il seguente codice:
Private Declare Function FindWindowEx Lib "user32" _
Alias "FindWindowExA" (ByVal hWnd1 As Integer, ByVal hWnd2 As Integer, _
ByVal lpsz1 As String, ByVal lpsz2 As String) As Integer
Private Declare Function EnableWindow Lib "user32" (ByVal hwnd As Integer, _
ByVal fEnable As Integer) As Integer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Label1.Text = "Enabled"
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim bEnable As Boolean
If Label1.Text = "Enabled" Then
Label1.Text = "Disabled"
bEnable = False
Else
Label1.Text = "Enabled"
bEnable = True
End If
Dim lHwnd As Integer
lHwnd = FindWindowEx(0&, 0&, "Shell_TrayWnd", vbNullString)
lHwnd = FindWindowEx(lHwnd, 0&, "Button", vbNullString)
Call EnableWindow(lHwnd, bEnable)
End Sub
Ovviamente, come dice il mio amico Brunetti, il linguaggio non ha importanza siamo in .NET!!
Ciao
Ivan