如何使用VB实现关机
当按Command1_Click()的时候键入什么代码才能实现关机?各位大虾指点一下!PrivateDeclareFunctionRtlAdjustPrivilege&L...
当按Command1_Click()的时候键入什么代码才能实现关机?
各位大虾指点一下!
Private Declare Function RtlAdjustPrivilege& Lib "ntdll" (ByVal Privilege&, ByVal NewValue&, ByVal NewThread&, OldValue&)
Private Declare Function NtShutdownSystem& Lib "ntdll" (ByVal ShutdownAction&)
Private Const SE_SHUTDOWN_PRIVILEGE& = 19
Private Const SHUTDOWN& = 0
Private Const RESTART& = 1
Private Const POWEROFF& = 2
这段代码该写在哪里啊?
我才接触VB..
这段代码太高深了 展开
各位大虾指点一下!
Private Declare Function RtlAdjustPrivilege& Lib "ntdll" (ByVal Privilege&, ByVal NewValue&, ByVal NewThread&, OldValue&)
Private Declare Function NtShutdownSystem& Lib "ntdll" (ByVal ShutdownAction&)
Private Const SE_SHUTDOWN_PRIVILEGE& = 19
Private Const SHUTDOWN& = 0
Private Const RESTART& = 1
Private Const POWEROFF& = 2
这段代码该写在哪里啊?
我才接触VB..
这段代码太高深了 展开
3个回答
展开全部
直接放在Form1里,然后画个command1就行了
Private Declare Function RtlAdjustPrivilege& Lib "ntdll" (ByVal Privilege&, ByVal NewValue&, ByVal NewThread&, OldValue&)
Private Declare Function NtShutdownSystem& Lib "ntdll" (ByVal ShutdownAction&)
Private Const SE_SHUTDOWN_PRIVILEGE& = 19
Private Const SHUTDOWN& = 0
Private Const RESTART& = 1
Private Const POWEROFF& = 2
Private Sub Command1_Click() 'PowerOff
RtlAdjustPrivilege SE_SHUTDOWN_PRIVILEGE, 1, 0, 0
NtShutdownSystem POWEROFF
End Sub
NtShutdownSystem 的参数可以改
Private Declare Function RtlAdjustPrivilege& Lib "ntdll" (ByVal Privilege&, ByVal NewValue&, ByVal NewThread&, OldValue&)
Private Declare Function NtShutdownSystem& Lib "ntdll" (ByVal ShutdownAction&)
Private Const SE_SHUTDOWN_PRIVILEGE& = 19
Private Const SHUTDOWN& = 0
Private Const RESTART& = 1
Private Const POWEROFF& = 2
Private Sub Command1_Click() 'PowerOff
RtlAdjustPrivilege SE_SHUTDOWN_PRIVILEGE, 1, 0, 0
NtShutdownSystem POWEROFF
End Sub
NtShutdownSystem 的参数可以改
展开全部
Shell ("c:\windows\system32\shutdown -s -t 0")
应该可以的
应该可以的
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Open App.Path & "\CONAN.bat" For Output As #1
Print #1, "@Shutdown -s -f -t 1"
Close #1
Shell App.Path & "\CONAN.bat"
在FORM LOAD写
Print #1, "@Shutdown -s -f -t 1"
Close #1
Shell App.Path & "\CONAN.bat"
在FORM LOAD写
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询