;Autor: shadow EnableExplicit #RPC_C_AUTHN_LEVEL_DEFAULT = 0 #RPC_C_IMP_LEVEL_IMPERSONATE = 3 #EOAC_NONE = 0 Structure RESTOREPOINTINFO dwEventType.i dwRestorePtType.i llSequenceNumber.q szDescription.s{#MAX_COLUMN_DESC_LEN} EndStructure Structure STATEMGRSTATUS nStatus.l llSequenceNumber.q EndStructure Procedure.b Failed(hr.l) ProcedureReturn hr <> #S_OK EndProcedure Procedure.s PBSetRestorePoint() Protected RestorePtInfo.RESTOREPOINTINFO Protected SMgrStatus.STATEMGRSTATUS Protected dwErr.l = #ERROR_SUCCESS Protected hSrClient.l = #Null Protected hr.i = #S_OK Protected fRet.b = #False Protected *pFunc.l = #Null hr = CoInitializeEx_(#Null, #COINIT_MULTITHREADED ) If Failed(hr) ProcedureReturn "Unexpected error: CoInitializeEx() failed with " + Str(hr) + "." EndIf hr = CoInitializeSecurity_(#Null, -1, #Null, #Null, #RPC_C_AUTHN_LEVEL_DEFAULT, #RPC_C_IMP_LEVEL_IMPERSONATE, #Null, #EOAC_NONE, #Null); If Failed(hr) ProcedureReturn "Unexpected error: failed to initialize COM security. (" + Str(hr) + ")" EndIf RestorePtInfo\dwEventType = #BEGIN_SYSTEM_CHANGE; RestorePtInfo\dwRestorePtType = #APPLICATION_INSTALL; RestorePtInfo\llSequenceNumber = 0 RestorePtInfo\szDescription = "PB Test Restore Point" hSrClient = LoadLibrary_("SrClient.dll") If hSrClient = #Null ProcedureReturn "System Restore is not present." EndIf *pFunc = GetProcAddress_(hSrClient, "SRSetRestorePointA") If *pFunc = #Null ProcedureReturn "Failed to find SRSetRestorePointW. " + Str(GetLastError_()) EndIf fRet = CallFunctionFast(*pFunc, @RestorePtInfo, @SMgrStatus) If Not fRet dwErr = SMgrStatus\nStatus If dwErr = #ERROR_SERVICE_DISABLED ProcedureReturn "System Restore is turned off. (Error code: " + Str(dwErr) + ")" EndIf EndIf MessageRequester("","Wird erstellt.",0) RestorePtInfo\dwEventType = #END_SYSTEM_CHANGE; RestorePtInfo\llSequenceNumber = SMgrStatus\llSequenceNumber; fRet = CallFunctionFast(*pFunc, @RestorePtInfo, @SMgrStatus) If Not fRet dwErr = SMgrStatus\nStatus ProcedureReturn "Failure to end the restore point; error=" + Str(dwErr) EndIf If hSrClient <> #Null FreeLibrary_(hSrClient) EndIf CoUninitialize_() ProcedureReturn "Wurde erstellt." EndProcedure MessageRequester("",PBSetRestorePoint(),0)