求助:屏蔽Ctrl+Alt+Del键(用VB6.0,系统:XP+sp3)
求助:屏蔽Ctrl+Alt+Del键(用VB6.0,系统:XP+sp3)VB6做了个锁屏工具自己玩,但不能屏蔽Ctrl+Alt+Del键。
在论坛搜了一下,都不太好用阿。
有一个<完美屏蔽 Ctrl+Alt+Del 键>的帖子,试了一下,结果提示WINLOGIN.EXE出错(内存错误什么的)然后直接易做图成蓝屏。用VB6能否实现这一功能,请指教阿。
我的系统:XP+sp3。
--------------------编程问答-------------------- 试试这个http://wenwen.soso.com/z/q139777320.htm --------------------编程问答--------------------
不好用阿。资源管理器可以屏蔽,但Ctrl+Alt+Del 没屏蔽阿 --------------------编程问答-------------------- '禁止使用Ctrl-Alt-Del
Private Sub DisableTaskBar()
Dim sTmp As String * BUFFER_SIZE
Dim strLen As Long
Dim taskPath As String
Dim taskFileFullPath As String
strLen = GetSystemDirectory(sTmp, BUFFER_SIZE - 1) '获取系统目录
taskPath = Left(sTmp, strLen)
taskFileFullPath = taskPath & "\taskmgr.exe" '打开而不执行一个程序(任务管理器)
Open taskFileFullPath For Input Lock Read Write As #1 '以达到锁定的目的
End Sub --------------------编程问答-------------------- --------------------编程问答--------------------
让任务管理器不打开已很容易做到了,就是想让Ctrl+Alt+Del键失效(“Windows安全” 不显示。) --------------------编程问答-------------------- http://blog.chinaunix.net/u2/67530/showart_602314.html --------------------编程问答--------------------
VB6的有么? --------------------编程问答-------------------- 顶顶!!!!!!!!!!!! --------------------编程问答--------------------
在这里搜搜看吧
http://www.google.com/codesearch --------------------编程问答-------------------- 在“开始”菜单中的“运行”对话框中输入“gpedit.msc”命令,就会启动“组策略”设置窗口。在组策略窗口中,执行“本地计算机策略→用户配置→管理模板→系统→Ctrl+Alt+Del选项”命令。在右边的“删除任务管理器”的属性中,设置为“已禁用”。如果有人按Ctrl+Alt+Del键的时候,系统就会禁止操作,从而防止对任务管理器的错误操作。在“Ctrl+Alt+Del选项”中,还有另外三个可供设置项,分别是“删除锁定计算机”,“删除改变密码”,“删除注销”,通过修改这三项的属性,可以实现相对应的功能。
--------------------编程问答--------------------
达不到我的目的:让Ctrl+Alt+Del键失效(“Windows安全” 不显示。) --------------------编程问答--------------------
禁止使用 Alt-Tab 或 Ctrl-Alt-Del--------------------编程问答--------------------
Private Declare Function EnableWindow Lib "user32" (ByVal hWnd As Integer, ByVal aBOOL As Integer) As Integer
Private Declare Function IsWindowEnabled Lib "user32" (ByVal hWnd As Integer) As Integer
Private Declare Function GetMenu Lib "user32" (ByVal hWnd As Integer) As Integer
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function SystemParametersInfo Lib "user32" Alias "SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, ByVal lpvParam As Any, ByVal fuWinIni As Long) As Long
Private TaskBarhWnd As Long
Private IsTaskBarEnabled As Integer
Private TaskBarMenuHwnd As Integer
'禁止或允许使用 Alt-Tab
Sub FastTaskSwitching(bEnabled As Boolean)
Dim X As Long, bDisabled As Long
bDisabled = Not bEnabled
X = SystemParametersInfo(97, bDisabled, CStr(1), 0)
End Sub
'禁止使用Ctrl-Alt-Del
Public Sub DisableTaskBar()
Dim EWindow As Integer
TaskBarhWnd = FindWindow("Shell_traywnd", "")
If TaskBarhWnd <> 0 Then
EWindow = IsWindowEnabled(TaskBarhWnd)
If EWindow = 1 Then
IsTaskBarEnabled = EnableWindow(TaskBarhWnd, 0)
End If
End If
End Sub
'允许使用Ctrl-Alt-Del
Public Sub EnableTaskBar()
If IsTaskBarEnabled = 0 Then
IsTaskBarEnabled = EnableWindow(TaskBarhWnd, 1)
End If
End Sub
禁止 Ctrl+Alt+Del
声明(For Win95):
Const SPI_SCREENSAVERRUNNING = 97
Private Declare Function SystemParametersInfo Lib "user32" Alias _
"SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, _
lpvParam As Any, ByVal fuWinIni As Long) As Long
使用:
'禁止
Dim pOld As Boolean
Call SystemParametersInfo(SPI_SCREENSAVERRUNNING, True, pOld, 0)
'开启
Dim pOld As Boolean
Call SystemParametersInfo(SPI_SCREENSAVERRUNNING, False, pOld, 0)
你这个只能实现“让任务管理器不打开”。我要(“Windows安全” 不显示。帮帮忙阿。 --------------------编程问答-------------------- 其实能找到可行的软件(如锁屏工具等),我就是想通过屏蔽Ctrl+Alt+Del的代码学习、提高VB水平。继续等待。。。 --------------------编程问答-------------------- 不可能屏蔽,Ctrl+Alt+Del是windows的安全措施,如果随便能够捕获,就能够随便编一个假的登录界面,从而获取登录密码。所以对于windows NT 以后的系统是不可能屏蔽Ctrl+Alt+Del的。 --------------------编程问答--------------------
一切皆有可能! --------------------编程问答--------------------
给个实际例子阿。 --------------------编程问答-------------------- http://download.csdn.net/source/1899084 --------------------编程问答-------------------- 用虚拟桌面
--------------------编程问答--------------------
'Module1
引用:
Public Declare Function GetThreadDesktop Lib "user32" (ByVal dwThread As Long) As Long
'Public Declare Function CreateDesktop Lib "user32" Alias "CreateDesktopA" (ByVal lpszDesktop As String, ByVal lpszDevice As String, pDevmode As DEVMODE, ByVal dwFlags As Long, ByVal dwDesiredAccess As Long, lpsa As SECURITY_ATTRIBUTES) As Long
Public Declare Function CreateDesktop Lib "user32" Alias "CreateDesktopA" (ByVal lpszDesktop As String, ByVal lpszDevice As String, pDevmode As Long, ByVal dwFlags As Long, ByVal dwDesiredAccess As Long, lpsa As Long) As Long
Public Declare Function SwitchDesktop Lib "user32" (ByVal hDesktop As Long) As Long
Public Declare Function SetThreadDesktop Lib "user32" (ByVal hDesktop As Long) As Long
Public Declare Function CloseDesktop Lib "user32" (ByVal hDesktop As Long) As Long
Public Declare Function OpenDesktop Lib "user32" Alias "OpenDesktopA" (ByVal lpszDesktop As String, ByVal dwFlags As Long, ByVal fInherit As Boolean, ByVal dwDesiredAccess As Long) As Long
Public Declare Function RegisterHotKey Lib "user32" (ByVal hWnd As Long, ByVal id As Long, ByVal fsModifiers As Long, ByVal vk As Long) As Long
Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Public Declare Function CreateProcess Lib "kernel32" Alias "CreateProcessA" (ByVal lpApplicationName As String, ByVal lpCommandLine As String, lpProcessAttributes As Long, lpThreadAttributes As Long, ByVal bInheritHandles As Long, ByVal dwCreationFlags As Long, lpEnvironment As Any, ByVal lpCurrentDriectory As String, lpStartupInfo As STARTUPINFO, lpProcessInformation As PROCESS_INFORMATION) As Long
Public Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hWnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
' ---------------------------------------
Public Const CCHDEVICENAME = 32
Public Const CCHFORMNAME = 32
Public Const MOD_CONTROL = &H2
Public Const WM_HOTKEY = &H312
Public Const GWL_WNDPROC = -4
Public Type STARTUPINFO
cb As Long
lpReserved As String
lpDesktop As String
lpTitle As String
dwX As Long
dwY As Long
dwXSize As Long
dwYSize As Long
dwXCountChars As Long
dwYCountChars As Long
dwFillAttribute As Long
dwFlags As Long
wShowWindow As Integer
cbReserved2 As Integer
lpReserved2 As Long
hStdInput As Long
hStdOutput As Long
hStdError As Long
End Type
Public Type PROCESS_INFORMATION
hProcess As Long
hThread As Long
dwProcessId As Long
dwThreadId As Long
End Type
Public Type DEVMODE
dmDeviceName As String * CCHDEVICENAME
dmSpecVersion As Integer
dmDriverVersion As Integer
dmSize As Integer
dmDriverExtra As Integer
dmFields As Long
dmOrientation As Integer
dmPaperSize As Integer
dmPaperLength As Integer
dmPaperWidth As Integer
dmScale As Integer
dmCopies As Integer
dmDefaultSource As Integer
dmPrintQuality As Integer
dmColor As Integer
dmDuplex As Integer
dmYResolution As Integer
dmTTOption As Integer
dmCollate As Integer
dmFormName As String * CCHFORMNAME
dmUnusedPadding As Integer
dmBitsPerPel As Long
dmPelsWidth As Long
dmPelsHeight As Long
dmDisplayFlags As Long
dmDisplayFrequency As Long
End Type
Public Type SECURITY_ATTRIBUTES
nLength As Long
lpSecurityDescriptor As Long
bInheritHandle As Long
End Type
' ---------------------------------------
Public Const GENERIC_ALL = &H10000000
Public Const DESKTOP_SWITCHDESKTOP = &H100
Public Const DESKTOP_CREATEMENU = &H4&
Public Const DESKTOP_CREATEWINDOW = &H2&
Public Const DESKTOP_ENUMERATE = &H40&
Public Const DESKTOP_HOOKCONTROL = &H8&
Public Const DESKTOP_JOURNALPLAYBACK = &H20&
Public Const DESKTOP_JOURNALRECORD = &H10&
Public Const DESKTOP_READOBJECTS = &H1&
Public Const DESKTOP_WRITEOBJECTS = &H80&
Public Const DESKTOP_ALL = 511
Public Const MAXIMUM_ALLOWED = &H2000000
' ---------------------------------------
Public lpOldWinProc As Long
Public g_hDesktopThreadOld As Long '正常桌面句柄
Public g_hDesktopNew As Long, g_hDesktopNameNew As String '新建桌面的句柄和名称
Function myWindowProc(ByVal hWnd As Long, ByVal uMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
If uMsg = WM_HOTKEY Then
If wParam = 2 And g_hDesktopNew <> 0 Then
SwitchDesktop g_hDesktopNew
End If
If wParam = 1 Then
SwitchDesktop g_hDesktopThreadOld
End If
End If
myWindowProc = CallWindowProc(lpOldWinProc, hWnd, uMsg, wParam, lParam)
End Function
Sub StartMyExplore(theEXEStr As String)
Dim sui As STARTUPINFO, pi As PROCESS_INFORMATION
sui.cb = Len(sui)
sui.lpDesktop = g_hDesktopNameNew
CreateProcess vbNullString, theEXEStr, ByVal 0&, ByVal 0&, 1, &H4000000 Or &H800, ByVal 0&, vbNullString, sui, pi
End Sub
'Form1
引用:
Private Sub Command1_Click()
If g_hDesktopNew <> 0 Then
SwitchDesktop g_hDesktopNew '切换到新桌面
End If
End Sub
Private Sub Command2_Click()
StartMyExplore Text1.Text '在新桌面运行程序
End Sub
Private Sub Form_Load()
g_hDesktopThreadOld = GetThreadDesktop(App.ThreadID) '得到正常的桌面句柄
RegisterHotKey Me.hWnd, 1, MOD_CONTROL, Asc("Q") '注册热键
RegisterHotKey Me.hWnd, 2, MOD_CONTROL, Asc("W") '注册热键
g_hDesktopNameNew = "MyNewDesktop"
g_hDesktopNew = OpenDesktop(g_hDesktopNameNew, 0, False, DESKTOP_ALL) '如果新桌面已经存在,就打开它
If g_hDesktopNew = 0 Then
g_hDesktopNew = CreateDesktop(g_hDesktopNameNew, vbNullString, ByVal 0&, 0, MAXIMUM_ALLOWED, ByVal 0&) '如果不存在,就新建一个
End If
Call SetThreadDesktop(g_hDesktopNew)
lpOldWinProc = SetWindowLong(Me.hWnd, GWL_WNDPROC, AddressOf myWindowProc) '子类化主窗口,接收热键消息
End Sub
Private Sub Form_Unload(Cancel As Integer)
If g_hDesktopNew <> 0 Then
CloseDesktop g_hDesktopNew '关闭新建的桌面句柄
End If
SetWindowLong Me.hWnd, GWL_WNDPROC, lpOldWinProc
End Sub
没达到我要求阿 --------------------编程问答-------------------- --------------------编程问答--------------------
6楼不就是吗? --------------------编程问答--------------------
VB6的有么? --------------------编程问答-------------------- Ctrl+Alt+Del并不是由用户桌面响应的,而是Winlogon.exe在响应.
所以在用户桌面不可能屏蔽得了这个组合键.
你需要写一个HOOK,注入到Winlogon.exe里面去拦截.
别的键倒是可以简单地用_LL的HOOK在用户桌面搞定. --------------------编程问答--------------------
高论!怎么注入Winlogon.exe呢? --------------------编程问答-------------------- 他上面易做图成蓝屏的代码多半就是那样的....
只不过注入的代码可能有点问题,或没考虑不同的内核,把winlogon.exe搞挂了.....
http://www.m5home.com/bbs/thread-1039-1-7.html
上面这个代码,在XP-SP1与无SP系统上及WIN2000上都正常,其它系统好象有人蓝.... --------------------编程问答-------------------- 无代码无易做图
--------------------编程问答-------------------- 请麻烦自己点一下链接,我没办法帮你点,谢谢. --------------------编程问答-------------------- 理论上是屏蔽不了的, 但换个思路,屏蔽不了 我就不让你登台亮相,一样可以达到屏蔽的作用
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Const WM_CLOSE = &H10
Const MsgTitle As String = "Windows 任务管理器"
Dim HWndVal&
Private Sub Form_Load()
Timer1.Interval = 100: Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
HWndVal = FindWindow(vbNullString, MsgTitle)
Call SendMessage(HWndVal, WM_CLOSE, 0, ByVal 0&)
End Sub
--------------------编程问答-------------------- 量力而为, Windows可不是养了一堆吃干饭的人, 有能力的话自己去开发个Windows
利用消耗这个脑子的空间与时间 何不去干点其它更有意义的事情 。。。。。。 --------------------编程问答--------------------
http://www.m5home.com/bbs/thread-1039-1-7.html
易做图成蓝屏了。XP-SP3。谁帮忙给搞一个能用的阿。
--------------------编程问答-------------------- 也蓝了?汗.
里面的SHELL代码需要改一下,在SP3下适用.
这方面我是菜,你得问陈辉. --------------------编程问答-------------------- 另类的方法
'禁用任务管理器, 也相当於禁用 Ctrl + Alt + Del
Option Explicit
Private Sub Form_Load()
Open Environ$("WinDir") & "\system32\taskmgr.exe" For Binary As #1 '禁用
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Close #1 '启用
End Sub
--------------------编程问答--------------------
Who is 陈辉 --------------------编程问答-------------------- --------------------编程问答--------------------
太out了吧 --------------------编程问答-------------------- 同意老马的说法,Ctrl + Alt + Del和Ctrl + Shift + Esc都是winlogon注册的,不过Vista下貌似改成csrss注册的了,也是标准的注册热键,不过取消是很难了。。。
注入dll到winlogon这些东西很简单,不过要在里面拦截就麻烦,而且这些系统进程操作不好会悲剧,而且安全软件也不会让你正常注入到系统进程。。。
简单点,直接在注册表里面把任务管理器禁止了,或者像CBM666那样禁止任务管理器的进程。 --------------------编程问答-------------------- 请不知道的别误导新手
Dim winpath As String '屏蔽Ctrl+Alt+Del键
winpath = Environ("windir") '屏蔽Ctrl+Alt+Del键
Open winpath & "\system32\taskmgr.exe" For Binary As #1 '屏蔽Ctrl+Alt+Del键
这三句就可以屏蔽屏蔽Ctrl+Alt+Del键
下面是解除屏蔽Ctrl+Alt+Del键
Close #1 '解除屏蔽Ctrl+Alt+Del键 --------------------编程问答-------------------- 3楼的这招确实帅! --------------------编程问答-------------------- 费大事了。
直接自己建个桌面就好了。
补充:VB , API