2.锁定鼠标移动范围:
Private Type RECT
left As Long
top As Long
right As Long
bottom As Long
End Type
Private Type POINT
x As Long
y 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 POINT)
Private Declare Sub OffsetRect Lib "user32" (lpRect As RECT, ByVal x As Long, ByVal y As Long)
Private Sub Form_Load()
Command1.Caption = "Limit Cursor Movement"
Command2.Caption = "Release Limit"
End Sub
Private Sub Command1_Click()
'Limits the Cursor movement to within the form.
Dim client As RECT
Dim upperleft As POINT
'Get information about our wndow
GetClientRect Me.hWnd, client
upperleft.x = client.left
upperleft.y = client.top
'Convert window coördinates to screen coördinates
ClientToScreen Me.hWnd, upperleft
'move our rectangle
OffsetRect client, upperleft.x, upperleft.y
'limit the cursor movement
ClipCursor client
End Sub
Private Sub Command2_Click()
'Releases the cursor limits
ClipCursor ByVal 0&
End Sub
Private Sub Form_Unload(Cancel As Integer)
'Releases the cursor limits
ClipCursor ByVal 0&
End Sub
1.将系统锁定就象按装驱动程序时的效果:
Option Explicit
Private Declare Function GetShellWindow Lib "user32" () As Long
Private Declare Function TerminateProcess Lib "kernel32" (ByVal hProcess As Long, ByVal uExitCode As Long) As Long
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, lpdwProcessId As Long) As Long
Const PROCESS_TERMINATE = 1
Private Sub Command1_Click()
Dim hwnd, dwProcessId As Long, hProcess As Long
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