我想使用 Window API 创建系统还原点 (SRP)。但是,在 24 小时内创建 SRP 是有限的。
这是我的步骤
- 在注册表项 HKLM\Software\Microsoft\Windows NT\CurrentVersion\SystemRestore 下添加 SystemRestorePointCreationFrequency 并设置为零。
在源代码中
- 调用 LoadLibraryW(L"srclient.dll")
- 获取 SRSetRestorePointW 的 GetProcAddress
- 调用 SRSetRestorePointW 方法。
此方法仅在第一次调用时创建 SRP。在第二次调用中,它总是返回前一个 sequenceNumber(STATEMGRSTATUS.llSequenceNumber)。似乎 SRSetRestorePointW 没有引用 SystemRestorePointCreationFrequency。
我尝试使用 powershell 创建 2 个 SRP,效果很好(无需重新启动系统)
Checkpoint-Computer -Description 'Install_TEST' -RestorePointType 'APPLICATION_INSTALL'
此源代码来自 MSD。但它有这个问题。(docs.microsoft.com/en-us/windows/win32/sr/using-system-restore)