Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

513 lines
22 KiB

  1. #ifndef __CLEANOC_API__
  2. #define __CLEANOC_API__
  3. // Flags used in GetControlInfo()
  4. #define GCI_NAME 1
  5. #define GCI_FILE 2
  6. #define GCI_CLSID 3
  7. #define GCI_TYPELIBID 4
  8. #define GCI_TOTALSIZE 5
  9. #define GCI_SIZESAVED 6
  10. #define GCI_TOTALFILES 7
  11. #define GCI_CODEBASE 8
  12. #define GCI_ISDISTUNIT 9
  13. #define GCI_DIST_UNIT_VERSION 10
  14. #define GCI_STATUS 11
  15. #define GCI_HAS_ACTIVEX 12
  16. #define GCI_HAS_JAVA 13
  17. // control status flags
  18. #define STATUS_CTRL_UNKNOWN 0 // Errors prevent determining the actual control state
  19. #define STATUS_CTRL_INSTALLED 1 // Control is properly installed and ready for use
  20. #define STATUS_CTRL_SHARED 2 // One or more components are shared by more than one control
  21. #define STATUS_CTRL_DAMAGED 3 // The control file or some part of the installation is damaged or missing
  22. #define STATUS_CTRL_UNPLUGGED 4 // The control has been re-registered in another location, the cache's
  23. // instance of the control is no longer being used.
  24. // RemoveExpiredControls flags
  25. #define REC_SILENT 1 // If set, controls whose deletion would require confirmation are not removed.
  26. ///////////////////////////////////////////////////////////////////////////////
  27. // FindFirstControl
  28. //
  29. // Purpose:
  30. // Initiate a search on the registry for an installed ActiveX control.
  31. //
  32. // Return Value:
  33. // - ERROR_SUCCESS if a control is found and search has been successfully
  34. // initiated.
  35. // - ERROR_NO_MORE_ITEMS if no control is found.
  36. // - If an error has occurred, the return value is a error code defined in
  37. // winerror.h
  38. //
  39. // Parameters:
  40. // hFindHandle -- a handle needed for resuming the search. Caller must
  41. // pass this handle to FindNextControl to retrieve the
  42. // the next installed ActiveX control.
  43. // hControlHandle -- handle to a control's data. Caller must pass this
  44. // handle into GetControlInfo to retrieve information
  45. // about the control. Call ReleaseControlHandle on the
  46. // handle when done.
  47. // lpCachePath -- points to a string buffer that has the path where
  48. // all controls to be retrieved are located. If it
  49. // is NULL, the internet cache path will be read
  50. // from the registry. If a path is to be supplied,
  51. // the path must be a full pathname without any ~'s
  52. // in order for the enumeration to work correctly.
  53. //
  54. #define axcFINDFIRSTCONTROL "FindFirstControl"
  55. LONG WINAPI FindFirstControl(
  56. HANDLE& hFindHandle,
  57. HANDLE& hControlHandle,
  58. LPCTSTR lpszCachePath = NULL
  59. );
  60. typedef LONG (WINAPI *FINDFIRSTCONTROL)(
  61. HANDLE& hFindHandle,
  62. HANDLE& hControlHandle,
  63. LPCTSTR lpszCachePath /*= NULL*/
  64. );
  65. ///////////////////////////////////////////////////////////////////////////////
  66. // FindNextControl
  67. //
  68. // Purpose:
  69. // Resume a previously started search for installed ActiveX controls. The
  70. // search must have been initiated by a call to FirstFirstControl.
  71. //
  72. // Return Value:
  73. // - ERROR_SUCCESS if a control is found and search has been successfully
  74. // initiated.
  75. // - ERROR_NO_MORE_ITEMS if no control is found.
  76. // - If an error has occurred, the return value is a error code defined in
  77. // winerror.h. In this situation, the caller can choose to continue
  78. // the search with another call to FindNextControl, or simply abort.
  79. //
  80. // Parameters:
  81. // hFindHandle -- a handle received from a call to FindFirstControl.
  82. // Pass this handle to subsequent calls to
  83. // FindNextControl to retrieve controls one at a time.
  84. // hControlHandle -- handle to a control's data. Caller must pass this
  85. // handle into GetControlInfo to retrieve information
  86. // about the control. Call ReleaseControlHandle on the
  87. // handle when done.
  88. //
  89. #define axcFINDNEXTCONTROL "FindNextControl"
  90. LONG WINAPI FindNextControl(
  91. HANDLE& hFindHandle,
  92. HANDLE& hControlHandle
  93. );
  94. typedef LONG (WINAPI *FINDNEXTCONTROL)(
  95. HANDLE& hFindHandle,
  96. HANDLE& hControlHandle
  97. );
  98. ///////////////////////////////////////////////////////////////////////////////
  99. // FindControlClose
  100. //
  101. // Purpose:
  102. // Called when search is over. Missing a call to this function after a
  103. // search might contribute memory leak. This function can be called
  104. // regardless of what FindFirstControl and/or FindNextControl return.
  105. //
  106. // Return Value:
  107. // None.
  108. //
  109. // Parameters:
  110. // hFindHandle -- a handle obtained from calls to FindFirstControl and
  111. // FindNextControl in the current search.
  112. //
  113. #define axcFINDCONTROLCLOSE "FindControlClose"
  114. void WINAPI FindControlClose(
  115. HANDLE hFindHandle
  116. );
  117. typedef void (WINAPI *FINDCONTROLCLOSE)(
  118. HANDLE hFindHandle
  119. );
  120. ///////////////////////////////////////////////////////////////////////////////
  121. // ReleaseControlHandle
  122. //
  123. // Purpose:
  124. // When a handle of a control is retrieved via FindFirstControl or
  125. // FindNextControl, the caller is responsible to release that handle
  126. // by call this function.
  127. //
  128. // Return Value:
  129. // None.
  130. //
  131. // Parameters:
  132. // hControlHandle -- a handle to a control obtained from FindFirstControl
  133. // or FindNextControl.
  134. //
  135. #define axcRELEASECONTROLHANDLE "ReleaseControlHandle"
  136. void WINAPI ReleaseControlHandle(
  137. HANDLE hControlHandle
  138. );
  139. typedef void (WINAPI *RELEASECONTROLHANDLE)(
  140. HANDLE hControlHandle
  141. );
  142. ///////////////////////////////////////////////////////////////////////////////
  143. // GetControlInfo
  144. //
  145. // Purpose:
  146. // Once a handle to a control is obtained via FindFirstControl or
  147. // FindNextControl, the caller may retrieve information about the control
  148. // by call this function with a flag (nFlag) indicating what info to
  149. // retrieve. The supported flags are:
  150. // GCI_NAME -- friendly name of control
  151. // GCI_FILE -- main full path & file name of control
  152. // GCI_CLSID -- clsid of control, in a NULL-terminated string
  153. // GCI_TYPELIBID -- typelib guid of control, in a NULL-terminated string
  154. // GCI_TOTALSIZE -- total size in bytes of all control's dependent files
  155. // GCI_SIZESAVED -- total size in bytes restored if control is removed
  156. // It can be different from GCI_TOTALSIZE since some
  157. // of the control's dependent files might be shared dlls
  158. // GCI_TOTALFILES -- total number of control dependent files, including
  159. // shared dlls if there are any
  160. // GCI_STATUS -- the controls status value from STATUS_CTRL_* <above>
  161. // GCI_HAS_ACTIVEX -- non-zero if control includes ActiveX contols(s)
  162. // GCI_HAS_JAVA -- non-zero if control includes Java packages
  163. //
  164. // Return Value:
  165. // TRUE if succeeded, FALSE otherwise.
  166. //
  167. // Parameters:
  168. // hControlHandle -- handle to a control for which information is to be
  169. // retrieved.
  170. // nFlag -- indicate which information to retrieve. Please refer
  171. // to Purpose section above for a list of supported
  172. // flags. nFlag can only equal to one of them so do
  173. // not pass in multiple flags OR'ed together.
  174. // lpdwData -- address of a buffer for storing a numerical value.
  175. // (ie. GCI_TOTALSIZE, GCI_SIZESAVED & GCI_TOTALFILES)
  176. // This parameter is ignored for other flags.
  177. // lpszData -- address of a buffer for storing a NULL-terminated
  178. // string value (ie. GCI_NAME, GCI_FILE, GCI_CLSID &
  179. // GCI_TYPELIBID) This paramter is ignored if other
  180. // flags are specified.
  181. // nBufLen -- length of string buffer pointed to by lpszData.
  182. // This parameter is ignored if a numerical value is
  183. // being retrieved.
  184. //
  185. #define axcGETCONTROLINFO "GetControlInfo"
  186. BOOL WINAPI GetControlInfo(
  187. HANDLE hControlHandle,
  188. UINT nFlag,
  189. LPDWORD lpdwData,
  190. LPTSTR lpszBuf,
  191. int nBufLen
  192. );
  193. typedef BOOL (WINAPI *GETCONTROLINFO)(
  194. HANDLE hControlHandle,
  195. UINT nFlag,
  196. LPDWORD lpdwData,
  197. LPTSTR lpszBuf,
  198. int nBufLen
  199. );
  200. ///////////////////////////////////////////////////////////////////////////////
  201. // GetControlDependentFile
  202. //
  203. // Purpose:
  204. // A given control might depend on other files. For instance, FOO.OCX
  205. // might need FOO.INF and MFCXX.DLL in order to work. This function
  206. // retrieves one file at a time from a list of files depended upon by a
  207. // given ActiveX control. The list of files is NOT sorted.
  208. //
  209. // Return Value:
  210. // - ERROR_SUCCESS if a file is found at position iFile in the list.
  211. // - ERROR_NO_MORE_FILES if no file is found at position iFile in the list.
  212. // - If an error has occurred, the return value is a error code defined in
  213. // winerror.h.
  214. //
  215. // Parameters:
  216. // iFile -- a zero-based index indicating which file in the list
  217. // to retrieve.
  218. // hControlHandle -- handle to a control obtained via FindFirstControl
  219. // or FindNextControl.
  220. // lpszFile -- points to a buffer used to store the retrieved name.
  221. // lpszSize -- points to a DWORD variable that is to store the size
  222. // in bytes of the file retrieved. If it is 0, the file
  223. // does not exist.
  224. // bToUpper -- TRUE if the filename returned is to be converted to
  225. // uppercase. No conversion takes place if FALSE
  226. //
  227. #define axcGETCONTROLDEPENDENTFILE "GetControlDependentFile"
  228. LONG WINAPI GetControlDependentFile(
  229. int iFile,
  230. HANDLE hControlHandle,
  231. LPTSTR lpszFile,
  232. LPDWORD lpdwSize,
  233. BOOL bToUpper = FALSE
  234. );
  235. typedef LONG (WINAPI *GETCONTROLDEPENDENTFILE)(
  236. int iFile,
  237. HANDLE hControlHandle,
  238. LPTSTR lpszFile,
  239. LPDWORD lpdwSize,
  240. BOOL bToUpper /*= FALSE*/
  241. );
  242. ///////////////////////////////////////////////////////////////////////////////
  243. // IsModuleRemovable
  244. //
  245. // Purpose:
  246. // Checks whether a file can be removed by looking into the registry.
  247. // This function is called "IsModuleRemovable" instead of
  248. // "IsFileRemovable" because this routine does not check the actual file
  249. // for its status. For instance, a file can be deemed removable even if
  250. // is being exclusively opened by someone. This routine only tells from
  251. // the registry's point of view if a file can be safely removed or not.
  252. //
  253. // Return Value:
  254. // - FALSE if there is any indication that the given file is being shared
  255. // by other applications.
  256. // - TRUE otherwise.
  257. //
  258. // Parameter:
  259. // lpszFile -- points to a buffer that has the name (with full path) of
  260. // the file whose removal status is to be verified.
  261. //
  262. #define axcISMODULEREMOVABLE "IsModuleRemovable"
  263. BOOL WINAPI IsModuleRemovable(
  264. LPCTSTR lpszFile
  265. );
  266. typedef BOOL (WINAPI *ISMODULEREMOVABLE)(
  267. LPCTSTR lpszFile
  268. );
  269. ///////////////////////////////////////////////////////////////////////////////
  270. // RemoveControlByHandle
  271. //
  272. // Purpose:
  273. // Remove a control from registry as well as all the files that the control
  274. // depends on.
  275. //
  276. // Return Value:
  277. // - S_OK if control has been successfully uninstalled.
  278. // - S_FALSE if minor error has occurred, but not serious enough to
  279. // abort the uninstallation. Control has been uninstalled when the
  280. // call returns.
  281. // - An error code defined in winerror.h if an serious error has occurred
  282. // and uninstallation has been aborted. The state of the control
  283. // is not gaurenteed.
  284. //
  285. // Parameters:
  286. // lpControlData -- points to an instance of CONTROL_DATA representing the
  287. // control to be removed. The struct must have been
  288. // initialized by a call to FindFirstControl or
  289. // FindNextControl. Be sure to call ReleaseControlData
  290. // on this struct after successful removal, for the data
  291. // in this struct is no longer useful.
  292. // bForceRemove -- If this flag is FALSE, the removal routine will check
  293. // if the control is safe for removal before removing it.
  294. // If the flag is TRUE, the control will be removed
  295. // regardless of its removal status (except for Shared
  296. // Violation). The flag only applies to the control file
  297. // itself. Other files upon which the control depends are
  298. // removed only if they are deemed as safe for removal.
  299. //
  300. #define axcREMOVECONTROLBYHANDLE "RemoveControlByHandle"
  301. HRESULT WINAPI RemoveControlByHandle(
  302. HANDLE hControlHandle,
  303. BOOL bForceRemove = FALSE
  304. );
  305. typedef HRESULT (WINAPI *REMOVECONTROLBYHANDLE)(
  306. HANDLE hControlHandle,
  307. BOOL bForceRemove /*= FALSE*/
  308. );
  309. ///////////////////////////////////////////////////////////////////////////////
  310. // RemoveControlByName
  311. //
  312. // Purpose:
  313. // Remove a control from registry as well as all the files that the control
  314. // depends on. It is an overloaded version.
  315. //
  316. // Return Value:
  317. // - S_OK if control has been successfully uninstalled.
  318. // - S_FALSE if minor error has occurred, but not serious enough to
  319. // abort the uninstallation. Control has been uninstalled when the
  320. // call returns.
  321. // - An error code defined in winerror.h if an serious error has occurred
  322. // and uninstallation has been aborted. The state of the control
  323. // is not gaurenteed.
  324. //
  325. // Parameters:
  326. // lpszFile -- Address of a null-terminated string which is the main
  327. // file for the control (ie "FOO.OCX" for FOO control).
  328. // lpszCLSID -- Address of a null-terminated string which is the CLSID
  329. // of the control.
  330. // lpszTypeLibID -- Address of a null-terminated string which is the TypeLib
  331. // clsid of the control.
  332. // bForceRemove -- If this flag is FALSE, the removal routine will check
  333. // if the control is safe for removal before removing it.
  334. // If the flag is TRUE, the control will be removed
  335. // regardless of its removal status (except for Shared
  336. // Violation). The flag only applies to the control file
  337. // itself. Other files upon which the control depends are
  338. // removed only if they are deemed as safe for removal.
  339. // dwIsDistUnit -- boolean value to tell if this is really a dist unit
  340. //
  341. #define axcREMOVECONTROLBYNAME "RemoveControlByName"
  342. HRESULT WINAPI RemoveControlByName(
  343. LPCTSTR lpszFile,
  344. LPCTSTR lpszCLSID,
  345. LPCTSTR lpszTypeLibID,
  346. BOOL bForceRemove = FALSE,
  347. DWORD dwIsDistUnit = FALSE
  348. );
  349. typedef HRESULT (WINAPI *REMOVECONTROLBYNAME)(
  350. LPCTSTR lpszFile,
  351. LPCTSTR lpszCLSID,
  352. LPCTSTR lpszTypeLibID,
  353. BOOL bForceRemove /*= FALSE*/,
  354. DWORD dwIsDistUnit /*= FALSE*/
  355. );
  356. ///////////////////////////////////////////////////////////////////////////////
  357. // type PFNDOBEFOREREMOVAL, used for function SweepControlsByLastAccessDate
  358. //
  359. // Purpose:
  360. // Define callback function to be called right before removing a control
  361. //
  362. // Return Values:
  363. // If a success code (S_XXX) is returned, the control will be removed.
  364. // If a fail code (E_XXX) is returned, the control will be skipped.
  365. //
  366. // Parameters:
  367. // HANDLE -- handle to the control to be removed. One can get information
  368. // about the control using the GetControlInfo function. Do NOT
  369. // call ReleaseControlHandle on the handle.
  370. // UINT -- number of remaining controls including this one.
  371. //
  372. typedef HRESULT (CALLBACK *PFNDOBEFOREREMOVAL)(HANDLE, UINT);
  373. ///////////////////////////////////////////////////////////////////////////////
  374. // type PFNDOAFTERREMOVAL, used for function SweepControlsByLastAccessDate
  375. //
  376. // Purpose:
  377. // Define callback function to be called right after removing a control
  378. //
  379. // Return Values:
  380. // If a success code (S_XXX) is returned, the removal operation proceeds.
  381. // If a fail code (E_XXX) is returned, the removal operation is aborted.
  382. //
  383. // Parameters:
  384. // HRESULT -- result of removing the control. The handle to this control
  385. // was passed to the callback of type PFNDOBEFOREREMOVAL before
  386. // the control was removed. The possible values for this
  387. // HRESULT parameter are:
  388. // - S_OK (succeeded)
  389. // - S_FALSE (control had been removed with possibly some very
  390. // minor errors)
  391. // - E_ACCESSDENIED (control not safe for removal)
  392. // - STG_E_SHAREVIOLATION (control being used by others)
  393. // - Other errors returned by registry functions
  394. // It is up to the implementator of this function to decide
  395. // what to do given the result of removing the last control.
  396. // UINT -- number of remaining controls, NOT including the one just
  397. // removed.
  398. //
  399. typedef HRESULT (CALLBACK *PFNDOAFTERREMOVAL)(HRESULT, UINT);
  400. ///////////////////////////////////////////////////////////////////////////////
  401. // SweepControlsByLastAccessDate
  402. //
  403. // Purpose:
  404. // Remove all controls whose last access date is before and on a given
  405. // date.
  406. //
  407. // Return Value:
  408. // - S_OK if succeeded and at least one control was removed.
  409. // - S_FALSE if succeeded but no controls have been removed.
  410. // - E_XXX defined in winerror.h if an error has occurred.
  411. //
  412. // Parameters:
  413. // pLastAccessTime -- specify a last access date. All controls accessed
  414. // before and on this date are to be removed. Note
  415. // that all fields except wYear, wMonth and wDay are
  416. // ignored. If NULL, all control will be removed.
  417. // pfnDoBefore -- callback function called just before a control is
  418. // removed. Please read the description for type
  419. // PFNDOBEFOREREMOVAL for details. If NULL, nothing
  420. // is to be done prior to removing a control.
  421. // pfnDoAfter -- callback function called right after a control is
  422. // removed. Please read the description for type
  423. // PFNDOAFTERREMOVAL for details. If NULL, nothing
  424. // is to be done after a control is removed.
  425. // dwSizeLimit -- controls will be removed only if the total size
  426. // (in bytes) of all controls exceeds the size
  427. // specified by this paramter. This parameter is
  428. // ignored if 0 is specified.
  429. //
  430. #define axcSWEEPCONTROLSBYLASTACCESSDATE "SweepControlsByLastAccessDate"
  431. HRESULT WINAPI SweepControlsByLastAccessDate(
  432. SYSTEMTIME *pLastAccessTime = NULL,
  433. PFNDOBEFOREREMOVAL pfnDoBefore = NULL,
  434. PFNDOAFTERREMOVAL pfnDoAfter = NULL,
  435. DWORD dwSizeLimit = 0
  436. );
  437. typedef HRESULT (WINAPI *SWEEPCONTROLSBYLASTACCESSDATE)(
  438. SYSTEMTIME *pLastAccessTime /*= NULL*/,
  439. PFNDOBEFOREREMOVAL pfnDoBefore /*= NULL*/,
  440. PFNDOAFTERREMOVAL pfnDoAfter /*= NULL*/,
  441. DWORD dwSizeLimit /*= 0*/
  442. );
  443. ///////////////////////////////////////////////////////////////////////////////
  444. // RemoveExpiredControls
  445. //
  446. // Purpose:
  447. // Similar to IEmptyVolumeCache. Removes all controls with a last
  448. // access date in the distant past and all controls flagged for more
  449. // rapid auto-expire.
  450. //
  451. // Return Value:
  452. // - S_OK if succeeded and at least one control was removed.
  453. // - S_FALSE if succeeded but no controls have been removed.
  454. // - E_XXX defined in winerror.h if an error has occurred.
  455. //
  456. // Parameters:
  457. // dwFlags -- Currently, only REC_SILENT is defined.
  458. // dwReserved -- Must be 0.
  459. //
  460. #define axcREMOVEEXPIREDCONTROLS "RemoveExpiredControls"
  461. HRESULT WINAPI RemoveExpiredControls(DWORD dwFlags, DWORD dwReserved);
  462. typedef HRESULT (WINAPI *REMOVEEXPIREDCONTROLS)(DWORD dwFlags, DWORD dwReserved);
  463. #endif