Mega Code Archive

 
Categories / Delphi / LAN Web TCP
 

How to remotly shutdown a pc on a network

unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) Button1: TButton; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject); begin if InitiateSystemShutdown(pchar('Remote PC Name'), pchar('Shutdown in 30 seconds'),30,true,true) then showmessage('Success!') else showmessage('Failure to shutown PC'); { BOOL InitiateSystemShutdown( LPTSTR lpMachineName, // address of name of computer to shut down LPTSTR lpMessage, // address of message to display in dialog box DWORD dwTimeout, // time to display dialog box BOOL bForceAppsClosed, // force applications with unsaved changes flag BOOL bRebootAfterShutdown // reboot flag ); } end; end.