讓win2000重啟是怎么寫的?(100分)

  • 主题发起人 主题发起人 W1979
  • 开始时间 开始时间
W

W1979

Unregistered / Unconfirmed
GUEST, unregistred user!
我要先為我的程序授權﹐正在用到LookupPrivilegeValue這個函數<br>我手上沒有MSDN,我只記的關機是SeShutDownPrivilege,忘了重啟動是什么了<br>我試了SeRebootPrivilege不對。。。讓各位見笑了
 
也是SeShutDownPrivilege<br><br>EWX_REBOOT Shuts down the system and then restarts the system. <br>Windows NT/2000: The calling process must have the SE_SHUTDOWN_NAME <br>privilege. For more information, see the following Remarks section. <br><br>MSDN上的
 
我試了一下﹐重啟后桌面都變成白色的了﹐怎么會這個樣子?
 
不会吧?什么叫重启后桌面变成白色的?那还是没能重启啊.
 
把代码贴出来看看
 
ExitWindowsEx你可以查一下这个函数的参数就可以了
 
依照論壇上一位前輩的代碼<br>procedure TForm1.Button2Click(Sender: TObject);<br>const<br>&nbsp; SE_SHUTDOWN_NAME = 'SeShutdownPrivilege';<br>var<br>&nbsp; hToken : THandle;<br>&nbsp; tkp : TTokenPrivileges;<br>&nbsp; tkpo : TTokenPrivileges;<br>&nbsp; zero : DWORD;<br>begin<br>&nbsp; zero:=0;<br>&nbsp; if not OpenProcessToken(GetCurrentProcess(),TOKEN_ADJUST_PRIVILEGES or TOKEN_QUERY, hToken) then begin<br>&nbsp; &nbsp; MessageBox( 0, 'Exit Error', 'OpenProcessToken() Failed', MB_OK );<br>&nbsp; &nbsp; Exit;<br>&nbsp; end;<br>&nbsp; if not OpenProcessToken( GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES or TOKEN_QUERY, hToken) then begin<br>&nbsp; &nbsp; MessageBox( 0, 'Exit Error', 'OpenProcessToken() Failed', MB_OK );<br>&nbsp; &nbsp; Exit;<br>&nbsp; end;<br><br>&nbsp; if not LookupPrivilegeValue( nil, 'SeShutdownPrivilege' , tkp.Privileges[ 0 ].Luid ) then begin<br>&nbsp; &nbsp; &nbsp; MessageBox( 0, 'Exit Error', 'LookupPrivilegeValue() Failed', MB_OK );<br>&nbsp; &nbsp; &nbsp; Exit;<br>&nbsp; end;<br>&nbsp; tkp.PrivilegeCount := 1;<br>&nbsp; tkp.Privileges[ 0 ].Attributes := SE_PRIVILEGE_ENABLED;<br>&nbsp; AdjustTokenPrivileges( hToken, False, tkp, SizeOf( TTokenPrivileges ), tkpo, zero );<br>&nbsp; if Boolean( GetLastError() ) then begin<br>&nbsp; &nbsp; &nbsp; MessageBox( 0, 'Exit Error', 'AdjustTokenPrivileges() Failed', MB_OK );<br>&nbsp; &nbsp; &nbsp; Exit;<br>&nbsp; end<br>&nbsp; else ExitWindowsEx( EWX_REBOOT or EWX_FORCE, 0 );<br>&nbsp; <br>end;
 
另外Kindly﹐你告訴我的那個netsh我還有點問題﹐請到我的另一問題
 
可以的啊,害我重启了一遍~
 
多人接受答案了。
 
后退
顶部