Код:
unit Unit1;
interface
uses
JclSecurity,JclRegistry, JclSysInfo, Registry,Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;
type
TForm1 = class(TForm)
Button2: TButton;
Memo1: TMemo;
procedure Button2Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button2Click(Sender: TObject);
var
RootKey: HKEY;
PathKEY:String;
begin
RegSetWOW64AccessMode(raNative);
SendMessage(HWND_BROADCAST, WM_WININICHANGE, 0, LongInt(PChar('HKEY_LOCAL_MACHINE\Software\Microsoft\WIMMount')));
RootKey := HKEY_LOCAL_MACHINE;
PathKEY:='Software\Microsoft\WIMMount';
if not RegKeyExists (RootKey,PathKEY) then begin
Memo1.Lines.Add ('Ключ не найден ');
exit
end else begin
Memo1.Lines.Add('[ ОК ] Ключ найден');
if not RegDeleteKeyTree (RootKey,PathKEY)then begin
Memo1.Lines.Add ('Ключ не удалён ');
exit
end else begin
Memo1.Lines.Add('[ ОК ] Ключ удалён');
end;
end;
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
if (CheckWin32Version(6, 0)) then
begin
if IsPrivilegeEnabled('SeBackupPrivilege') then
EnableProcessPrivilege(False, 'SeBackupPrivilege');
if IsPrivilegeEnabled('SeRestorePrivilege') then
EnableProcessPrivilege(False, 'SeRestorePrivilege');
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
if (CheckWin32Version(6, 0)) then
begin
if not IsPrivilegeEnabled('SeBackupPrivilege') then
EnableProcessPrivilege(True, 'SeBackupPrivilege');
if not IsPrivilegeEnabled('SeRestorePrivilege') then
EnableProcessPrivilege(True, 'SeRestorePrivilege');
end;
end;
end.