by Nimesh Patel (3 Submissions)
Category: Windows System Services
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Sun 7th April 2002
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Lock Your Computer...
API Declarations
-----------------------------
Option Explicit
'hides and shows the desktop
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
'swap the mouse buttons
Private Declare Function SwapMouseButton& Lib "user32" (ByVal bSwap As Long)
'enable and disable ctrl+alt+delete
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
Private Const SPI_SCREENSAVERRUNNING = 97
____________________________________________________________________________
Form2 name : frmmain
---------------------------------
Option Explicit
'hides and shows the desktop
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
'swap the mouse buttons
Private Declare Function SwapMouseButton& Lib "user32" (ByVal bSwap As Long)
'enable and disable ctrl+alt+delete
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
Private Const SPI_SCREENSAVERRUNNING = 97
--------------------------------Private Sub txtPassword_Change()
txtPassword.SetFocus
If txtPassword.Text = "admin" Then
'when you unlock the program...
'enables ctrl+alt+delete
'shows mouse
'unswaps the mouse buttons
'shows taskbar
'shows desktop
Dim hWnd As Long
Dim Ret As Long
Dim pOld As Boolean
Dim rtn As Long
rtn = FindWindow("Shell_traywnd", "")
Call SetWindowPos(rtn, 0, 0, 0, 0, 0, SWP_SHOWWINDOW)
hWnd = FindWindowEx(0&, 0&, "Progman", vbNullString)
ShowWindow hWnd, 5
Ret = SystemParametersInfo(SPI_SCREENSAVERRUNNING, False, pOld, 0)
ShowCursor (True)
SwapMouseButton (False)
Me.Hide
End If
End Sub
________________________________________________________________________________
form2 name : frmmain
----------------------------------
Private Sub Form_Load()
'when you lock the program...
'disables ctrl+alt+delete
'hides mouse
'swaps the mouse buttons
'hides taskbar
'hides desktop
Dim rtn As Long
Dim Ret As Long
Dim pOld As Boolean
Dim hWnd As Long
hWnd = FindWindowEx(0&, 0&, "Progman", vbNullString)
ShowWindow hWnd, 0
Ret = SystemParametersInfo(SPI_SCREENSAVERRUNNING, True, pOld, 0)
ShowCursor (False)
SwapMouseButton (True)
rtn = FindWindow("Shell_traywnd", "")
Call SetWindowPos(rtn, 0, 0, 0, 0, 0, SWP_HIDEWINDOW)
Me.Hide
frmLOCKED.Show
End Sub
_______________________________________________________________________________
Modules name : module1
--------------------------------------------Option Explicit
'hides and shows the taskbar
Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
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
'hides and shows mouse
Declare Function ShowCursor& Lib "user32" (ByVal bShow As Long)
'open and close CD tray
Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long