请问Windows重启、关机的API函数是什么?怎么调用?

fst 2001-12-08 12:52:27
请问Windows重启、关机的API函数是什么?怎么调用?在此多谢各位!
...全文
393 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
pctommy 2001-12-08
  • 打赏
  • 举报
回复
如果有谁知道怎么操纵ATX电源的汇编……我给他1000分!
tiaozi2000 2001-12-08
  • 打赏
  • 举报
回复
哈哈~~ 但是要关闭WIN2000的话你必须给出关机权限令牌!
lightning_68 2001-12-08
  • 打赏
  • 举报
回复
16位Windows用ExitWindows() API函数,而32位Windows则用ExitWindowsEx().32位版本比16位版本多了更多的控制及选项,包括注销及关机。

Declare Function ExitWindows Lib "user" (ByVal uFlags As Long, ByVal _
dwReserved As integer) As integer
Const EW_REBOOTSYSTEM = &H43
Const EW_RESTARTWINDOWS = &H42

Sub Command1_Click()

Dim iAns As Integer
Dim rVal As Integer
Dim iButtonType as Integer

iButtonType = 4 + 32 ' vbYesNo + vbQuestion

' Ask if the user is sure they want to exit.
iAns = MsgBox("Are you sure you want to exit windows?", iButtonType, _
"Exit Windows")
If iAns = 6 Then ' Yes pressed
' Call the exit function to Reboot.
rVal = ExitWindows(EW_REBOOTSYSTEM, 0)
End If

End Sub

***** 32位的例子 *****
In a project with 1 commandbutton, place the following code:
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
Private Const EWX_FORCE = 4

Private Sub Command1_Click()

Dim iAns As Integer
Dim rVal As Long

' Ask if the user is sure they want to exit.
iAns = MsgBox("Are you sure you want to exit windows?", vbQuestion Or _
vbYesNo, "Exit Windows")
If iAns = vbYes Then
rVal = ExitWindowsEx(EWX_SHUTDOWN, 0&)
End If

End Sub


查看ExitWindowsEx的详细用法

Jneu 2001-12-08
  • 打赏
  • 举报
回复
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 '重新引导系统
Private Const EWX_FORCE = 4 '强迫中止没有响应的进程

Public Sub ExitWindow9x()
Call ExitWindowsEx(EWX_FORCE Or EWX_SHUTDOWN, 0)
End Sub

1,486

社区成员

发帖
与我相关
我的任务
社区描述
VB API
社区管理员
  • API
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧