vb挂机锁
请问怎么用vb制作一个完整的挂机锁(仿万象挂机锁,就是在网吧万象网管有个挂机锁,有屏幕小键盘),谢谢了!最好不要下载!
追问:来自手机问问那你把代码和动态链接库一起发到我邮箱,1047910711@qq.com,谢谢!
请问怎么用vb制作一个完整的挂机锁(仿万象挂机锁,就是在网吧万象网管有个挂机锁,有屏幕小键盘),谢谢了!最好不要下载!
追问:来自手机问问那你把代码和动态链接库一起发到我邮箱,1047910711@qq.com,谢谢!
答案:我不知道你了不了解全局HOOK,HOOK简单来说就是跟操作系统比速度。为什么这样说呢,举个例子,当你移动了鼠标,会发生一个鼠标移动的消息,这个时候如果你做一HOOOK过程,那么这个鼠标移动的消息你将比操作系统更具有优先处理的权力,比如你不让这个鼠标移动的消息交给系统来处理,就好比你吃掉了这条消息一样,换言之,你移动了鼠标就跟没有移动一样。
根据你的要求,我觉得这个功能需要借助于全局HOOK过程。据我所知,VB6好象不能实现全局HOOK过程,如果想要实现全局HOOK的话,需要借助于其它语言,如C写一个DLL文件,然后在VB6里调用。我没有VB版的,只有一个C#版的,要的话给我联系。
请先在窗体上新建这些控件.
以下程式用到了MD5算法,这样密码就不容易被破.如果只是做为测试,请自行取消有MD5的代码.
Dim tempLP As String
Private Declare Function SetWindowPos Lib "user32" ( _
ByVal hwnd As Long, _
ByVal hWndInsertAfter As Long, _
ByVal X As Long, _
ByVal Y As Long, _
ByVal cx As Long, _
ByVal cy As Long, _
ByVal wFlags As Long) As Long
Private mbOnTop As Boolean
Private Property Let OnTop(Setting As Boolean)
If Setting Then
SetWindowPos hwnd, -1, 0, 0, 0, 0, &H2 Or &H1
Else
SetWindowPos hwnd, -2, 0, 0, 0, 0, &H2 Or &H1
End If
mbOnTop = Setting
End Property
Private Property Get OnTop() As Boolean
'Return the private variable set in Property Let
OnTop = mbOnTop
End Property
Private Sub LXH2_Click()End Sub
Private Sub cmdcancelLock_Click()
If cmdcancelLock.Caption = "确认解锁" Then
If Md5(txtLockPass(1).Text, 134) = tempLP Then Unload Me: frmmain.Show
Else
Unload Me
frmmain.Show
End If
End SubPrivate Sub cmdLockOk_Click()
Me.WindowState = 2
fraSet.Caption = " 服务器已锁定,请输入密码解锁... "
fraSet.Left = (Me.Width - fraSet.Width) / 2
fraSet.Top = (Me.Height - fraSet.Height) / 2
lbl(0).Visible = False
lbl(2).Visible = False
txtLockPass(0).Visible = False
txtLockPass(2).Visible = False
lbl(1).Caption = "解锁密码:"
cmdLockOk.Visible = False
cmdeditLock.Visible = False
cmdcancelLock.Caption = "确认解锁"
txtLockPass(0).Text = ""
txtLockPass(1).Text = ""
txtLockPass(2).Text = ""
Call loadLockPass
Timer1.Enabled = True
End SubPrivate Sub cmdeditLock_Click()
If Md5(txtLockPass(0).Text, 134) = tempLP Then
If txtLockPass(1).Text = txtLockPass(2).Text And txtLockPass(1).Text <> "" Then
myWriteINI App.Path & "\already.ini", "main", "lockpass", Md5(txtLockPass(2).Text, 134)
MsgBox "密码修改成功!", vbInformation
txtLockPass(0).Text = ""
txtLockPass(1).Text = ""
txtLockPass(2).Text = ""
Call loadLockPass
Else
MsgBox "两次输入的密码不一致!", vbQuestion
End If
Else
MsgBox "原始密码错误!", vbCriticalEnd If
End Sub
Private Sub Form_Load()
OnTop = True
Call loadLockPassEnd Sub
Private Sub fraSet_DragDrop(Source As Control, X As Single, Y As Single)
End Sub
Private Sub Timer1_Timer()
'Call MouseDis
txtLockPass(1).SetFocus
End SubPrivate Sub txtLockPass_KeyPress(Index As Integer, KeyAscii As Integer)
If KeyAscii = 13 Then cmdcancelLock_Click: KeyAscii = 0
End SubSub loadLockPass()
tempLP = Trim(myReadINI(App.Path & "\already.ini", "main", "lockpass", ""))
tempLP = Left(tempLP, Len(tempLP) - 1)
If tempLP = "" Then tempLP = "308920E0WL063798ADZXEF5AB698"'这里为初始密码的MD5码.不需要就直接改为123456
End SubSub MouseDis()
Dim R As Recs
Dim L As Recs
Dim W, H, T, B As Long
W = Me.Width
H = Me.Height
T = Screen.TwipsPerPixelX
B = Screen.TwipsPerPixelY
R.Left = Me.Left / 15
R.Top = Me.Top / 15
R.Right = (Me.Left + Me.Width) / 15
R.Bottom = (Me.Top + Me.Height) / 15
'ClipCursor R'OnTop = True
AllowKeys True
'Me.SetFocusSetKeyValue USER, Pol, "DisableTaskMgr", "1", 1 'DWORD
End Sub
不知道这样的可不可以。
锁定后鼠标也会被锁定
说说大概思路吧,一个程式你要明确它的功能,功能描述完整了才好下手,这是程序前必须的工作,有助于效率提高,挂机锁就是用户不能操作系统,实际上是可以的,只不过途径被我们封了,一个最大化的才窗口覆盖屏幕,这个窗口不能被最小化,不能被结束进程,不能被切换,不能被关闭,此时用户有鼠标和键盘两种输入途径,鼠标不用屏蔽,主要是评标键盘,这就需要键盘钩子hook
Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags 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 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
Private Declare Function UnhookWindowsHookEx Lib "user32" (ByVal hHook As Long) As Long
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
Public Const REG_SZ As Long = 1
Public Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Declare Function GetActiveWindow Lib "user32" () As Long
Public 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
Public Const HKEY_LOCAL_MACHINE = &H80000002
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Public Const WM_CLOSE = &H10
Public ihook As Long
Private Type PKBDLLHOOKSTRUCT
vkCode As Long
scanCode As Long
flags As Long
time As Long
dwExtraInfo As Long
End Type
Private Const VK_RETURN = &HD
Private Const VK_ESCAPE = &H1B
Private Const VK_CONTROL = 17
Private Const VK_ME
上一个:vb的dim 怎么用啊?
下一个:VB新手入门问题