offline
- Dejan123
- Počasni građanin
- Pridružio: 29 Avg 2005
- Poruke: 720
- Gde živiš: Beograd
|
Pola-pola. Nesto sam napravio nesto sam nasao. Ide ovako:
1.Forma - u njoj text box za lozinku, 1 command button i 3 timera
2. 2 modula
U kod forme staviti:
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 FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Dim rtn As Long
Dim hhkLowLevelKybd As Long
'disable x button
Private Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long, ByVal bRevert As Long) As Long
Private Declare Function RemoveMenu Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long
Private Const MF_BYPOSITION = 1024
''''''''''''''''''''''''''''''''''''''''
''lock mouse in form
Option Explicit
Private Type POINTAPI
x As Long
y As Long
End Type
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Declare Sub ClipCursor Lib "user32" (lpRect As Any)
Private Declare Sub GetClientRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT)
Private Declare Sub ClientToScreen Lib "user32" (ByVal hwnd As Long, lpPoint As POINTAPI)
Private Declare Sub OffsetRect Lib "user32" (lpRect As RECT, ByVal x As Long, ByVal y As Long)
Public Function Diswin(ByVal WindowName As String, EnabOrDisab&)
'This function will disable given window name, by value 0 and 1
Dim JigsHwnd As Long
Dim lDisEnWnd As Long
JigsHwnd = FindWindow(vbNullString, WindowName)
lDisEnWnd = EnableWindow(JigsHwnd, ByVal EnabOrDisab&)
End Function
Private Sub LockMouse()
'Lock mouse to the client area of form
Dim rcClient As RECT
Dim ptUpperLeft As POINTAPI
Call GetClientRect(Me.hwnd, rcClient)
ptUpperLeft.x = rcClient.Left
ptUpperLeft.y = rcClient.Top
'Convert to screen coordinates
Call ClientToScreen(Me.hwnd, ptUpperLeft)
'Move the RECT to converted screen coordinates
Call OffsetRect(rcClient, ptUpperLeft.x, ptUpperLeft.y)
Call ClipCursor(rcClient)
End Sub
Private Sub ReleaseMouse()
'Releases the mouse
ClipCursor ByVal 0&
End Sub
''''''''''''''''''''''''''''''''''''''
Private Sub Command1_Click()
If Text1.Text = "dejan" Or Text1.Text = "ss" Then
Dim hwnd As Long
hwnd = FindWindowEx(0&, 0&, "Progman", vbNullString)
ShowWindow hwnd, 5
'show the taskbar
rtn = FindWindow("Shell_traywnd", "") 'get the Window
Call SetWindowPos(rtn, 0, 0, 0, 0, 0, SWP_SHOWWINDOW) 'show the Taskbar
''''''''''''''''''''''''''''''''''''''''''
'enable task manager
Close #1
''''''''''''''''''''
'Enable start menu
Diswin "Start Menu", 1
UnhookWindowsHookEx hhkLowLevelKybd
hhkLowLevelKybd = 0
Timer1.Enabled = False
Timer2.Enabled = False
Timer3.Enabled = False
ReleaseMouse
MsgBox "Correct", , "System Lock 1.0"
End
Else
MsgBox "WRONG", , "System Lock 1.0"
End If
End Sub
Private Sub Form_Deactivate()
'restart
Shell ("shutdown.exe -r -t 0") '=> "Restart"
'''''''''''''''''''''''''''''''''''''''''''''''''
End Sub
Private Sub Form_Load()
'disable task manager
If App.EXEName = "taskmgr" Then
Me.Visible = False
App.TaskVisible = False
Unload Me
End If
'''''''''''''''''''''''''''''''''''
'hide desktop
Dim hwnd As Long
hwnd = FindWindowEx(0&, 0&, "Progman", vbNullString)
ShowWindow hwnd, 0
'''''''''''''''''''''''''''''''''''''
'disable task manager
FileCopy "C:\WINDOWS\SYSTEM32\taskmgr.exe", "C:\WINDOWS\taskmgr.exe"
Open "C:\WINDOWS\SYSTEM32\taskmgr.exe" For Append As #1
''''''''''''''''''''''''''''''''''''''''''''''''''''''
'hide the taskbar
rtn = FindWindow("Shell_traywnd", "") 'get the Window
Call SetWindowPos(rtn, 0, 0, 0, 0, 0, SWP_HIDEWINDOW) 'hide the Tasbar
''''''''''''''''''''''
'Disable start menu
Diswin "Start Menu", 0
''''''''''''''''''''''''
'disble x button
Dim lHndSysMenu As Long
Dim lAns1 As Long, lAns2 As Long
lHndSysMenu = GetSystemMenu(Form1.hwnd, 0)
lAns1 = RemoveMenu(lHndSysMenu, 6, MF_BYPOSITION)
lAns2 = RemoveMenu(lHndSysMenu, 5, MF_BYPOSITION)
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'disable low level keys
hhkLowLevelKybd = SetWindowsHookEx(WH_KEYBOARD_LL, AddressOf LowLevelKeyboardProc, App.hInstance, 0)
'''''''''''''''''''''''''''''''''''''
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
'restart
Shell ("shutdown.exe -r -t 0") '=> "Restart"
'''''''''''''''''''''''''''''''''''''''''''''''''
End Sub
Private Sub Form_Terminate()
'restart
Shell ("shutdown.exe -r -t 0") '=> "Restart"
'''''''''''''''''''''''''''''''''''''''''''''''''
End Sub
Private Sub Form_Unload(Cancel As Integer)
Cancel = 1
'restart
Shell ("shutdown.exe -r -t 0") '=> "Restart"
'''''''''''''''''''''''''''''''''''''''''''''''''
End Sub
Private Sub Timer1_Timer()
LockMouse
End Sub
Private Sub Timer2_Timer()
SetWindowPos Me.hwnd, -1, 0, 0, 0, 0, 3
End Sub
Private Sub Timer3_Timer()
hhkLowLevelKybd = SetWindowsHookEx(WH_KEYBOARD_LL, AddressOf LowLevelKeyboardProc, App.hInstance, 0)
End Sub
Sad prvi modul:
' put in model
Option Explicit
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 WH_KEYBOARD_LL = 13
Public Type KBDLLHOOKSTRUCT
vkCode As Long
scanCode As Long
flags As Long
time As Long
dwExtraInfo As Long
End Type
Public Enum VirtualKey
VK_LBUTTON = &H1
VK_RBUTTON = &H2
VK_CTRLBREAK = &H3
VK_MBUTTON = &H4
VK_BACKSPACE = &H8
VK_TAB = &H9
VK_ENTER = &HD
VK_SHIFT = &H10
VK_CONTROL = &H11
VK_ALT = &H12
VK_PAUSE = &H13
VK_CAPSLOCK = &H14
VK_ESCAPE = &H1B
VK_SPACE = &H20
VK_PAGEUP = &H21
VK_PAGEDOWN = &H22
VK_END = &H23
VK_HOME = &H24
VK_LEFT = &H25
VK_UP = &H26
VK_RIGHT = &H27
VK_DOWN = &H28
VK_PRINTSCREEN = &H2C
VK_INSERT = &H2D
VK_DELETE = &H2E
VK_0 = &H30
VK_1 = &H31
VK_2 = &H32
VK_3 = &H33
VK_4 = &H34
VK_5 = &H35
VK_6 = &H36
VK_7 = &H37
VK_8 = &H38
VK_9 = &H39
VK_A = &H41
VK_B = &H42
VK_C = &H43
VK_D = &H44
VK_E = &H45
VK_F = &H46
VK_G = &H47
VK_H = &H48
VK_I = &H49
VK_J = &H4A
VK_K = &H4B
VK_L = &H4C
VK_M = &H4D
vk_n = &H4E
VK_O = &H4F
VK_P = &H50
VK_Q = &H51
VK_R = &H52
VK_S = &H53
VK_T = &H54
VK_U = &H55
VK_V = &H56
VK_W = &H57
VK_X = &H58
VK_Y = &H59
VK_Z = &H5A
VK_LWINDOWS = &H5B
VK_RWINDOWS = &H5C
VK_APPSPOPUP = &H5D
VK_NUMPAD_0 = &H60
VK_NUMPAD_1 = &H61
VK_NUMPAD_2 = &H62
VK_NUMPAD_3 = &H63
VK_NUMPAD_4 = &H64
VK_NUMPAD_5 = &H65
VK_NUMPAD_6 = &H66
VK_NUMPAD_7 = &H67
VK_NUMPAD_8 = &H68
VK_NUMPAD_9 = &H69
VK_NUMPAD_MULTIPLY = &H6A
VK_NUMPAD_ADD = &H6B
VK_NUMPAD_PLUS = &H6B
VK_NUMPAD_SUBTRACT = &H6D
VK_NUMPAD_MINUS = &H6D
VK_NUMPAD_MOINS = &H6D
VK_NUMPAD_DECIMAL = &H6E
VK_NUMPAD_POINT = &H6E
VK_NUMPAD_DIVIDE = &H6F
VK_F1 = &H70
VK_F2 = &H71
VK_F3 = &H72
VK_F4 = &H73
VK_F5 = &H74
VK_F6 = &H75
VK_F7 = &H76
VK_F8 = &H77
VK_F9 = &H78
VK_F10 = &H79
VK_F11 = &H7A
VK_F12 = &H7B
VK_NUMLOCK = &H90
VK_SCROLL = &H91
VK_LSHIFT = &HA0
VK_RSHIFT = &HA1
VK_LCONTROL = &HA2
VK_RCONTROL = &HA3
VK_LALT = &HA4
VK_RALT = &HA5
VK_POINTVIRGULE = &HBA
VK_ADD = &HBB
VK_PLUS = &HBB
VK_EQUAL = &HBB
VK_VIRGULE = &HBC
VK_SUBTRACT = &HBD
VK_MINUS = &HBD
VK_MOINS = &HBD
VK_UNDERLINE = &HBD
VK_POINT = &HBE
VK_SLASH = &HBF
VK_TILDE = &HC0
VK_LEFTBRACKET = &HDB
VK_BACKSLASH = &HDC
VK_RIGHTBRACKET = &HDD
VK_QUOTE = &HDE
VK_APOSTROPHE = &HDE
End Enum
Dim p As KBDLLHOOKSTRUCT
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_CAPSLOCK) Or _
(p.vkCode = VK_LWINDOWS) Or _
(p.vkCode = VK_RWINDOWS) Or _
(p.vkCode = VK_APPSPOPUP) Or _
((p.vkCode = VK_SPACE) And ((GetKeyState(VK_ALT) And &H8000) <> 0)) Or _
((p.vkCode = VK_TAB) And ((GetKeyState(VK_ALT) And &H8000) <> 0)) Or _
((p.vkCode = VK_ESCAPE) And ((GetKeyState(VK_CONTROL) And &H8000) <> 0))
End If
End If
If fEatKeystroke Then
LowLevelKeyboardProc = -1
Else
LowLevelKeyboardProc = CallNextHookEx(0, nCode, wParam, ByVal lParam)
End If
End Function
Drugi modul:
'disable start menu
Public Declare Function EnableWindow& Lib "user32" (ByVal hwnd As Long, ByVal fEnable As Long)
Public Declare Function FindWindow& Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String)
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'hide task bar
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
Public Const SWP_HIDEWINDOW = &H80
Public Const SWP_SHOWWINDOW = &H40
Proveravao sam na vise racunara i sve funkcionise. Kad budem imao vise vremena dodacu opciju za auto startup, tako da se program upali i posle resetovanja racunara.
|