恶作剧之吻2结局:VB在WIN2K/NT/XP的注销/关机/重起代码

来源:百度文库 编辑:高校问答 时间:2024/04/29 10:53:44
在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 As Long, ByVal dwReserved As Long) As Long

如果声明没错,那就要看看你是不是在WIN2000以上系统,如果是那就要提升权限:
去看看:

调用API函数ExitWindowsEx可以首先重新驱动和关机。ExitWindowsEx定义如下:
BOOL ExitWindowsEx(
UINT uFlags, // shutdown operation
DWORD dwReserved // reserved
);

去下面站里看看 很详细地

引用user32.dll声明如下:
Private Declare Function ExitWindowsEx Lib "user32.dll" (ByVal uFlags As Long, ByVal dwReserved As Long) As Long

或用shell函数Shell "shutdown.exe /s"

看下下面的网页吧^_^
http://www.china-askpro.com/msg2/qa66.shtml

晕~~~