jwasrrestoreptapi.pas 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  1. {******************************************************************************}
  2. { }
  3. { Windows System Restore API interface Unit for Object Pascal }
  4. { }
  5. { Portions created by Microsoft are Copyright (C) 1995-2001 Microsoft }
  6. { Corporation. All Rights Reserved. }
  7. { }
  8. { The original file is: srrestoreptapi.h, released Match 2003. The original }
  9. { Pascal code is: SrRestorePtApi.pas, released December 2000. }
  10. { The initial developer of the Pascal code is Marcel van Brakel }
  11. { (brakelm att chello dott nl). }
  12. { }
  13. { Portions created by Marcel van Brakel are Copyright (C) 1999-2001 }
  14. { Marcel van Brakel. All Rights Reserved. }
  15. { }
  16. { Obtained through: Joint Endeavour of Delphi Innovators (Project JEDI) }
  17. { }
  18. { You may retrieve the latest version of this file at the Project JEDI }
  19. { APILIB home page, located at http://jedi-apilib.sourceforge.net }
  20. { }
  21. { The contents of this file are used with permission, subject to the Mozilla }
  22. { Public License Version 1.1 (the "License"); you may not use this file except }
  23. { in compliance with the License. You may obtain a copy of the License at }
  24. { http://www.mozilla.org/MPL/MPL-1.1.html }
  25. { }
  26. { Software distributed under the License is distributed on an "AS IS" basis, }
  27. { WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for }
  28. { the specific language governing rights and limitations under the License. }
  29. { }
  30. { Alternatively, the contents of this file may be used under the terms of the }
  31. { GNU Lesser General Public License (the "LGPL License"), in which case the }
  32. { provisions of the LGPL License are applicable instead of those above. }
  33. { If you wish to allow use of your version of this file only under the terms }
  34. { of the LGPL License and not to allow others to use your version of this file }
  35. { under the MPL, indicate your decision by deleting the provisions above and }
  36. { replace them with the notice and other provisions required by the LGPL }
  37. { License. If you do not delete the provisions above, a recipient may use }
  38. { your version of this file under either the MPL or the LGPL License. }
  39. { }
  40. { For more information about the LGPL: http://www.gnu.org/copyleft/lesser.html }
  41. { }
  42. {******************************************************************************}
  43. // $Id: JwaSrRestorePtApi.pas,v 1.7 2005/09/06 16:36:50 marquardt Exp $
  44. unit JwaSrRestorePtApi;
  45. {$WEAKPACKAGEUNIT}
  46. {$HPPEMIT ''}
  47. {$HPPEMIT '#include "SrRestorePtApi.h"'}
  48. {$HPPEMIT ''}
  49. {$I jediapilib.inc}
  50. interface
  51. uses
  52. JwaWindows;
  53. //
  54. // Type of Event
  55. //
  56. const
  57. MIN_EVENT = 100;
  58. {$EXTERNALSYM MIN_EVENT}
  59. BEGIN_SYSTEM_CHANGE = 100;
  60. {$EXTERNALSYM BEGIN_SYSTEM_CHANGE}
  61. END_SYSTEM_CHANGE = 101;
  62. {$EXTERNALSYM END_SYSTEM_CHANGE}
  63. BEGIN_NESTED_SYSTEM_CHANGE = 102; // for Whistler only - use this to prevent nested restore pts
  64. {$EXTERNALSYM BEGIN_NESTED_SYSTEM_CHANGE}
  65. END_NESTED_SYSTEM_CHANGE = 103; // for Whistler only - use this to prevent nested restore pts
  66. {$EXTERNALSYM END_NESTED_SYSTEM_CHANGE}
  67. MAX_EVENT = 103;
  68. {$EXTERNALSYM MAX_EVENT}
  69. //
  70. // Type of Restore Points
  71. //
  72. MIN_RPT = 0;
  73. {$EXTERNALSYM MIN_RPT}
  74. APPLICATION_INSTALL = 0;
  75. {$EXTERNALSYM APPLICATION_INSTALL}
  76. APPLICATION_UNINSTALL = 1;
  77. {$EXTERNALSYM APPLICATION_UNINSTALL}
  78. DESKTOP_SETTING = 2; // Not implemented
  79. {$EXTERNALSYM DESKTOP_SETTING}
  80. ACCESSIBILITY_SETTING = 3; // Not implemented
  81. {$EXTERNALSYM ACCESSIBILITY_SETTING}
  82. OE_SETTING = 4; // Not implemented
  83. {$EXTERNALSYM OE_SETTING}
  84. APPLICATION_RUN = 5; // Not implemented
  85. {$EXTERNALSYM APPLICATION_RUN}
  86. RESTORE = 6;
  87. {$EXTERNALSYM RESTORE}
  88. CHECKPOINT = 7;
  89. {$EXTERNALSYM CHECKPOINT}
  90. WINDOWS_SHUTDOWN = 8; // Not implemented
  91. {$EXTERNALSYM WINDOWS_SHUTDOWN}
  92. WINDOWS_BOOT = 9; // Not implemented
  93. {$EXTERNALSYM WINDOWS_BOOT}
  94. DEVICE_DRIVER_INSTALL = 10;
  95. {$EXTERNALSYM DEVICE_DRIVER_INSTALL}
  96. FIRSTRUN = 11;
  97. {$EXTERNALSYM FIRSTRUN}
  98. MODIFY_SETTINGS = 12;
  99. {$EXTERNALSYM MODIFY_SETTINGS}
  100. CANCELLED_OPERATION = 13; // Only valid for END_SYSTEM_CHANGE
  101. {$EXTERNALSYM CANCELLED_OPERATION}
  102. BACKUP_RECOVERY = 14;
  103. {$EXTERNALSYM BACKUP_RECOVERY}
  104. MAX_RPT = 14;
  105. {$EXTERNALSYM MAX_RPT}
  106. MAX_DESC = 64;
  107. {$EXTERNALSYM MAX_DESC}
  108. MAX_DESC_W = 256; // longer for Whistler
  109. {$EXTERNALSYM MAX_DESC_W}
  110. //
  111. // for Millennium compatibility
  112. //
  113. //#pragma pack(push, srrestoreptapi_include)
  114. //#pragma pack(1)
  115. //
  116. // Restore point information
  117. //
  118. type
  119. _RESTOREPTINFOA = packed record
  120. dwEventType: DWORD; // Type of Event - Begin or End
  121. dwRestorePtType: DWORD; // Type of Restore Point - App install/uninstall
  122. llSequenceNumber: Int64; // Sequence Number - 0 for begin
  123. szDescription: array [0..MAX_DESC - 1] of Char; // Description - Name of Application / Operation
  124. end;
  125. {$EXTERNALSYM _RESTOREPTINFOA}
  126. RESTOREPOINTINFOA = _RESTOREPTINFOA;
  127. {$EXTERNALSYM RESTOREPOINTINFOA}
  128. PRESTOREPOINTINFOA = ^RESTOREPOINTINFOA;
  129. {$EXTERNALSYM PRESTOREPOINTINFOA}
  130. TRestorePointInfoA = RESTOREPOINTINFOA;
  131. _RESTOREPTINFOW = packed record
  132. dwEventType: DWORD; // Type of Event - Begin or End
  133. dwRestorePtType: DWORD; // Type of Restore Point - App install/uninstall
  134. llSequenceNumber: Int64; // Sequence Number - 0 for begin
  135. szDescription: array [0..MAX_DESC_W - 1] of WideChar; // Description - Name of Application / Operation
  136. end;
  137. {$EXTERNALSYM _RESTOREPTINFOW}
  138. RESTOREPOINTINFOW = _RESTOREPTINFOW;
  139. {$EXTERNALSYM RESTOREPOINTINFOW}
  140. PRESTOREPOINTINFOW = ^RESTOREPOINTINFOW;
  141. {$EXTERNALSYM PRESTOREPOINTINFOW}
  142. TRestorePointInfoW = RESTOREPOINTINFOW;
  143. {$IFDEF UNICODE}
  144. RESTOREPOINTINFO = RESTOREPOINTINFOW;
  145. {$EXTERNALSYM RESTOREPOINTINFO}
  146. PRESTOREPOINTINFO = PRESTOREPOINTINFOW;
  147. {$EXTERNALSYM PRESTOREPOINTINFO}
  148. TRestorePointInfo = TRestorePointInfoW;
  149. {$ELSE}
  150. RESTOREPOINTINFO = RESTOREPOINTINFOA;
  151. {$EXTERNALSYM RESTOREPOINTINFO}
  152. PRESTOREPOINTINFO = PRESTOREPOINTINFOA;
  153. {$EXTERNALSYM PRESTOREPOINTINFO}
  154. TRestorePointInfo = TRestorePointInfoA;
  155. {$ENDIF UNICODE}
  156. //
  157. // Status returned by System Restore
  158. //
  159. _SMGRSTATUS = packed record
  160. nStatus: DWORD; // Status returned by State Manager Process
  161. llSequenceNumber: Int64; // Sequence Number for the restore point
  162. end;
  163. {$EXTERNALSYM _SMGRSTATUS}
  164. STATEMGRSTATUS = _SMGRSTATUS;
  165. {$EXTERNALSYM STATEMGRSTATUS}
  166. PSTATEMGRSTATUS = ^STATEMGRSTATUS;
  167. {$EXTERNALSYM PSTATEMGRSTATUS}
  168. TSMgrStatus = STATEMGRSTATUS;
  169. //#pragma pack(pop, srrestoreptapi_include)
  170. //
  171. // RPC call to set a restore point
  172. //
  173. // Return value TRUE if the call was a success
  174. // FALSE if the call failed
  175. //
  176. // If pSmgrStatus nStatus field is set as follows
  177. //
  178. // ERROR_SUCCESS If the call succeeded (return value will be TRUE)
  179. //
  180. // ERROR_TIMEOUT If the call timed out due to a wait on a mutex for
  181. // for setting restore points.
  182. //
  183. // ERROR_INVALID_DATA If the cancel restore point is called with an invalid
  184. // sequence number
  185. //
  186. // ERROR_INTERNAL_ERROR If there are internal failures.
  187. //
  188. // ERROR_BAD_ENVIRONMENT If the API is called in SafeMode
  189. //
  190. // ERROR_SERVICE_DISABLED If SystemRestore is Disabled.
  191. //
  192. // ERROR_DISK_FULL If System Restore is frozen (Windows Whistler only)
  193. //
  194. // ERROR_ALREADY_EXISTS If this is a nested restore point
  195. function SRSetRestorePointA(pRestorePtSpec: PRESTOREPOINTINFOA; pSMgrStatus: PSTATEMGRSTATUS): BOOL stdcall;
  196. {$EXTERNALSYM SRSetRestorePointA}
  197. function SRSetRestorePointW(pRestorePtSpec: PRESTOREPOINTINFOW; pSMgrStatus: PSTATEMGRSTATUS): BOOL stdcall;
  198. {$EXTERNALSYM SRSetRestorePointW}
  199. function SRRemoveRestorePoint(dwRPNum: DWORD): DWORD; stdcall;
  200. {$EXTERNALSYM SRRemoveRestorePoint}
  201. function SRSetRestorePoint(pRestorePtSpec: PRESTOREPOINTINFO; pSMgrStatus: PSTATEMGRSTATUS): BOOL stdcall;
  202. {$EXTERNALSYM SRSetRestorePoint}
  203. implementation
  204. uses
  205. JwaWinDLLNames;
  206. {$IFDEF DYNAMIC_LINK}
  207. var
  208. _SRSetRestorePointA: Pointer;
  209. function SRSetRestorePointA;
  210. begin
  211. GetProcedureAddress(_SRSetRestorePointA, srclient, 'SRSetRestorePointA');
  212. asm
  213. MOV ESP, EBP
  214. POP EBP
  215. JMP [_SRSetRestorePointA]
  216. end;
  217. end;
  218. var
  219. _SRSetRestorePointW: Pointer;
  220. function SRSetRestorePointW;
  221. begin
  222. GetProcedureAddress(_SRSetRestorePointW, srclient, 'SRSetRestorePointW');
  223. asm
  224. MOV ESP, EBP
  225. POP EBP
  226. JMP [_SRSetRestorePointW]
  227. end;
  228. end;
  229. var
  230. _SRSetRestorePoint: Pointer;
  231. function SRSetRestorePoint;
  232. begin
  233. GetProcedureAddress(_SRSetRestorePoint, srclient, 'SRSetRestorePoint' + AWSuffix);
  234. asm
  235. MOV ESP, EBP
  236. POP EBP
  237. JMP [_SRSetRestorePoint]
  238. end;
  239. end;
  240. var
  241. _SRRemoveRestorePoint: Pointer;
  242. function SRRemoveRestorePoint;
  243. begin
  244. GetProcedureAddress(_SRRemoveRestorePoint, srclient, 'SRRemoveRestorePoint');
  245. asm
  246. MOV ESP, EBP
  247. POP EBP
  248. JMP [_SRRemoveRestorePoint]
  249. end;
  250. end;
  251. {$ELSE}
  252. function SRSetRestorePointA; external srclient name 'SRSetRestorePointA';
  253. function SRSetRestorePointW; external srclient name 'SRSetRestorePointW';
  254. function SRSetRestorePoint; external srclient name 'SRSetRestorePointW' + AWSuffix;
  255. function SRRemoveRestorePoint; external srclient name 'SRRemoveRestorePoint';
  256. {$ENDIF DYNAMIC_LINK}
  257. end.