VB.Net远程控制编程实例[注销关机重启] |
作者:IVA 来源:乐博网转化 更新时间:2007-12-16 |
原代码为C#编写,由L3'Studio团队开发;乐博网将其转化为VB.Net代码 功能描述:管理类(主要有关机重启等功能,API函数实现) 相关事件 :注销 关机 重启 命名空间:Lob.Windows 子类:WindowsManager 转化后代码如下: Public Class WindowsManager Friend Const SE_PRIVILEGE_ENABLED As Integer = 2 Friend Const TOKEN_QUERY As Integer = 8 Friend Const TOKEN_ADJUST_PRIVILEGES As Integer = 32 Friend Const SE_SHUTDOWN_NAME As String = "SeShutdownPrivilege" Friend Const EWX_LOGOFF As Integer = 0 Friend Const EWX_SHUTDOWN As Integer = 1 Friend Const EWX_REBOOT As Integer = 2 Friend Const EWX_FORCE As Integer = 4 Friend Const EWX_POWEROFF As Integer = 8 Friend Const EWX_FORCEIFHUNG As Integer = 16 Friend Declare Function GetCurrentProcess Lib "kernel32.dll" () As IntPtr Friend Declare Function OpenProcessToken Lib "advapi32.dll" (ByVal h As IntPtr, ByVal acc As Integer, ByRef phtok As IntPtr) As Boolean Friend Declare Function LookupPrivilegeValue Lib "advapi32.dll" (ByVal host As String, ByVal name As String, ByRef pluid As Long) As Boolean Friend Declare Function AdjustTokenPrivileges Lib "advapi32.dll" (ByVal htok As IntPtr, ByVal disall As Boolean, ByRef newst As TokPriv1Luid, ByVal len As Integer, ByVal prev As IntPtr, ByVal relen As IntPtr) As Boolean Friend Declare Function ExitWindowsEx Lib "user32.dll" (ByVal flg As Integer, ByVal rea As Integer) As Boolean Private Shared Sub DoExitWin(ByVal flg As Integer) Public Shared Sub ShutDown() Public Shared Sub Reboot() <StructLayout(LayoutKind.Sequential, Pack:=1)> _ Public Count As Integer Public Luid As Long Public Attr As Integer
|
联系客服