雙擊窗體進入常規
CODE:
Imports System
Imports Microsoft
Public Class Form
<DllImport(
Friend Shared Function GetCurrentProcess() As IntPtr
End Function
<DllImport(
Friend Shared Function OpenProcessToken(ByVal h As IntPtr
End Function
<DllImport(
Friend Shared Function LookupPrivilegeValue(ByVal host As String
End Function
<DllImport(
Friend Shared Function AdjustTokenPrivileges(ByVal htok As IntPtr
End Function
<DllImport(
Friend Shared Function ExitWindowsEx(ByVal flg As Integer
End Function
Friend Const SE_PRIVILEGE_ENABLED As Integer = &H
Friend Const TOKEN_QUERY As Integer = &H
Friend Const TOKEN_ADJUST_PRIVILEGES As Integer = &H
Friend Const SE_SHUTDOWN_NAME As String =
Friend Const EWX_LOGOFF As Integer = &H
Friend Const EWX_SHUTDOWN As Integer = &H
Friend Const EWX_REBOOT As Integer = &H
Friend Const EWX_FORCE As Integer = &H
Friend Const EWX_POWEROFF As Integer = &H
Friend Const EWX_FORCEIFHUNG As Integer = &H
<StructLayout(LayoutKind
Friend Structure TokPriv
Public Count As Integer
Public Luid As Long
Public Attr As Integer
End Structure
Private Shared Sub DoExitWin(ByVal flg As Integer)
Dim xc As Boolean
Dim tp As TokPriv
Dim hproc As IntPtr = GetCurrentProcess()
Dim htok As IntPtr = IntPtr
xc = OpenProcessToken(hproc
tp
tp
tp
xc = LookupPrivilegeValue(Nothing
xc = AdjustTokenPrivileges(htok
xc = ExitWindowsEx(flg
End Sub
Public Shared Sub Reboot()
DoExitWin((EWX_FORCE Or EWX_REBOOT))
End Sub
Public Shared Sub PowerOff()
DoExitWin((EWX_FORCE Or EWX_POWEROFF))
End Sub
Public Shared Sub LogoOff()
DoExitWin((EWX_FORCE Or EWX_LOGOFF))
End Sub
Dim entTime As Object
Dim xianzaiTime As Object
Dim startTime As Object
[
From:http://tw.wingwit.com/Article/program/net/201311/15695.html