home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 April / Chip_2002-04_cd1.bin / zkuste / delphi / kolekce / d56 / NT.ZIP / NTShutdown.pas < prev    next >
Pascal/Delphi Source File  |  1999-06-17  |  2KB  |  61 lines

  1. unit NTShutdown;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;
  7.  
  8. type
  9.   TNTShutdown = class(TComponent)
  10.   private
  11.     { Private declarations }
  12.     FMachineName:String;
  13.     FMessage:String;
  14.     FTimeOut:DWORD;
  15.     FForceApps:Boolean;
  16.     FReboot:Boolean;
  17.   protected
  18.     { Protected declarations }
  19.   public
  20.     { Public declarations }
  21.   published
  22.     { Published declarations }
  23.     property MachineName:String read FMachineName write FMachineName;
  24.     property MessageText:String read FMessage write FMessage;
  25.     property TimeOut:DWORD read FTimeOut write FTimeOut;
  26.     property ForceApps:Boolean read FForceApps write FForceApps default False;
  27.     property Reboot:Boolean read FReboot write FReboot default False;
  28.     function Execute:Boolean;
  29.   end;
  30.  
  31. procedure Register;
  32.  
  33. implementation
  34.  
  35. function TNTShutdown.Execute:Boolean;
  36. begin
  37.      If FMachineName='' Then
  38.      Begin
  39.           If InitiateSystemShutdown(nil,PChar(FMessage),FTimeOut,FForceApps,FReboot)=False Then
  40.           Begin
  41.                Result:=False;
  42.                Exit;
  43.           End;
  44.      End Else
  45.      Begin
  46.           If InitiateSystemShutdown(PChar(FMachineName),PChar(FMessage),FTimeOut,FForceApps,FReboot)=False Then
  47.           Begin
  48.                Result:=False;
  49.                Exit;
  50.           End;
  51.      End;
  52.      Result:=True;
  53. end;
  54.  
  55. procedure Register;
  56. begin
  57.   RegisterComponents('NT Tools - Additional', [TNTShutdown]);
  58. end;
  59.  
  60. end.
  61.