如何用api实现windows系统的屏幕锁定??神仙?妖怪?谢谢!

解决方案 »

  1.   

    楼上正解,不过还要屏蔽Alt+Ctrl+Del,另外,9x/Me使用而已
      

  2.   

    锁定鼠标是最好的方法!!!
    'Example Name:ClipCursor
    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()
        'KPD-Team 1999
        'URL: http://www.allapi.net/
        'E-Mail: [email protected]
        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
      

  3.   

    98下比较好做,像2楼说的,然后再把系统各热键都屏蔽掉就成了,比如ctrl+alt+del,alt+f4,alt+tab,win键锁鼠标没用,对电脑熟悉点的用户都可以在没有鼠标的情况下使用windows,和word
      

  4.   

    可以用键盘钩子和鼠标钩子分别禁用键盘和鼠标,用VC做个DLL即可。
    楼主要的话我可以给你做一个。  :)
      

  5.   

    Declare Function BlockInput Lib "USER32.dll" (ByVal fBlockIt As Long) As LongBlockInput 1    ' 鼠标键盘统统死
    BlockInput 0    ' 活过来
    注意Ctrl+Alt+Del可以立即取消BlockInput的效果。而且当执行BlockInput时当前窗口不属同一进程时,不会产生任何效果。
      

  6.   

    Declare Function BlockInput Lib "USER32.dll" (ByVal fBlockIt As Long) As LongBlockInput 1    ' 鼠标键盘统统死
    BlockInput 0    ' 活过来
    注意Ctrl+Alt+Del可以立即取消BlockInput的效果。而且当执行BlockInput时当前窗口不属同一进程时,不会产生任何效果。
      

  7.   

    NT/2K: 最简单的是 LockWorkStation
    如果想麻烦,需要安装 WH_KEYBOARD_LL 钩子, VB就算了吧
    (我见有文章这样说,我个人没用过)
      

  8.   

    我有另外一种方法,看大家觉得怎么样?
    先得到桌面窗口的句柄和任务栏的句柄,用Enablewindow来禁用桌面及任务栏
    或者干脆用Sendmessage发送一个SW_HIDE来隐藏窗口,Progman 任务栏类名
      

  9.   

    试试看这个,突然想到的,msgbox不是有个参数是“系统级”吗,不知道能不能屏蔽掉那些热键,呵呵,等会儿试一下。
      

  10.   

    j_x_y(cctv)的方法很好,我以前编过一个delphi类似的就用的这种方法.
      

  11.   

    用api函数SystemParametersInfo (SPI_SETSCREENSAVERRUNNING,TRUE,NULL,0) 取消ctrl+alt+del
    然后隐藏任务栏
    FindWindow ("Shell_TrayWnd",NULL) '找到任务栏的句柄
    showwindow(hwnd,false)
    注意最好是锁定鼠标,用系统热键呼叫解锁程序
      

  12.   

    干脆让Window不接受键盘输入及Mouse Click:Private Declare Function EnableWindow Lib "user32" (ByVal hwnd As Long, ByVal fEnable As Long) As Long
    Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)Private Sub Command1_Click()
    Call EnableWindow(Me.hwnd, 0)
    Me.Caption = "现在拒绝KeyPress, MouseClick"
    Dim i As Long
    For i = 1 To 100
    Call Sleep(100)
    DoEvents '虽有DoEvents,会发现,按Form的任何地方都没有反应
    Next i
    Me.Caption = "现在解除了"
    Call EnableWindow(Me.hwnd, 1)
    End Sub
    不过Mouse仍可自由的移动,若要让Mouse也不能动,就使用JournalPlayBack Hook,而不是使用本方法。