Kombinuję z wylistowaniem wszystkich nazw punktów przywracania systemu.
Mam już kasowanie i tworzenie punktów, brakuje mi tylko odczytać listę tych punktów.
Tworzenie punktu:
const
BEGIN_SYSTEM_CHANGE = 100;
END_SYSTEM_CHANGE = 101;
APPLICATION_INSTALL = 0;
CANCELLED_OPERATION = 13;
MAX_DESC = 64;
MIN_EVENT = 100;
type
PRESTOREPTINFOA = ^_RESTOREPTINFOA;
_RESTOREPTINFOA = packed record
dwEventType: DWORD; // Type of Event - Begin or End
dwRestorePtType: DWORD; // Type of Restore Point - App install/uninstall
llSequenceNumber: INT64; // Sequence Number - 0 for begin
szDescription: array [0..MAX_DESC] of CHAR; // Description - Name of Application / Operation
end;
RESTOREPOINTINFO = _RESTOREPTINFOA;
PRESTOREPOINTINFOA = ^_RESTOREPTINFOA;
PSMGRSTATUS = ^_SMGRSTATUS;
_SMGRSTATUS = packed record
nStatus: DWORD; // Status returned by State Manager Process
llSequenceNumber: INT64; // Sequence Number for the restore point
end;
STATEMGRSTATUS = _SMGRSTATUS;
PSTATEMGRSTATUS = ^_SMGRSTATUS;
function SRSetRestorePointA(pRestorePtSpec: PRESTOREPOINTINFOA; pSMgrStatus: PSTATEMGRSTATUS): Bool;
stdcall; external 'SrClient.dll' Name 'SRSetRestorePointA';
//wywołanie
const
CR = #13#10;
var
RestorePtSpec: RESTOREPOINTINFO;
SMgrStatus: STATEMGRSTATUS;
begin
RestorePtSpec.dwEventType := BEGIN_SYSTEM_CHANGE;
RestorePtSpec.dwRestorePtType := APPLICATION_INSTALL;
RestorePtSpec.llSequenceNumber := 0;
RestorePtSpec.szDescription := 'SAMPLE RESTORE POINT'; // nazwa punktu
if (SRSetRestorePointA(@RestorePtSpec, @SMgrStatus)) then
ShowMessage('Restore point set. Restore point data:' + CR+
'Sequence Number: ' + Format('%d', [SMgrStatus.llSequenceNumber]) + CR+
'Status: ' + Format('%u', [SMgrStatus.nStatus]))
else ShowMessage('Couldn''t set restore point.');
end;
Kasowanie punktu:
const
BEGIN_SYSTEM_CHANGE = 100;
END_SYSTEM_CHANGE = 101;
APPLICATION_INSTALL = 0;
CANCELLED_OPERATION = 13;
MAX_DESC = 64;
MIN_EVENT = 100;
type
PRESTOREPTINFOA = ^_RESTOREPTINFOA;
_RESTOREPTINFOA = packed record
dwEventType: DWORD; // Type of Event - Begin or End
dwRestorePtType: DWORD; // Type of Restore Point - App install/uninstall
llSequenceNumber: INT64; // Sequence Number - 0 for begin
szDescription: array [0..MAX_DESC] of CHAR; // Description - Name of Application / Operation
end;
RESTOREPOINTINFO = _RESTOREPTINFOA;
PRESTOREPOINTINFOA = ^_RESTOREPTINFOA;
PSMGRSTATUS = ^_SMGRSTATUS;
_SMGRSTATUS = packed record
nStatus: DWORD; // Status returned by State Manager Process
llSequenceNumber: INT64; // Sequence Number for the restore point
end;
STATEMGRSTATUS = _SMGRSTATUS;
PSTATEMGRSTATUS = ^_SMGRSTATUS;
function SRSetRestorePointA(pRestorePtSpec: PRESTOREPOINTINFOA; pSMgrStatus: PSTATEMGRSTATUS): Bool;
stdcall; external 'SrClient.dll' Name 'SRSetRestorePointA';
// wywołanie
const
CR = #13#10;
var
RestorePtSpec: RESTOREPOINTINFO;
SMgrStatus: STATEMGRSTATUS;
begin
RestorePtSpec.dwEventType := END_SYSTEM_CHANGE;
RestorePtSpec.dwRestorePtType := CANCELLED_OPERATION;
RestorePtSpec.llSequenceNumber := 6; // tutaj trzeba podać nr punktu do skasowania
if (SRSetRestorePointA(@RestorePtSpec, @SMgrStatus)) then
ShowMessage('Restore point canceled. Restore point data:' + CR+
'Sequence Number: ' + Format('%d', [SMgrStatus.llSequenceNumber]) + CR+
'Status: ' + Format('%u', [SMgrStatus.nStatus]))
else ShowMessage('Couldn''t cancel restore point.');
end;