Const EWX_LOGOFF = 0 Const EWX_SHUTDOWN = 1 Const EWX_REBOOT = 2 Const EWX_FORCE = 4 Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long Private Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Long, ByVal dwReserved As Long) As Long
Private Sub fairyTimer_Timer() Dim myweekday, mydate Dim mytime, hh$, mm$, ss$ mydate = Date myweekday = Weekday(mydate) mytime = Time hh$ = Left$(mytime, 2) mm$ = Mid$(mytime, 4, 2) If myweekday > 1 And myweekday < 7 Then 注释:周一至周五登录规则 If hh > 18 And hh < 19 Then Exit Sub Else End If Else 注释:双休日登录规则 If hh > 13 And hh < 15 Then Exit Sub ElseIf hh > 18 And hh < 20 Then Exit Sub Else End If End If mainForm.Visible = True mainTimer.Interval = 60000 注释:启动注销进程 End Sub
Private Sub Form_Load() Dim s$, cnt&, dl& cnt& = 199 s$ = String$(200, 0) dl& = GetUserName(s$, cnt) 注释:Debug.Print Left$(s$, cnt - 1); cnt If Left$(s$, cnt - 1) = "ChenHL" Then fairyTimer.Interval = 6000 注释:启动监听精灵 Else mainTimer.Interval = 0 End If End Sub
Private Sub Form_Unload(Cancel As Integer) Dim ret& ret& = ExitWindowsEx(EWX_FORCE Or EWX_LOGOFF, 0) End Sub
Private Sub mainTimer_Timer() Dim ret& ret& = ExitWindowsEx(EWX_FORCE Or EWX_LOGOFF, 0) End Sub