首先打開 Microsoft Visual Studio 2005,新建一個 Windows 應用程序 (Windows Application)。
然後添加3個button控件,分別命名為為btnLogout、btnClose、btnReboot,它們的text屬性分別為注銷、關機、重新啟動。如圖:
以下是本例的代碼代碼:
Imports System.Runtime.InteropServices
Imports Microsoft.VisualBasic
Public Class form
_
FrIEnd Shared Function GetCurrentProcess() As IntPtr
End Function
_
FrIEnd Shared Function OpenProcessToken(ByVal h As IntPtr, ByVal acc As Integer, ByRef phtok As IntPtr) As Boolean
End Function
_
FrIEnd Shared Function LookupPrivilegeValue(ByVal host As String, ByVal name As String, ByRef pluid As Long) As Boolean
End Function
_
FrIEnd Shared Function AdjustTokenPrivileges(ByVal htok As IntPtr, ByVal disall As Boolean, ByRef newst As TokPriv1Luid, _
ByVal len As Integer, ByVal prev As IntPtr,