|
|
|
|
|
Dicas
|
|
Visual Basic (Arquivos/Diretórios)
|
|
|
Título da Dica: Impedir acesso a uma Pasta
|
|
|
|
Postada em 1/9/2004 por Msmarcus_RJ
'O exemplo impede o acesso à pasta Meus Documentos: 'Para funcionar adicione um controle Timer no Form.
Option Explicit Private Declare Function GetForegroundWindow Lib "user32.dll" () As Long Private Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long Dim CurrentWindow As String
Private Sub Form_Load() CurrentWindow = GetCaption(GetForegroundWindow) Timer1.Interval = 1000 Me.Hide
End Sub
Private Sub Timer1_Timer() If CurrentWindow <> GetCaption(GetForegroundWindow) Then CurrentWindow = GetCaption(GetForegroundWindow) If LCase(CurrentWindow) = LCase("meus documentos") Then SendKeys "%{f4}"
End Sub
Function GetCaption(WindowHandle As Long) As String Dim Buffer As String, TextLength As Long TextLength = GetWindowTextLength(WindowHandle) Buffer = String(TextLength, 0) Call GetWindowText(WindowHandle, Buffer, TextLength + 1) GetCaption = Buffer
End Function
Fonte no site: www.vbmania.com.br
|
|
|
|
|