Workstation sperren

SystemParametersInfo, SetWindowPos
Benutzt die SystemParametersInfo-API-Function, um dem System zu sagen, dass ein Bildschirmschoner läuft.
Setzt  Alt-Tab  und  Ctl-Alt-Del  außer Kraft.
Private Declare Function SystemParametersInfo Lib "user32" Alias "SystemParametersInfoA" (ByVal uAction As Long, _
  ByVal uParam As Long, ByRef lpvParam As Any, ByVal fuWinIni As Long) As Long
Private Const SPI_SCREENSAVERRUNNING = 97
Private m_LastLeft As Single
Private m_LastTop As Single
Private m_LastWidth As Single
Private m_LastHeight As Single
Use the SetWindowPos to make the form topmost and position it over the entire screen including the task bar.
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 Const SWP_NOMOVE = &H2
Private Const SWP_NOSIZE = &H1
Private Const HWND_TOPMOST = -1
Private Const HWND_NOTOPMOST = -2
Private Sub cmdExit_Click()
Unload Me
End Sub
Private Sub cmdLockWorkstation_Click() Lock the computer so the user cannot use other programs.
Dim prev_value As Long
Dim wid As Long
Dim hgt As Long
 cmdLockWorkstation.Enabled = False
 cmdUnlockWorkstation.Enabled = True
 cmdExit.Enabled = False
 m_LastLeft = Left Save the current size and position.
 m_LastTop = Top
 m_LastWidth = Width
 m_LastHeight = Height
 wid = Screen.Width / Screen.TwipsPerPixelX Put the form on top of everything (including the task bar).
 hgt = Screen.Height / Screen.TwipsPerPixelY
 SetWindowPos hwnd, HWND_TOPMOST, 0, 0, wid, hgt, 0
 SystemParametersInfo SPI_SCREENSAVERRUNNING, _ Tell the system a screen saver is running.
   True, prev_value, 0
End Sub
Private Sub cmdUnlockWorkstation_Click()
Dim prev_value As Long
 cmdLockWorkstation.Enabled = True
 cmdUnlockWorkstation.Enabled = False
 cmdExit.Enabled = True
 Move m_LastLeft, m_LastTop, m_LastWidth, m_LastHeight Restore the size and position.
 SystemParametersInfo SPI_SCREENSAVERRUNNING, _ Tell the system no screen saver is running.
   False, prev_value, 0
End Sub
Private Sub Form_Load()
 Move (Screen.Width - Width) / 2, (Screen.Height - Height) / 2
 cmdLockWorkstation.Enabled = True
 cmdUnlockWorkstation.Enabled = False
 cmdExit.Enabled = True
End Sub
Private Sub Form_Resize()
Const GAP = 60
Dim X As Single
Dim Y As Single
 X = (ScaleWidth - cmdLockWorkstation.Width) / 2
 Y = ScaleHeight / 2 - 1.5 * cmdLockWorkstation.Height - GAP
 cmdLockWorkstation.Move X, Y
 Y = Y + cmdLockWorkstation.Height + GAP
 cmdUnlockWorkstation.Move X, Y
 Y = Y + cmdLockWorkstation.Height + GAP
 cmdExit.Move X, Y
End Sub
Private Sub Form_Unload(Cancel As Integer)
 cmdUnlockWorkstation_Click
End Sub

 Ranking-Hits zurück Sitemap
Designed by www.wbrnet.info