重启Windows2000/NT系统
2018-06-17 17:14:20来源:未知 阅读 ()
'APICallsusedforRebootPC
PrivateConstTOKEN_ADJUST_PRIVILEGES=&H20
PrivateConstTOKEN_QUERY=&H8
PrivateConstSE_PRIVILEGE_ENABLED=&H2
PrivateConstEWX_SHUTDOWNAsLong=1
PrivateConstEWX_FORCEAsLong=4
PrivateConstEWX_REBOOT=2
PrivateTypeLUID
UsedPartAsLong
IgnoredForNowHigh32BitPartAsLong
EndType
PrivateTypeTOKEN_PRIVILEGES
PrivilegeCountAsLong
TheLuidAsLUID
AttributesAsLong
EndType
PrivateDeclareFunctionExitWindowsExLib"user32"(ByValdwOptionsAsLong,ByValdwReservedAsLong)AsLong
PrivateDeclareFunctionGetCurrentProcessLib"kernel32"()AsLong
PrivateDeclareFunctionOpenProcessTokenLib"advapi32"(ByValProcessHandleAsLong,ByValDesiredAccessAsLong,TokenHandleAsLong)AsLong
PrivateDeclareFunctionLookupPrivilegeValueLib"advapi32"Alias"LookupPrivilegeValueA"(ByVallpSystemNameAsString,ByVallpNameAsString,lpLuidAsLUID)AsLong
PrivateDeclareFunctionAdjustTokenPrivilegesLib"advapi32"(ByValTokenHandleAsLong,ByValDisableAllPrivilegesAsLong,NewStateAsTOKEN_PRIVILEGES,ByValBufferLengthAsLong,PreviousStateAsTOKEN_PRIVILEGES,ReturnLengthAsLong)AsLong
SubRebootPC()
OnLocalErrorGoToRebootPC_ErrorHandler
ConstcsProcName="RebootPC"
DimhProcessHandleAsLong
DimhTokenHandleAsLong
DimtmpLuidAsLUID
DimtkpNewAsTOKEN_PRIVILEGES
DimtkpPreviousAsTOKEN_PRIVILEGES
DimlBufferNeededAsLong
hProcessHandle=GetCurrentProcess()
CallOpenProcessToken(hProcessHandle,TOKEN_ADJUST_PRIVILEGESOrTOKEN_QUERY,hTokenHandle)
'GettheLUIDfortheshutdownprivilege
CallLookupPrivilegeValue("","SeShutdownPrivilege",tmpLuid)
tkpNew.PrivilegeCount=1'Oneprivilegetoset
tkpNew.TheLuid=tmpLuid
tkpNew.Attributes=SE_PRIVILEGE_ENABLED
'Enabletheshutdownprivilegeintheaccesstokenofthisprocess.
lBufferNeeded=0
CallAdjustTokenPrivileges(hTokenHandle,False,tkpNew,Len(tkpPrevious),tkpPrevious,lBufferNeeded)
'ForceaReboot(nooptiontosavefilestocancelout)
CallExitWindowsEx(EWX_FORCEOrEWX_REBOOT,&HFFFF)
ExitSub
RebootPC_ErrorHandler:
CallRaiseError(csModName,csProcName,Err.Number,Err.Description)
EndSub->
标签:
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有
上一篇:简单介绍透明位图的实现方法
下一篇:VB多媒体程序设计
- 在VB中如何创建闪烁(标语)屏 2018-06-17
- Shell语句用法心得 2018-06-17
- 用VB实现“木马”式隐形运行程序 2018-06-17
- 教你认识VB的座标系统 2018-06-17
- 如何满屏播放AVI文件 2018-06-17
IDC资讯: 主机资讯 注册资讯 托管资讯 vps资讯 网站建设
网站运营: 建站经验 策划盈利 搜索优化 网站推广 免费资源
网络编程: Asp.Net编程 Asp编程 Php编程 Xml编程 Access Mssql Mysql 其它
服务器技术: Web服务器 Ftp服务器 Mail服务器 Dns服务器 安全防护
软件技巧: 其它软件 Word Excel Powerpoint Ghost Vista QQ空间 QQ FlashGet 迅雷
网页制作: FrontPages Dreamweaver Javascript css photoshop fireworks Flash