重新启动windows 2000/nt系统
rebootindows 2000 pbsp;many examples shellthe kernel and just kill the pbsp;this doesproperly and takes into aser privilages.
'api calls used for rebootpc
private st token_adjust_privileges = &h20
private st token_query = &h8
private st se_privilege_enabled = &h2
private st ewx_shutdownlong = 1
private st ewx_forg = 4
private st ewx_reboot = 2
private type luid
usedpartlong
ignoredfornowhigh32bitpartlong
end type
private type token_privileges
privilegetlong
theluidluid
attributeslong
end type
private declare fun exitwindowsex lib "user32" (byval dwoptionslong, byval dwreservedlong)long
private declare fun getcurrentprocess lib "kernel32" long
private declare fun openprocesstoken lib "advapi32" (byval processhandlelong, byval desiredaccesslong, tokenhandlelong)long
private declare fun lookupprivilegevalue lib "advapi32" alias "lookupprivilegevaluea" (byval lpsystemring, byval lpring, lpluidluid)long
private declare fun adjusttokenprivileges lib "advapi32" (byval tokenhandlelong, byval disableallprivilegeslong, atetoken_privileges, byval bufferlengthlong, previousstatetoken_privileges, returhlong)long
sub rebootpc
lobsp;error goto rebootpc_errorhandler
st e = "rebootpc"
dim hprocesshandlelong
dim htokenhandlelong
dim tmpluidluid
dim tkpoken_privileges
dim tkpprevioustoken_privileges
dim lbufferneededlong
hprocesshandle = getcurrentprocess
call openprocesstoken(hprocesshandle, token_adjust_privilegestoken_query, htokenhandle)
' get the luid for the shutdown privilege
call lookupprivilegevalue("", "seshutdownprivilege", tmpluid)
= 1 ' one privilegese = tmplui = se_privilege_enabled
' enable the shutdown privilegethe access tokenthi = 0
call adjusttokenprivileges(htokenhandle, false, tkpnew, len(tkpprevious), tkpprevious, lbufferneeded)
' forceboot (no options**e filesbsp;out)
call exitwindowsex(ewx_forceewx_reboot, &hffff)
exit sub
rebootpc_errorhandler:
call raiseerror(e, e, err.number, err.description)
end sub</p>