菜 菜鸟黄 Unregistered / Unconfirmed GUEST, unregistred user! 2008-12-17 #2 //获取计算机的关闭、注销、重启的权限<br>procedure TForm1.FormCreate(Sender: TObject);<br>var<br> hToken : THandle;<br> Tkp : TTokenPrivileges;<br> ZeroWORD;<br>begin<br> OpenProcessToken(GetCurrentProcess(),TOKEN_ADJUST_PRIVILEGES or<br> TOKEN_QUERY,hToken);<br> LookupPrivilegeValue(nil,'SeShutdownPrivilege',tkp.Privileges[0].Luid);<br> Tkp.PrivilegeCount :=1;<br> Tkp.Privileges[0].Attributes := SE_PRIVILEGE_ENABLED;<br> AdjustTokenPrivileges(hToken,False,Tkp,SizeOf(TTokenPrivileges),nil,Zero); <br>end;<br><br>procedure TForm1.Timer1Timer(Sender: TObject);<br>var<br> WSAData: TWSAData;<br> MSocket: TSocket;<br> SockAddrIn: TSockAddrIn;<br> RetVal, OptVal, i: Integer;<br> MacAddr: array[0..5] of Byte;<br> MagicData: array[0..101] of Byte;<br> Position: Longint;<br> SAddr:string;<br>begin<br> if Edit1.Text =panel1.Caption then<br> begin<br> Timer1.Enabled :=False;<br> if Combobox1.Text ='注销' then<br> begin<br> ExitWindowsEx(EWX_LOGOFF,0);<br> end;<br> if Combobox1.Text ='重新启动' then<br> begin<br> ExitWindowsEx(EWX_REBOOT,0);<br> end;<br> if Combobox1.Text ='关闭计算机' then<br> begin<br> ExitWindowsEx(EWX_SHUTDOWN or EWX_POWEROFF,0);<br> end;<br> end;<br>end;
//获取计算机的关闭、注销、重启的权限<br>procedure TForm1.FormCreate(Sender: TObject);<br>var<br> hToken : THandle;<br> Tkp : TTokenPrivileges;<br> ZeroWORD;<br>begin<br> OpenProcessToken(GetCurrentProcess(),TOKEN_ADJUST_PRIVILEGES or<br> TOKEN_QUERY,hToken);<br> LookupPrivilegeValue(nil,'SeShutdownPrivilege',tkp.Privileges[0].Luid);<br> Tkp.PrivilegeCount :=1;<br> Tkp.Privileges[0].Attributes := SE_PRIVILEGE_ENABLED;<br> AdjustTokenPrivileges(hToken,False,Tkp,SizeOf(TTokenPrivileges),nil,Zero); <br>end;<br><br>procedure TForm1.Timer1Timer(Sender: TObject);<br>var<br> WSAData: TWSAData;<br> MSocket: TSocket;<br> SockAddrIn: TSockAddrIn;<br> RetVal, OptVal, i: Integer;<br> MacAddr: array[0..5] of Byte;<br> MagicData: array[0..101] of Byte;<br> Position: Longint;<br> SAddr:string;<br>begin<br> if Edit1.Text =panel1.Caption then<br> begin<br> Timer1.Enabled :=False;<br> if Combobox1.Text ='注销' then<br> begin<br> ExitWindowsEx(EWX_LOGOFF,0);<br> end;<br> if Combobox1.Text ='重新启动' then<br> begin<br> ExitWindowsEx(EWX_REBOOT,0);<br> end;<br> if Combobox1.Text ='关闭计算机' then<br> begin<br> ExitWindowsEx(EWX_SHUTDOWN or EWX_POWEROFF,0);<br> end;<br> end;<br>end;