Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
Proteggi PC - frmMain.frm

frmMain.frm

Caricato da: Roberto VB
Scarica il programma completo

  1. Option Explicit
  2. Dim stRichiesta As String
  3. Dim Tentativi As Byte
  4. Dim lTempo As Long
  5. Dim stPassword As String
  6.  
  7. Private Sub cmdAttivaProtezione_Click()
  8.     frmBlocco.Show
  9.     txtAutorizzazione.Text = ""
  10.     txtPassword.Locked = True
  11.     Do
  12.     stRichiesta = InputBox$("INSERISCI PASSWORD: ( Default pas ) " _
  13.     & vbCrLf & "Tentativi rimasti: " & Tentativi, "PASSWORD")
  14.     If stRichiesta <> stPassword Then
  15.             If Tentativi <= 0 Then
  16.                 'Spegne il pc
  17.                 Shell "c:\windows\system32\shutdown.exe -s -t 1 -f"
  18.             End If
  19.         Tentativi = Tentativi - 1
  20.     Else
  21.         Exit Do
  22.     End If
  23.     Loop
  24.     frmBlocco.Hide
  25.     frmMain.Show
  26. End Sub
  27.  
  28.  
  29.  
  30. Private Sub cmdRiduci_Click()
  31.     Riduci.Enabled = True
  32. End Sub
  33.  
  34. Private Sub cmdTimer_Click()
  35.     Timer.Enabled = False
  36. End Sub
  37.  
  38. Private Sub Command1_Click()
  39.     'Termino il programma
  40.     End
  41. End Sub
  42.  
  43.  
  44. Private Sub Form_Click()
  45.     Riduci.Enabled = False
  46.     frmMain.Width = 6540
  47.     frmMain.Height = 2835
  48. End Sub
  49.  
  50. Private Sub Form_Load()
  51.     'Imposto la posizione del form
  52.     frmMain.Left = 0
  53.     frmMain.Top = 0
  54.     txtPassword.Enabled = False
  55.     'Imposto il valore alle variabili
  56.     Tentativi = 3
  57.     stPassword = txtPassword.Text
  58.         'Richiede la password
  59.     Do
  60.     stRichiesta = InputBox$("INSERISCI PASSWORD: ( Default pas ) " _
  61.     & vbCrLf & "Tentativi rimasti: " & Tentativi, "PASSWORD")
  62.     If stRichiesta <> stPassword Then
  63.             If Tentativi <= 0 Then
  64.                 'Spegne il pc
  65.                 Shell "c:\windows\system32\shutdown.exe -s -t 1 -f"
  66.             End If
  67.         Tentativi = Tentativi - 1
  68.     Else
  69.         Exit Do
  70.     End If
  71.     Loop
  72.     frmBlocco.Hide
  73. End Sub
  74.  
  75.  
  76.  
  77.  
  78. Private Sub lblTempo_DblClick()
  79.     On Error GoTo Errore
  80.     lTempo = InputBox$("Inserisci fra quanti secondi dovrà partire la protezione automatica", "PROTEZIONE AUTOMATICA")
  81.     Timer.Enabled = True
  82.     cmdTimer.Enabled = True
  83.     Exit Sub
  84. Errore:
  85.     MsgBox Err.Description, vbCritical
  86.     'Termino il programma
  87.     End
  88.    
  89. End Sub
  90.  
  91. Private Sub Orario_Timer()
  92.     lblOrario.Caption = Time$
  93. End Sub
  94.  
  95. Private Sub Riduci_Timer()
  96.         frmMain.Height = frmMain.Height - 6
  97.         frmMain.Width = frmMain.Width - 6
  98. End Sub
  99.  
  100. Private Sub Timer_Timer()
  101.     lTempo = lTempo - 1
  102.     lblTempo.Caption = lTempo & " secondi"
  103.     If lTempo <= 0 Then
  104.         Timer.Enabled = False
  105.         cmdAttivaProtezione_Click
  106.     End If
  107.        
  108. End Sub
  109.  
  110. Private Sub txtAutorizzazione_Change()
  111.     If txtAutorizzazione.Text = stPassword Then
  112.         txtPassword.Enabled = True
  113.         txtPassword.Locked = False
  114.         txtPassword.SetFocus
  115.     End If
  116. End Sub
  117.  
  118. Private Sub txtPassword_GotFocus()
  119.     txtPassword.Text = ""
  120. End Sub
  121.  
  122. Private Sub txtPassword_LostFocus()
  123.     'Avvisa l'utente che la password è stata cambiata con successo
  124.     MsgBox "Password cambiata!", vbInformation + vbOKOnly, "PASSWORD CAMBIATA CON SUCCESSO!"
  125.     txtPassword.Locked = True
  126.     stPassword = txtPassword.Text
  127.     If txtPassword.Text = "" Then
  128.         MsgBox "Password non valida", vbCritical, "ERRORE"
  129.         End
  130.     End If
  131.    
  132. End Sub
  133.  
  134. Private Sub txtPassword_Validate(Cancel As Boolean)
  135.     If txtPassword.Text = "pas" Then
  136.         optPredefinito.Value = True
  137.     Else
  138.         optPersonalizzato.Value = True
  139.     End If
  140. End Sub