谁知道怎样用VB编程序关机?

来源:百度知道 编辑:UC知道 时间:2024/05/10 17:56:10
shell "shutdown -s -t"的方法不是很好,有没有什么正常一点的?谢谢……

'晕!我刚刚才做了一个,把代码给你。(怎么这么巧啊?)

'你需要画一个timer,名字叫timer1,然后把代码复制就可以了。

Option Explicit

Private Const EWX_LogOff As Long = 0
Private Const EWX_SHUTDOWN As Long = 1
Private Const EWX_REBOOT As Long = 2
Private Const EWX_FORCE As Long = 4
Private Const EWX_POWEROFF As Long = 8

'The ExitWindowsEx function either logs off, shuts down, or shuts
'down and restarts the system.
Private Declare Function ExitWindowsEx Lib "user32" (ByVal dwOptions As Long, ByVal dwReserved As Long) As Long

'The GetLastError function returns the calling thread's last-error
'code value. The last-error code is maintained on a per-thread basis.
'Multiple threads do not overwrite each other's last-error code.
Private Declare Function GetLastError Lib "kernel32" () As Long

Private Type LUID
UsedPart As Long
IgnoredForNowHigh32BitPart As Long