论坛: 编程破解 标题: 用vb做关机程序 复制本贴地址    
作者: dewarfing [dewarfing]    论坛用户   登录
是不是用SHELL “RUNDLL。EXE USER。EXE,EXITWINNDOWS”就可以了,我总觉得少了点,例如:执行关机后,该程序还未结束,该怎么改进一下哪?应该怎么写???
                              请教

地主 发表时间: 06-04-25 17:54

回复: jhkdiy [jhkdiy]   版主   登录
重启Windows 2000/NT系统

Reboots a Windows 2000 PC. Many examples shell to the kernel and just kill the PC. This does it properly and takes into account a user privilages.

'API Calls used for RebootPC

Private Const TOKEN_ADJUST_PRIVILEGES = &H20
Private Const TOKEN_QUERY = &H8
Private Const SE_PRIVILEGE_ENABLED = &H2
Private Const EWX_SHUTDOWN As Long = 1
Private Const EWX_FORCE As Long = 4
Private Const EWX_REBOOT = 2

Private Type LUID
 UsedPart As Long
 IgnoredForNowHigh32BitPart As Long
End Type

Private Type TOKEN_PRIVILEGES
 PrivilegeCount As Long
 TheLuid As LUID
 Attributes As Long
End Type

Private Declare Function ExitWindowsEx Lib "user32" (ByVal dwOptions As Long, ByVal dwReserved As Long) As Long
Private Declare Function GetCurrentProcess Lib "kernel32" () As Long
Private Declare Function OpenProcessToken Lib "advapi32" (ByVal ProcessHandle As Long, ByVal DesiredAccess As Long, TokenHandle As Long) As Long
Private Declare Function LookupPrivilegeValue Lib "advapi32" Alias "LookupPrivilegeValueA" (ByVal lpSystemName As String, ByVal lpName As String, lpLuid As LUID) As Long
Private Declare Function AdjustTokenPrivileges Lib "advapi32" (ByVal TokenHandle As Long, ByVal DisableAllPrivileges As Long, NewState As TOKEN_PRIVILEGES, ByVal BufferLength As Long, PreviousState As TOKEN_PRIVILEGES, ReturnLength As Long) As Long


Sub RebootPC()
 On Local Error GoTo RebootPC_ErrorHandler
 Const csProcName = "RebootPC"
 
 Dim hProcessHandle As Long
 Dim hTokenHandle As Long
 Dim tmpLuid As LUID
 Dim tkpNew As TOKEN_PRIVILEGES
 Dim tkpPrevious As TOKEN_PRIVILEGES
 Dim lBufferNeeded As Long

 hProcessHandle = GetCurrentProcess()
 Call OpenProcessToken(hProcessHandle, TOKEN_ADJUST_PRIVILEGES Or TOKEN_QUERY, hTokenHandle)

' Get the LUID for the shutdown privilege
 Call LookupPrivilegeValue("", "SeShutdownPrivilege", tmpLuid)

 tkpNew.PrivilegeCount = 1 ' One privilege to set
 tkpNew.TheLuid = tmpLuid
 tkpNew.Attributes = SE_PRIVILEGE_ENABLED

' Enable the shutdown privilege in the access token of this process.
 lBufferNeeded = 0
 Call AdjustTokenPrivileges(hTokenHandle, False, tkpNew, Len(tkpPrevious), tkpPrevious, lBufferNeeded)

' Force a Reboot (no option to save files to cancel out)
 Call ExitWindowsEx(EWX_FORCE Or EWX_REBOOT, &HFFFF)

 Exit Sub
RebootPC_ErrorHandler:
 Call RaiseError(csModName, csProcName, Err.Number, Err.Description)
End Sub


B1层 发表时间: 06-04-26 12:30

回复: 286 [unique]   版主   登录
强制关机可解决一切问题。

B2层 发表时间: 06-04-27 17:42

回复: dewarfing [dewarfing]   论坛用户   登录
谢了!!!!!

B3层 发表时间: 06-05-07 12:56

回复: 漂伯依旧 [sutiandy]   论坛用户   登录
不行哒``我顶`

B4层 发表时间: 07-05-29 08:26

回复: 肥牛肉 [bobotv]   论坛用户   登录
修改注册表:HKEY-CURRENT-USER\Control Panel\Desktop\AutoEndTasks:数值改1

B5层 发表时间: 07-05-31 05:47

回复: TGV_Mic [tgv]      登录
直接向cmd传shutdown可以不?

如果用VB.NET大把的MMC可以让你调用

B6层 发表时间: 07-06-21 19:35

回复: 老鹰 [hack00]   论坛用户   登录
大家有兴趣的可一来★ 黑客☆攻防★ 研究共同进步, 群号是 :42365758

B7层 发表时间: 07-07-17 17:32

论坛: 编程破解

20CN网络安全小组版权所有
Copyright © 2000-2010 20CN Security Group. All Rights Reserved.
论坛程序编写:NetDemon

粤ICP备05087286号