VB在WIN2K/NT/XP的注销/关机/重起代码

来源:百度知道 编辑:UC知道 时间:2024/05/17 09:27:19
在VB6.0中WIN2K/NT/XP的注销/关机/重起代码是什么???我写的代码是:
Private Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Long, ByVal dwReserved As Long) As Long
Private Const EWX_LOGOFF = 0
Private Const EWX_SHUTDOWN = 1
Private Const EWX_REBOOT = 2
运行后提示:运行是错误‘453’
不能找到入口点ExitWindowsEx在user32

这个问题怎么解决啊?~!!!

呵呵,我给你个办法,你肯定喜欢。根本不用API.
具体代码如下:

Dim oWMI, oSys, oOpSys
Set oWMI = GetObject("winmgmts:{(shutdown)}!\\.\root\cimv2")
Set oOpSys = oWMI.ExecQuery("SELECT * FROM Win32_OperatingSystem")

reboot()'This Script is Written By Lantico.

sub Shutdown()
For Each oSys In oOpSys
WScript.Echo "Reboot..."
oSys.Reboot
Next
End sub

sub reboot()
For Each oSys In oOpSys
WScript.Echo "Shuting down..."
oSys.Shutdown
Next
end sub
Set oOpSys = Nothing
Set oSys = Nothing
Set oWMI = Nothing

代码演示下载:
http://lantico.xinwen365.net/restart.vbs

看看是不是你的api声明错误了
正确的应该是
Private Declare Function ExitWindowsEx Lib "user32" Alias "ExitWindowsEx" (ByVal uFlags A