DESATIVAR MENU INICIAR DO WINDOWS E OUTROS

HARYSOHN 25/06/2013 17:02:17
#425203
Amigos... referente a este tópico... não consigo acessar os link[ô]s, alguem os teria para me ceder?

http://www.vbmania.com.br/pages/?varModulo=Forum&varMethod=abrir&varID=43961

Cumprimentos.
HARYSOHN 26/06/2013 12:43:15
#425247
Boas Marcelo, obrigado por responder...

Uma coisa... consegui ocultar a barra de tarefas e bloquear a tecla Win,

Tem exemplo de como desabilitar Alt + Tab?


Cumprimentos.
MARCELO.TREZE 26/06/2013 13:38:52
#425251
veja se este funciona

Declare Function SetWindowsHookEx Lib [Ô]user32[Ô] Alias [Ô]SetWindowsHookExA[Ô] (ByVal idHook As Integer, ByVal lpfn As LowLevelKeyboardProcDelegate, ByVal hMod As IntPtr, ByVal dwThreadId As Integer) As IntPtr  
Declare Function UnhookWindowsHookEx Lib [Ô]user32[Ô] Alias [Ô]UnhookWindowsHookEx[Ô] (ByVal hHook As IntPtr) As Boolean
Declare Function CallNextHookEx Lib [Ô]user32[Ô] Alias [Ô]CallNextHookEx[Ô] (ByVal hHook As IntPtr, ByVal nCode As Integer, ByVal wParam As Integer, ByRef lParam As KBDLLHOOKSTRUCT) As Integer
Delegate Function LowLevelKeyboardProcDelegate(ByVal nCode As Integer, ByVal wParam As Integer, ByRef lParam As KBDLLHOOKSTRUCT) As Integer

Const WH_KEYBOARD_LL As Integer = 13

Structure KBDLLHOOKSTRUCT
Dim vkCode As Integer
Dim scanCode As Integer
Dim flags As Integer
Dim time As Integer
Dim dwExtraInfo As Integer
End Structure

Dim intLLKey As IntPtr

Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
intLLKey = SetWindowsHookEx(WH_KEYBOARD_LL, AddressOf LowLevelKeyboardProc, IntPtr.Zero, 0)
End Sub

Private Sub frmMain_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
UnhookWindowsHookEx(intLLKey)
End Sub

Private Function LowLevelKeyboardProc(ByVal nCode As Integer, ByVal wParam As Integer, ByRef lParam As KBDLLHOOKSTRUCT) As Integer
Dim blnEat As Boolean = False

Select Case wParam
Case 256, 257, 260, 261
[ô]Alt+Tab, Alt+Esc, Ctrl+Esc, Windows Key
blnEat = ((lParam.vkCode = 9) AndAlso (lParam.flags = 32)) Or _
((lParam.vkCode = 27) AndAlso (lParam.flags = 32)) Or _
((lParam.vkCode = 27) AndAlso (lParam.flags = 0)) Or _
((lParam.vkCode = 91) AndAlso (lParam.flags = 1)) Or _
((lParam.vkCode = 92) AndAlso (lParam.flags = 1))
End Select

If blnEat = True Then
Return 1
Else
Return CallNextHookEx(IntPtr.Zero, nCode, wParam, lParam)
End If
End Function
HARYSOHN 26/06/2013 13:57:12
#425253
Para desabilitas a Combinação Alt + Tab:

Option Compare Database

[ô]-----------------------------------------------------------------------------------------------------------------------------------------------------------------
[ô]Declarações utilizadas para a desativação da comninação das teclas Ctrl + Alt
[ô]=================================================================================================================================================================
Public Declare Sub CopyMemory Lib [Ô]kernel32[Ô] Alias [Ô]RtlMoveMemory[Ô] (Destination As Any, Source As Any, ByVal Length As Long)
Public Declare Function GetKeyState Lib [Ô]user32[Ô] (ByVal nVirtKey As Long) As Integer
Public Declare Function SetWindowsHookEx Lib [Ô]user32[Ô] Alias [Ô]SetWindowsHookExA[Ô] (ByVal idHook As Long, ByVal lpfn As Long, ByVal hmod As Long, ByVal dwThreadId As Long) As Long
Public Declare Function CallNextHookEx Lib [Ô]user32[Ô] (ByVal hHook As Long, ByVal nCode As Long, ByVal wParam As Long, lParam As Any) As Long
Public Declare Function UnhookWindowsHookEx Lib [Ô]user32[Ô] (ByVal hHook As Long) As Long
Public Const HC_ACTION = 0
Public Const WM_KEYDOWN = &H100
Public Const WM_KEYUP = &H101
Public Const WM_SYSKEYDOWN = &H104
Public Const WM_SYSKEYUP = &H105
Public Const VK_TAB = &H9
Public Const VK_CONTROL = &H11
Public Const VK_ESCAPE = &H1B
Public Const VK_STARTKEY = &H5B
Public Const WH_KEYBOARD_LL = 13
Public Const LLKHF_ALTDOWN = &H20

Public Type KBDLLHOOKSTRUCT
vkCode As Long
scanCode As Long
flags As Long
time As Long
dwExtraInfo As Long
End Type

Public hhkLowLevelKybd
Dim p As KBDLLHOOKSTRUCT

[ô]-----------------------------------------------------------------------------------------------------------------------------------------------------------------
[ô]Função a ser chhamada no evento ao carregar do formulário desabilitando assim a combinação sas teclas Ctrl + Alt
Function LowLevelKeyboardProc(ByVal nCode As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Dim fEatKeystroke As Boolean
If (nCode = HC_ACTION) Then
If wParam = WM_KEYDOWN Or wParam = WM_SYSKEYDOWN Or wParam = WM_KEYUP Or wParam = WM_SYSKEYUP Then
CopyMemory p, ByVal lParam, Len(p)
fEatKeystroke = _
((p.vkCode = VK_TAB) And ((p.flags And LLKHF_ALTDOWN) <> 0)) Or _
((p.vkCode = VK_ESCAPE) And ((p.flags And LLKHF_ALTDOWN) <> 0)) Or _
((p.vkCode = VK_ESCAPE) And ((GetKeyState(VK_CONTROL) And &H8000) <> 0)) Or _
p.vkCode = VK_STARTKEY
End If
End If
If fEatKeystroke Then
LowLevelKeyboardProc = -1
Else
LowLevelKeyboardProc = CallNextHookEx(0, nCode, wParam, ByVal lParam)
End If
End Function

[ô]VBA tags courtesy of www.thecodenet.com
[ô]Correção para funcionamento por: Harysohn Pina (Fórum Máximo Acccess) - PILOTO
[ô]Em 26/06/2013
[ô]Harysohn@hotmail.com
[ô]Para rodar a função no formulário:
[ô]VBA:

[ô]hhkLowLevelKybd = SetWindowsHookEx(WH_KEYBOARD_LL, AddressOf LowLevelKeyboardProc, 0, 0)

=======================================================================

Pesquisei sobre a Ctrl + Alt + Del

me retornou
App.TaskVisible = False

Porém em VBA não funciona... Não funcionou. Alguma ideia?

Cumprimentos.
HARYSOHN 26/06/2013 14:24:57
#425256
Boas Marcelo, perdoe-me não havia visto sua mensagem acima.

No entanto consegui atavés do código que postei acima..

Tem alguma ideia para a Ctrl + Alt + Del?

Cumprimentos.
HARYSOHN 26/06/2013 14:30:45
#425257
Boas Marcelo, implementando o código que postou há alguma discrepância quanto ao mesmo visto que estou o utilizando em vba.

Os comandos
Delegate Funcion
AndAlso
Return

Alguma ideia?

Obrigado e perdoe-me o incomodo.
MARCELO.TREZE 26/06/2013 14:36:41
#425258
colega pra vba tente este

No evento ao carregar do seu formulário inicial cole:

Call DesativaCtrlAltDel

Cole o código abaixo em um novo módulo:

Public Declare Function GetCurrentProcessId _ Lib [Ô]kernel32[Ô] () As Long

Public Declare Function GetCurrentProcess _ Lib [Ô]kernel32[Ô] () As Long

Public Declare Function RegisterServiceProcess _ Lib [Ô]kernel32[Ô] (ByVal dwProcessID As Long, _ ByVal dwType As Long) As Long

Public Const RSP_SIMPLE_SERVICE = 1

Public Const RSP_UNREGISTER_SERVICE = 0

Public Sub DesativaCtrlAltDel()
Dim pid As Long, reserv As Long

Let pid = GetCurrentProcessId()
Let reserv = RegisterServiceProcess (pid, RSP_SIMPLE_SERVICE)
End Sub
HARYSOHN 26/06/2013 15:04:02
#425259
Para o VBA tive que retirar alguns Underlines das declarações públicas ficando assim:

Public Declare Function GetCurrentProcessId Lib [Ô]kernel32[Ô] () As Long
Public Declare Function GetCurrentProcess Lib [Ô]kernel32[Ô] () As Long
Public Declare Function RegisterServiceProcess Lib [Ô]kernel32[Ô] (ByVal dwProcessID As Long, ByVal dwType As Long) As Long
Public Const RSP_SIMPLE_SERVICE = 1
Public Const RSP_UNREGISTER_SERVICE = 0


Porem ai rodar a função deu o erro 453
[Ô]Impossível localizar ponto de entrada RegisterServiceProcess de DLL em Kernel32.


Cumprimentos.
HARYSOHN 26/06/2013 15:08:13
#425261
Estive vendo no código que obtive sucesso em desabilitar a combinação Alt + Tab e Ctrl + Esc, que isso é feito na sequencia abaixo:

fEatKeystroke = _
((p.vkCode = VK_TAB) And ((p.flags And LLKHF_ALTDOWN) <> 0)) Or _
((p.vkCode = VK_ESCAPE) And ((p.flags And LLKHF_ALTDOWN) <> 0)) Or _
((p.vkCode = VK_ESCAPE) And ((GetKeyState(VK_CONTROL) And &H8000) <> 0)) Or _
p.vkCode = VK_STARTKEY

Será que não conseguiriamos adaptar ai (acrescentar) a Ctrl + Alr + Del?


Cumprimentos.
HARYSOHN 27/06/2013 15:16:28
#425312
Boas amigos... Terminei este exemplo, não consegui desativar as combinações ctrl + Alt + Del, porém encerrei o processo do TaskManager ao tentar iniciá-lo ..


Bloqueia Barra de tarefas
Encerra o TaskManager ao tentar entrar no gerenciador de tarefas pelas teclas Ctrl + Alt + Del
Desabilita as combinações de teclas Ctrl + Alt e Alt + Esc


Página 1 de 2 [12 registro(s)]
Tópico encerrado , respostas não são mais permitidas