问答文章1 问答文章501 问答文章1001 问答文章1501 问答文章2001 问答文章2501 问答文章3001 问答文章3501 问答文章4001 问答文章4501 问答文章5001 问答文章5501 问答文章6001 问答文章6501 问答文章7001 问答文章7501 问答文章8001 问答文章8501 问答文章9001 问答文章9501

如何在javascript上实现禁用ctrl alt del键

发布网友 发布时间:2022-05-17 13:28

我来回答

2个回答

懂视网 时间:2022-05-17 17:49

代码如下:
document.onclick = function(e){
alert(getKey(e));
};
function getKey(e){
var e = e || window.event;
var keys = [];

if(e.shiftKey){
keys.push("shift键");
};
if(e.ctrlKey){
keys.push("ctrl键");
};
if(e.altKey){
keys.push("alt键");
};
return keys;
};

热心网友 时间:2022-05-17 14:57

一个窗体文件FORM1.FRM,一个模块

'窗体代码开始:(保存为FORM1.FRM)
'////////////////////////////////////////////////////////
VERSION 5.00
Begin VB.Form Form1
Caption = "CTRL +ALT + DEL"
ClientHeight = 735
ClientLeft = 60
ClientTop = 450
ClientWidth = 4155
LinkTopic = "Form1"
ScaleHeight = 735
ScaleWidth = 4155
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command3
Caption = "启用"
Height = 495
Left = 2160
TabIndex = 1
Top = 120
Width = 1695
End
Begin VB.CommandButton Command1
Caption = "禁用"
Height = 495
Left = 240
TabIndex = 0
Top = 120
Width = 1695
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Private Sub Command1_Click()
Dim i As Boolean
i = LockKeyboard(True)
If i = True Then Me.Caption = i

Getkeykoardok
End Sub

Private Sub Getkeykoardok()
Dim i As Boolean
i = GetKeyboardState
If i = True Then Me.Caption = "CTRL +ALT + DEL已禁用" Else Me.Caption = "CTRL +ALT + DEL已启用"

End Sub

Private Sub Command3_Click()
Dim i As Boolean
i = LockKeyboard(False)
If i = True Then Me.Caption = i
Getkeykoardok

End Sub

'窗体代码结束:
'///////////////////////////////////////////////////////////////////

'模块代码开始:(保存为Mole1.BAS)

Attribute VB_Name = "Mole1"
Option Explicit
'注意,以下所有双版本的API均声明成了 UNICODE 版。 并且许多地方与VB的API浏览器生成的代码有所不同。
Private Declare Function OpenProcess Lib "kernel32" (ByVal _
dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal _
dwProcessId As Long) As Long
Private Declare Function ReadProcessMemory Lib "kernel32" (ByVal _
hProcess As Long, ByVal lpBaseAddress As Long, lpBuffer As Any, _
ByVal nSize As Long, _
lpNumberOfBytesWritten As Long) As Long
Private Declare Function WriteProcessMemory Lib "kernel32" (ByVal _
hProcess As Long, ByVal lpBaseAddress As Long, lpBuffer As Any, _
ByVal nSize As Long, _
lpNumberOfBytesWritten As Long) As Long
Private Declare Function GlobalAddAtom Lib "kernel32" Alias _
"GlobalAddAtomW" (ByVal lpString As Long) As Integer
Private Declare Function GlobalDeleteAtom Lib "kernel32" (ByVal _
nAtom As Integer) As Integer
Private Declare Function GlobalFindAtom Lib "kernel32" Alias _
"GlobalFindAtomW" (ByVal lpString As Long) As Integer
Private Const TH32CS_SNAPPROCESS = 2
Private Type PROCESSENTRY32W
dwSize As Long
cntUsage As Long
h32ProcessID As Long ' // this process
th32DefaultHeapID As Long '
h32MoleID As Long ' // associated exe
cntThreads As Long '
th32ParentProcessID As Long ' // this process's parent process
pcPriClassBase As Long ' // Base priority of process'sthreads
dwFlags As Long '
szExeFile(1 To 260) As Integer ' // Path
End Type
Private Declare Function CreateToolhelp32Snapshot Lib "kernel32" (ByVal dwFlags As Long, ByVal th32ProcessID As Long) As Long
Private Declare Function Process32First Lib "kernel32" Alias "Process32FirstW" (ByVal hSnapshot As Long, lpPE As PROCESSENTRY32W) As Long
Private Declare Function Process32Next Lib "kernel32" Alias "Process32NextW" (ByVal hSnapshot As Long, lpPE As PROCESSENTRY32W) As Long
Private Declare Function lstrcmpi Lib "kernel32" Alias "lstrcmpiW" (lpString1 As Integer, ByVal lpString2 As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long

Private Type LUID
lowpart As Long
highpart As Long
End Type
Private Type LUID_AND_ATTRIBUTES
pLuid As LUID
Attributes As Long
End Type
Private Type TOKEN_PRIVILEGES
PrivilegeCount As Long
Privileges As LUID_AND_ATTRIBUTES
End Type
Private Const PROCESS_ALL_ACCESS As Long = &H1F0FFF
Private Const TOKEN_QUERY As Long = &H8&
Private Const TOKEN_ADJUST_PRIVILEGES As Long = &H20&
Private Const SE_PRIVILEGE_ENABLED As Long = &H2
Private Const SE_DEBUG_NAME As String = "SeDebugPrivilege"
Private Declare Function GetCurrentProcess Lib "kernel32" () As Long
Private Declare Function OpenProcessToken Lib "advapi32.dll" (ByVal ProcessHandle As Long, ByVal DesiredAccess As Long, TokenHandle As Long) As Long
Private Declare Function LookupPrivilegeValue Lib "advapi32.dll" Alias "LookupPrivilegeValueW" (ByVal lpSystemName As Long, ByVal lpName As Long, lpLuid As LUID) As Long
Private Declare Function AdjustTokenPrivileges Lib "advapi32.dll" (ByVal TokenHandle As Long, ByVal DisableAllPrivileges As Long, NewState As TOKEN_PRIVILEGES, _
ByVal BufferLength As Long, ByVal PrevState As Long, ByVal N As Long) As Long
Private Declare Function LoadLibrary Lib "kernel32" Alias _
"LoadLibraryW" (ByVal lpLibFileName As Long) As Long
Private Declare Function GetProcAddress Lib "kernel32" (ByVal _
hMole As Long, ByVal lpProcName As String) As Long
Private Declare Function FreeLibrary Lib "kernel32" (ByVal _
hLibMole As Long) As Long
Private Const MEM_COMMIT As Long = &H1000
Private Const MEM_DECOMMIT As Long = &H4000
Private Const PAGE_EXECUTE_READWRITE As Long = &H40
Private Declare Function VirtualAllocEx Lib "kernel32" (ByVal _
ProcessHandle As Long, ByVal lpAddress As Long, ByVal dwSize As _
Long, ByVal flAllocationType As Long, ByVal flProtect As Long) As Long
Private Declare Function VirtualFreeEx Lib "kernel32" (ByVal _
ProcessHandle As Long, ByVal lpAddress As Long, ByVal dwSize As _
Long, ByVal dwFreeType As Long) As Long
Private Declare Function CreateRemoteThread Lib "kernel32" (ByVal hProcess As Long, ByVal lpThreadAttributes As Long, ByVal dwStackSize As Long, ByVal lpStartAddress As Long, ByVal lpParameter As Long, ByVal dwCreationFlags As Long, lpThreadId As Long) As Long
Private Declare Function SetWindowsHookEx Lib "user32" Alias "SetWindowsHookExW" (ByVal idHook As Long, ByVal lpfn As Long, ByVal hmod As Long, ByVal dwThreadId As Long) As Long
Private Declare Function UnhookWindowsHookEx Lib "user32" (ByVal hHook As Long) As Long
Private Declare Function CallNextHookEx Lib "user32" (ByVal hHook As Long, ByVal nCode As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const ATOM_FLAG As String = "HookSysKey"
Private Const SHELL_FALG As String = "Winlogon"
Private Const SHELL_CODE_DWORDLEN = 240 '注入代码所占的双字数
Private Const SHELL_CODE_LENGTH = (SHELL_CODE_DWORDLEN * 4) '字节数
Private Const SHELL_FUNCOFFSET = &H26 '注入代码线程函数偏移量
Private mlShellCode(SHELL_CODE_DWORDLEN - 1) As Long

Private m_lHookID As Long '键盘钩子句柄
'============================================
' 锁定/解锁键盘
' 参数:布尔型,真表示锁定
' 返回:布尔型, 真表示成功
' 注意:非 Ctrl+Alt+Del 键使用普通钩子技术,因此
' 程序在退出时注意要卸载钩子。
'============================================
Public Function LockKeyboard(ByVal bLock As Boolean) As Boolean
Dim lResult As Long
Dim lStrPtr As Long
lStrPtr = StrPtr(SHELL_FALG)
lResult = GlobalFindAtom(lStrPtr)
If lResult = 0 Then
lResult = InsertAsmCode
Debug.Assert lResult = 0
If lResult Then Exit Function
End If

lStrPtr = StrPtr(ATOM_FLAG)
lResult = GlobalFindAtom(lStrPtr)
If bLock Then
m_lHookID = SetWindowsHookEx(13, AddressOf LowLevelKeyboardProc, App.hInstance, 0)
If (lResult = 0 And m_lHookID <> 0) Then lResult = GlobalAddAtom(lStrPtr)
LockKeyboard = (lResult <> 0 And m_lHookID <> 0)
Debug.Assert LockKeyboard
Else
Call UnhookWindowsHookEx(m_lHookID)
If lResult Then lResult = GlobalDeleteAtom(lResult)
LockKeyboard = (lResult <> 0)
End If
End Function
Public Function GetKeyboardState() As Boolean
GetKeyboardState = GlobalFindAtom(StrPtr(ATOM_FLAG)) <> 0
End Function

Private Function LowLevelKeyboardProc(ByVal nCode As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
If nCode >= 0 Then
'在这里可以加入实际的过滤条件
LowLevelKeyboardProc = 1
Else
LowLevelKeyboardProc = CallNextHookEx(m_lHookID, nCode, wParam, lParam)
End If
End Function
'----------------------------------------------
' 远程线程插入函数
' 功能:向 Winlogon 进程插入远程线程代码,并执行
' 返回:0 表示成功,非 0 为标准的错误代号(此错误
' 代码为远程线程返回的错误)
'----------------------------------------------
Private Function InsertAsmCode() As Long
Const WINLOGON As String = "Winlogon.exe"
Dim hProcess As Long '远端进程句柄
Dim hPId As Long '远端进程ID
Dim lResult As Long '一般返回变量
Dim pToken As TOKEN_PRIVILEGES
Dim hToken As Long
Dim hRemoteThread As Long
Dim hRemoteThreadID As Long
Dim lDbResult(1) As Long
Dim lRemoteAddr As Long

'------------------------------------
'取winlogon进程ID
'------------------------------------
hPId = GetProcessIdFromName(WINLOGON)
If hPId = 0 Then
Debug.Assert False
Exit Function
End If

'------------------------------------
'提升本进程权限,以取得对winlogon进程操作的许可
'------------------------------------
lResult = OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES Or TOKEN_QUERY, hToken)
Debug.Assert lResult
lResult = LookupPrivilegeValue(0, StrPtr(SE_DEBUG_NAME), pToken.Privileges.pLuid)
Debug.Assert lResult
pToken.PrivilegeCount = 1
pToken.Privileges.Attributes = SE_PRIVILEGE_ENABLED
lResult = AdjustTokenPrivileges(hToken, False, pToken, Len(pToken), 0, 0)
Debug.Assert lResult

'请看下一篇

模块代码太多字体了,请到我的博客看第二篇
http://hi.baidu.com/starwork/blog/item/609ea12b4b5d7efbe6cd4086.html
声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com
为什么研究生报名时填写非定向,录取为委培 非定向和定向应该怎么填 报考类别定向还是非定向填什么 有单位的考研报名必须定向吗 考研定向就业怎么报名 研究生定向中的委培单位是填学校吗 农村医生如何提升学历? 小米手机丢失怎么定位找回来小米手机丢失定位找回手机怎么办 国美“帅康燃气灶”暴利身后的阴谋 我想入手一台三星I9300 GALAXY SIII ,联通跟移动版选哪一个? 我的不能建群,也不能进群是什么原因,怎么解决? 农村信用社利息表2015年12月存款利率 2015年四川省农村信用社联合社存款利率是多少 农村信用社最新的存款利率是多少?谢谢! 2015年农村信用社10月23日的存款利率是多少定期的 联合国是怎样组成的 怎么样申请400电话 联合国是在怎样的背景时代下成立的 怎样申请400电话? 联合国1914年成立? 联合国是如何建立的? 个人能够办400电话吗?需要哪些证件? 个人可以办理400电话吗? 联合国是谁创立的? 个人可以办理400电话业务吗? 联合国是1946年在哪创立的 个人名义可以办理400电话吗? 上海的澳洲联邦银行COMMBANK的分行,去那换澳币,然后存COMMONBANK的卡手续费要出么? commonwealth bank三个账户的区别??? 日本可爱少女网名日语 牙齿不好,在佛教中是犯了什么业?如何消业? 牙齿不好犯了什么业障 牙烂的因果是什么 牙疼是造了什么孽?站在佛法的角度解释 头痛牙痛突然发生是业障突然现前了不 学佛后口臭加重,是业障消除的表现吗? 掉牙是消业障的梦吗 算命说的犯业障什么意思 身上佩戴老虎的牙齿和佛教有冲突吗?包括进寺庙拜佛啊什么的?麻烦回答的详细一点,十分感谢! - 信息提示 吃十几年抗抑郁症药品会影响牙齿吗 牙齿不坚固是并发症吗? 我今年本命年都掉了三颗牙齿,按照命理学这有什么说法没有? - 信息提示 怎么安装?无线宽带 微信里我把对方删除,然后更改,没有电话号码,对方还能找到我吗? 学前发展心理学,课程小论文,谈谈作为一名教育工作者树立怎样的儿童的教育观 学前儿童心理学方面的论文题目 梦到赶火车可是想起学校还有自己的钱,回到学校之后看见自己书包里有好多的钱 做梦在海边捡了好多百元钱放在自已的书包里 梦见一大书包崭新的钱,全是50一沓的钱