2000里用参数8,就可以了
If Con2w = False Then
AdjustTokenPrivilegesForNT
Call ExitWindowsEx(1, 0) 'Win98中关闭计算机
Else
AdjustTokenPrivilegesForNT
Call ExitWindowsEx(8, 0) 'Win2000中关闭计算机
End If
2000里用参数8,就可以了
If Con2w = False Then
AdjustTokenPrivilegesForNT
Call ExitWindowsEx(1, 0) 'Win98中关闭计算机
Else
AdjustTokenPrivilegesForNT
Call ExitWindowsEx(8, 0) 'Win2000中关闭计算机
End If
to progame:我说的意思是用win2000里的关机功能可以关闭电源,用ExitWindowsEx()为什么不行? 用ExitWindowsEx可实现提示“可以正常关机”,但不能关闭电源!
简单说用vb如何实现在关闭计算机的时候关闭电源(win2000)?
如果你行的话,就写出代码来,否则别吹牛!
Windows NT: To shut down or restart the system, the calling process must use the AdjustTokenPrivileges function to enable the SE_SHUTDOWN_NAME privilege. For more information about security privileges, see Privileges.
通过程序实现Windows用户的注销、关机、重启机器。
组成:一个Module、一个Form和三个CommandButtom
实现:
'Module1.bas
'ExitWindowsEx的功能是注销、关机或重启。参数一:指定功能类型,参数二:调用时忽略。
Public Const EWX_LOGOFF = 0 '注销
Public Const EWX_SHUTDOWN = 1 '关机
Public Const EWX_REBOOT = 2 '重启
Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Long, ByVal _
dwReserved As Long) As Long
'以上语句都可从API浏览器中找到
Private Sub Command1_Click()
ExitWindowsEx EWX_LOGOFF, O '注销
End Sub
Private Sub Command2_Click()
ExitWindowsEx EWX_SHUTDOWN, 0 '关机
End Sub
Private Sub Command3_Click()
ExitWindowsEx EWX_REBOOT, 0 '重启
End Sub