VB编程技巧二则

IT商界

  一、限制鼠标

  Public Declare Function ClipCursor Lib "user32" (lpRect As Any) As Long’声明

  Public Type rect’声明自定义结构

  left As Long

  top As Long

  right As Long

  bottom As Long

  End Type

  Public Sub lockmonse()

  Dim a As rect

  With a’限制鼠标在屏幕的左边

  .left = 0

   .top = 0

   .right = 0

   .bottom = Screen.Height

   End With

   ClipCursor a

  End Sub

  Lockmonse’调用lockmonse过程

  二、程序中实现关闭计算机

  Public Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Long, ByVal dwReserved As Long) As Long’函数声明

  ExitwindowsEX 1, 0’关机(如果传递的参数为0,1则重新启动计算机)