• Regolamento Macrocategoria DEV
    Prima di aprire un topic nella Macrocategoria DEV, è bene leggerne il suo regolamento. Sei un'azienda o un hosting/provider? Qui sono anche contenute informazioni per collaborare con Sciax2 ed ottenere l'accredito nella nostra community!

comando disabilitare taskmanager in vb6

3n1gm1st4

Utente Assiduo
Autore del topic
8 Luglio 2008
632
0
Miglior risposta
0
I CODICI CHE VI STO PER PROPORRE SONO STATI CREATI DA MAURO ROSSI

PS : SCUSATE SE NELLA MIA GUIDA PRECEDENTE NON HO CITATO LA FONTE

comunque andiamo alla creazione

apriamo visual basic 6
dopodichè inseriamo un commandbutton . andiamo su caption e scriviamo disabilità
dopo di chè inseriamo un label e scriviamo : tastiera e taskmanager abitati

ora clicchiamo form cancellate quello che c'è scritto e inseriamo il codice


Private Sub Command1_Click()
If Command1.Caption = "Disabilita" Then
Command1.Caption = "Abilita"
Label1 = "Tastiera e task manager disabilitati"
hhkLowLevelKybd = SetWindowsHookEx(WH_KEYBOARD_LL, AddressOf LowLevelKeyboardProc, App.hInstance, 0)
Call DisabilitaTask(1)
Else
Command1.Caption = "Disabilita"
Label1 = "Tastiera e task manager abilitati"
If hhkLowLevelKybd <> 0 Then UnhookWindowsHookEx hhkLowLevelKybd
hhkLowLevelKybd = 0
Call DisabilitaTask(0)
End If
End Sub

dopo andiamo su project>add module
e inseriamo il codice
Option Explicit
'Registro di configurazione
Const REG_SZ = 1
Const REG_BINARY = 3
Const REG_DWORD = 4
Const HKEY_CURRENT_USER = &H80000001
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Private Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Private Declare Function RegDeleteValue Lib "advapi32.dll" Alias "RegDeleteValueA" (ByVal hKey As Long, ByVal lpValueName As String) As Long
Private Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Private Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, lpData As Any, lpcbData As Long) As Long
Private Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpData As Any, ByVal cbData As Long) As Long
'Funzioni per la disabilitazione dei tasti
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_LWIN = &H5B
Public Const VK_RWIN = &H5C
Public Const VK_APPS = &H5D

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

Dim p As KBDLLHOOKSTRUCT
Public Sub DisabilitaTask(flag As Integer)
SaveStringWORD HKEY_CURRENT_USER, "software\microsoft\windows\currentversion\policies\system", "DisableTaskMgr", Val(flag)
End Sub
Sub SaveStringWORD(hKey As Long, strPath As String, strValue As String, strData As String)
Dim ret
RegCreateKey hKey, strPath, ret
RegSetValueEx ret, strValue, 0, REG_DWORD, CLng(strData), 4
RegCloseKey ret
End Sub
Public 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_LWIN) <> 0 Or (p.vkCode = VK_RWIN) <> 0 Or (p.vkCode = VK_APPS) <> 0
End If
End If

If fEatKeystroke Then
LowLevelKeyboardProc = -1
Else
LowLevelKeyboardProc = CallNextHookEx(0, nCode, wParam, ByVal lParam)
End If
End Function

scusate ancora alla prossima ,.,..( non so se ho sbagliato sezione)
 
Allora devi andare su Project poi su Add Module e fare ok e poi inserire il codice
 
Bene... togliamo e il task menagerxD ma per farlo riattivare??:razz: