Source code of Windows XP (NT5)
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.

499 lines
16 KiB

  1. //+----------------------------------------------------------------------------
  2. //
  3. // Task Scheduler
  4. //
  5. // Microsoft Windows
  6. // Copyright (C) Microsoft Corporation, 1992 - 1996.
  7. //
  8. // File: mstask.idl
  9. //
  10. // Contents: ITaskTrigger, ITask, ITaskScheduler, IEnumWorkItems
  11. // interfaces and related definitions
  12. //
  13. // History: 06-Sep-95 EricB created
  14. //
  15. //-----------------------------------------------------------------------------
  16. import "oaidl.idl";
  17. import "oleidl.idl";
  18. // 148BD520-A2AB-11CE-B11F-00AA00530503 - Task object class ID
  19. // 148BD52A-A2AB-11CE-B11F-00AA00530503 - Task Scheduler class ID
  20. // A6B952F0-A4B1-11D0-997D-00AA006887EC - IScheduledWorkItem interface ID
  21. // 148BD524-A2AB-11CE-B11F-00AA00530503 - ITask interface ID
  22. // 148BD527-A2AB-11CE-B11F-00AA00530503 - ITaskScheduler interface ID
  23. // 148BD528-A2AB-11CE-B11F-00AA00530503 - IEnumWorkItems interface ID
  24. // 148BD52B-A2AB-11CE-B11F-00AA00530503 - ITaskTrigger interface ID
  25. //+----------------------------------------------------------------------------
  26. //
  27. // Datatypes
  28. //
  29. //-----------------------------------------------------------------------------
  30. cpp_quote("#define TASK_SUNDAY (0x1)")
  31. cpp_quote("#define TASK_MONDAY (0x2)")
  32. cpp_quote("#define TASK_TUESDAY (0x4)")
  33. cpp_quote("#define TASK_WEDNESDAY (0x8)")
  34. cpp_quote("#define TASK_THURSDAY (0x10)")
  35. cpp_quote("#define TASK_FRIDAY (0x20)")
  36. cpp_quote("#define TASK_SATURDAY (0x40)")
  37. cpp_quote("#define TASK_FIRST_WEEK (1)")
  38. cpp_quote("#define TASK_SECOND_WEEK (2)")
  39. cpp_quote("#define TASK_THIRD_WEEK (3)")
  40. cpp_quote("#define TASK_FOURTH_WEEK (4)")
  41. cpp_quote("#define TASK_LAST_WEEK (5)")
  42. cpp_quote("#define TASK_JANUARY (0x1)")
  43. cpp_quote("#define TASK_FEBRUARY (0x2)")
  44. cpp_quote("#define TASK_MARCH (0x4)")
  45. cpp_quote("#define TASK_APRIL (0x8)")
  46. cpp_quote("#define TASK_MAY (0x10)")
  47. cpp_quote("#define TASK_JUNE (0x20)")
  48. cpp_quote("#define TASK_JULY (0x40)")
  49. cpp_quote("#define TASK_AUGUST (0x80)")
  50. cpp_quote("#define TASK_SEPTEMBER (0x100)")
  51. cpp_quote("#define TASK_OCTOBER (0x200)")
  52. cpp_quote("#define TASK_NOVEMBER (0x400)")
  53. cpp_quote("#define TASK_DECEMBER (0x800)")
  54. cpp_quote("#define TASK_FLAG_INTERACTIVE (0x1)")
  55. cpp_quote("#define TASK_FLAG_DELETE_WHEN_DONE (0x2)")
  56. cpp_quote("#define TASK_FLAG_DISABLED (0x4)")
  57. cpp_quote("#define TASK_FLAG_START_ONLY_IF_IDLE (0x10)")
  58. cpp_quote("#define TASK_FLAG_KILL_ON_IDLE_END (0x20)")
  59. cpp_quote("#define TASK_FLAG_DONT_START_IF_ON_BATTERIES (0x40)")
  60. cpp_quote("#define TASK_FLAG_KILL_IF_GOING_ON_BATTERIES (0x80)")
  61. cpp_quote("#define TASK_FLAG_RUN_ONLY_IF_DOCKED (0x100)")
  62. cpp_quote("#define TASK_FLAG_HIDDEN (0x200)")
  63. cpp_quote("#define TASK_FLAG_RUN_IF_CONNECTED_TO_INTERNET (0x400)")
  64. cpp_quote("#define TASK_FLAG_RESTART_ON_IDLE_RESUME (0x800)")
  65. cpp_quote("#define TASK_FLAG_SYSTEM_REQUIRED (0x1000)")
  66. cpp_quote("#define TASK_FLAG_RUN_ONLY_IF_LOGGED_ON (0x2000)")
  67. cpp_quote("#define TASK_TRIGGER_FLAG_HAS_END_DATE (0x1)")
  68. cpp_quote("#define TASK_TRIGGER_FLAG_KILL_AT_DURATION_END (0x2)")
  69. cpp_quote("#define TASK_TRIGGER_FLAG_DISABLED (0x4)")
  70. //
  71. // 1440 = 60 mins/hour * 24 hrs/day since a trigger/TASK could run all day at
  72. // one minute intervals.
  73. //
  74. const int TASK_MAX_RUN_TIMES = 1440;
  75. //
  76. // The TASK_TRIGGER_TYPE field of the TASK_TRIGGER structure determines
  77. // which member of the TRIGGER_TYPE_UNION field to use.
  78. //
  79. typedef enum _TASK_TRIGGER_TYPE {
  80. TASK_TIME_TRIGGER_ONCE = 0, // Ignore the Type field.
  81. TASK_TIME_TRIGGER_DAILY = 1, // Use DAILY
  82. TASK_TIME_TRIGGER_WEEKLY = 2, // Use WEEKLY
  83. TASK_TIME_TRIGGER_MONTHLYDATE = 3, // Use MONTHLYDATE
  84. TASK_TIME_TRIGGER_MONTHLYDOW = 4, // Use MONTHLYDOW
  85. TASK_EVENT_TRIGGER_ON_IDLE = 5, // Ignore the Type field.
  86. TASK_EVENT_TRIGGER_AT_SYSTEMSTART = 6, // Ignore the Type field.
  87. TASK_EVENT_TRIGGER_AT_LOGON = 7 // Ignore the Type field.
  88. } TASK_TRIGGER_TYPE, *PTASK_TRIGGER_TYPE;
  89. typedef struct _DAILY {
  90. WORD DaysInterval;
  91. } DAILY;
  92. typedef struct _WEEKLY {
  93. WORD WeeksInterval;
  94. WORD rgfDaysOfTheWeek;
  95. } WEEKLY;
  96. typedef struct _MONTHLYDATE {
  97. DWORD rgfDays;
  98. WORD rgfMonths;
  99. } MONTHLYDATE;
  100. typedef struct _MONTHLYDOW {
  101. WORD wWhichWeek;
  102. WORD rgfDaysOfTheWeek;
  103. WORD rgfMonths;
  104. } MONTHLYDOW;
  105. typedef union _TRIGGER_TYPE_UNION {
  106. DAILY Daily;
  107. WEEKLY Weekly;
  108. MONTHLYDATE MonthlyDate;
  109. MONTHLYDOW MonthlyDOW;
  110. } TRIGGER_TYPE_UNION;
  111. typedef struct _TASK_TRIGGER {
  112. WORD cbTriggerSize; // Structure size.
  113. WORD Reserved1; // Reserved. Must be zero.
  114. WORD wBeginYear; // Trigger beginning date year.
  115. WORD wBeginMonth; // Trigger beginning date month.
  116. WORD wBeginDay; // Trigger beginning date day.
  117. WORD wEndYear; // Optional trigger ending date year.
  118. WORD wEndMonth; // Optional trigger ending date month.
  119. WORD wEndDay; // Optional trigger ending date day.
  120. WORD wStartHour; // Run bracket start time hour.
  121. WORD wStartMinute; // Run bracket start time minute.
  122. DWORD MinutesDuration; // Duration of run bracket.
  123. DWORD MinutesInterval; // Run bracket repetition interval.
  124. DWORD rgFlags; // Trigger flags.
  125. TASK_TRIGGER_TYPE TriggerType; // Trigger type.
  126. TRIGGER_TYPE_UNION Type; // Trigger data.
  127. WORD Reserved2; // Reserved. Must be zero.
  128. WORD wRandomMinutesInterval; // Maximum number of random minutes
  129. // after start time.
  130. } TASK_TRIGGER, * PTASK_TRIGGER;
  131. //+----------------------------------------------------------------------------
  132. //
  133. // Interfaces
  134. //
  135. //-----------------------------------------------------------------------------
  136. //+----------------------------------------------------------------------------
  137. //
  138. // Interface: ITaskTrigger
  139. //
  140. // Synopsis: Trigger object interface. A Task object may contain several
  141. // of these.
  142. //
  143. //-----------------------------------------------------------------------------
  144. cpp_quote("// {148BD52B-A2AB-11CE-B11F-00AA00530503}")
  145. cpp_quote("DEFINE_GUID(IID_ITaskTrigger, 0x148BD52BL, 0xA2AB, 0x11CE, 0xB1, 0x1F, 0x00, 0xAA, 0x00, 0x53, 0x05, 0x03);")
  146. interface ITaskTrigger;
  147. [
  148. local,
  149. object,
  150. uuid(148BD52B-A2AB-11CE-B11F-00AA00530503),
  151. pointer_default(unique)
  152. ]
  153. interface ITaskTrigger : IUnknown
  154. {
  155. // Methods:
  156. HRESULT SetTrigger(
  157. [in] const PTASK_TRIGGER pTrigger);
  158. HRESULT GetTrigger(
  159. [out] PTASK_TRIGGER pTrigger);
  160. HRESULT GetTriggerString(
  161. [out] LPWSTR * ppwszTrigger);
  162. };
  163. //+----------------------------------------------------------------------------
  164. //
  165. // Interface: IScheduledWorkItem
  166. //
  167. // Synopsis: Abstract base class for any runnable work item that can be
  168. // scheduled by the task scheduler.
  169. //
  170. //-----------------------------------------------------------------------------
  171. cpp_quote("// {a6b952f0-a4b1-11d0-997d-00aa006887ec}")
  172. cpp_quote("DEFINE_GUID(IID_IScheduledWorkItem, 0xa6b952f0L, 0xa4b1, 0x11d0, 0x99, 0x7d, 0x00, 0xaa, 0x00, 0x68, 0x87, 0xec);")
  173. interface IScheduledWorkItem;
  174. [
  175. local,
  176. object,
  177. uuid(a6b952f0-a4b1-11d0-997d-00aa006887ec),
  178. pointer_default(unique)
  179. ]
  180. interface IScheduledWorkItem : IUnknown
  181. {
  182. // Methods concerning scheduling:
  183. HRESULT CreateTrigger(
  184. [out] WORD * piNewTrigger,
  185. [out] ITaskTrigger ** ppTrigger);
  186. HRESULT DeleteTrigger(
  187. [in] WORD iTrigger);
  188. HRESULT GetTriggerCount(
  189. [out] WORD * pwCount);
  190. HRESULT GetTrigger(
  191. [in] WORD iTrigger,
  192. [out] ITaskTrigger ** ppTrigger);
  193. HRESULT GetTriggerString(
  194. [in] WORD iTrigger,
  195. [out] LPWSTR * ppwszTrigger);
  196. HRESULT GetRunTimes(
  197. [in] const LPSYSTEMTIME pstBegin,
  198. [in] const LPSYSTEMTIME pstEnd,
  199. [in, out] WORD * pCount,
  200. [out] LPSYSTEMTIME * rgstTaskTimes);
  201. HRESULT GetNextRunTime(
  202. [in, out] SYSTEMTIME * pstNextRun);
  203. HRESULT SetIdleWait(
  204. [in] WORD wIdleMinutes,
  205. [in] WORD wDeadlineMinutes);
  206. HRESULT GetIdleWait(
  207. [out] WORD * pwIdleMinutes,
  208. [out] WORD * pwDeadlineMinutes);
  209. // Other methods:
  210. HRESULT Run(
  211. void);
  212. HRESULT Terminate(
  213. void);
  214. HRESULT EditWorkItem(
  215. [in] HWND hParent,
  216. [in] DWORD dwReserved);
  217. HRESULT GetMostRecentRunTime(
  218. [out] SYSTEMTIME * pstLastRun);
  219. HRESULT GetStatus(
  220. [out] HRESULT * phrStatus);
  221. HRESULT GetExitCode(
  222. [out] DWORD * pdwExitCode);
  223. // Properties:
  224. HRESULT SetComment(
  225. [in] LPCWSTR pwszComment);
  226. HRESULT GetComment(
  227. [out] LPWSTR * ppwszComment);
  228. HRESULT SetCreator(
  229. [in] LPCWSTR pwszCreator);
  230. HRESULT GetCreator(
  231. [out] LPWSTR * ppwszCreator);
  232. HRESULT SetWorkItemData(
  233. [in] WORD cbData,
  234. [in] BYTE rgbData[]);
  235. HRESULT GetWorkItemData(
  236. [out] WORD * pcbData,
  237. [out] BYTE ** prgbData);
  238. HRESULT SetErrorRetryCount(
  239. [in] WORD wRetryCount);
  240. HRESULT GetErrorRetryCount(
  241. [out] WORD * pwRetryCount);
  242. HRESULT SetErrorRetryInterval(
  243. [in] WORD wRetryInterval);
  244. HRESULT GetErrorRetryInterval(
  245. [out] WORD * pwRetryInterval);
  246. HRESULT SetFlags(
  247. [in] DWORD dwFlags);
  248. HRESULT GetFlags(
  249. [out] DWORD * pdwFlags);
  250. HRESULT SetAccountInformation(
  251. [in] LPCWSTR pwszAccountName,
  252. [in] LPCWSTR pwszPassword);
  253. HRESULT GetAccountInformation(
  254. [out] LPWSTR * ppwszAccountName);
  255. }
  256. //+----------------------------------------------------------------------------
  257. //
  258. // Interface: ITask
  259. //
  260. // Synopsis: Task object interface. The primary means of task object
  261. // manipulation.
  262. //
  263. //-----------------------------------------------------------------------------
  264. cpp_quote("// {148BD524-A2AB-11CE-B11F-00AA00530503}")
  265. cpp_quote("DEFINE_GUID(IID_ITask, 0x148BD524L, 0xA2AB, 0x11CE, 0xB1, 0x1F, 0x00, 0xAA, 0x00, 0x53, 0x05, 0x03);")
  266. interface ITask;
  267. [
  268. local,
  269. object,
  270. uuid(148BD524-A2AB-11CE-B11F-00AA00530503),
  271. pointer_default(unique)
  272. ]
  273. interface ITask : IScheduledWorkItem
  274. {
  275. // Properties that correspond to parameters of CreateProcess:
  276. HRESULT SetApplicationName(
  277. [in] LPCWSTR pwszApplicationName);
  278. HRESULT GetApplicationName(
  279. [out] LPWSTR * ppwszApplicationName);
  280. HRESULT SetParameters(
  281. [in] LPCWSTR pwszParameters);
  282. HRESULT GetParameters(
  283. [out] LPWSTR * ppwszParameters);
  284. HRESULT SetWorkingDirectory(
  285. [in] LPCWSTR pwszWorkingDirectory);
  286. HRESULT GetWorkingDirectory(
  287. [out] LPWSTR * ppwszWorkingDirectory);
  288. HRESULT SetPriority(
  289. [in] DWORD dwPriority);
  290. HRESULT GetPriority(
  291. [out] DWORD * pdwPriority);
  292. // Other properties:
  293. HRESULT SetTaskFlags(
  294. [in] DWORD dwFlags);
  295. HRESULT GetTaskFlags(
  296. [out] DWORD * pdwFlags);
  297. HRESULT SetMaxRunTime(
  298. [in] DWORD dwMaxRunTimeMS);
  299. HRESULT GetMaxRunTime(
  300. [out] DWORD * pdwMaxRunTimeMS);
  301. }
  302. //+----------------------------------------------------------------------------
  303. //
  304. // Interface: IEnumWorkItems
  305. //
  306. // Synopsis: Work item object enumerator. Enumerates the work item objects
  307. // within the Tasks folder.
  308. //
  309. //-----------------------------------------------------------------------------
  310. cpp_quote("// {148BD528-A2AB-11CE-B11F-00AA00530503}")
  311. cpp_quote("DEFINE_GUID(IID_IEnumWorkItems, 0x148BD528L, 0xA2AB, 0x11CE, 0xB1, 0x1F, 0x00, 0xAA, 0x00, 0x53, 0x05, 0x03);")
  312. interface IEnumWorkItems;
  313. [
  314. local,
  315. object,
  316. uuid(148BD528-A2AB-11CE-B11F-00AA00530503),
  317. pointer_default(unique)
  318. ]
  319. interface IEnumWorkItems : IUnknown
  320. {
  321. // Methods:
  322. HRESULT Next(
  323. [in] ULONG celt,
  324. [out] LPWSTR ** rgpwszNames,
  325. [out] ULONG * pceltFetched);
  326. HRESULT Skip(
  327. [in] ULONG celt);
  328. HRESULT Reset(
  329. void);
  330. HRESULT Clone(
  331. [out] IEnumWorkItems ** ppEnumWorkItems);
  332. }
  333. //+----------------------------------------------------------------------------
  334. //
  335. // Interface: ITaskScheduler
  336. //
  337. // Synopsis: Task Scheduler interface. Provides location transparent
  338. // manipulation of task and/or queue objects within the Tasks
  339. // folder.
  340. //
  341. //-----------------------------------------------------------------------------
  342. cpp_quote("// {148BD527-A2AB-11CE-B11F-00AA00530503}")
  343. cpp_quote("DEFINE_GUID(IID_ITaskScheduler, 0x148BD527L, 0xA2AB, 0x11CE, 0xB1, 0x1F, 0x00, 0xAA, 0x00, 0x53, 0x05, 0x03);")
  344. interface ITaskScheduler;
  345. [
  346. local,
  347. object,
  348. uuid(148BD527-A2AB-11CE-B11F-00AA00530503),
  349. pointer_default(unique)
  350. ]
  351. interface ITaskScheduler : IUnknown
  352. {
  353. // Methods:
  354. HRESULT SetTargetComputer(
  355. [in] LPCWSTR pwszComputer);
  356. HRESULT GetTargetComputer(
  357. [out] LPWSTR * ppwszComputer);
  358. HRESULT Enum(
  359. [out] IEnumWorkItems ** ppEnumWorkItems);
  360. HRESULT Activate(
  361. [in] LPCWSTR pwszName,
  362. [in] REFIID riid,
  363. [out] IUnknown ** ppUnk);
  364. HRESULT Delete(
  365. [in] LPCWSTR pwszName);
  366. HRESULT NewWorkItem(
  367. [in] LPCWSTR pwszTaskName,
  368. [in] REFCLSID rclsid,
  369. [in] REFIID riid,
  370. [out] IUnknown ** ppUnk);
  371. HRESULT AddWorkItem(
  372. [in] LPCWSTR pwszTaskName,
  373. [in] IScheduledWorkItem * pWorkItem);
  374. HRESULT IsOfType(
  375. [in] LPCWSTR pwszName,
  376. [in] REFIID riid);
  377. }
  378. cpp_quote("EXTERN_C const CLSID CLSID_CTask;")
  379. cpp_quote("EXTERN_C const CLSID CLSID_CTaskScheduler;")
  380. cpp_quote(" ")
  381. cpp_quote("// {148BD520-A2AB-11CE-B11F-00AA00530503}")
  382. cpp_quote("DEFINE_GUID(CLSID_CTask, 0x148BD520, 0xA2AB, 0x11CE, 0xB1, 0x1F, 0x00, 0xAA, 0x00, 0x53, 0x05, 0x03);")
  383. cpp_quote(" ")
  384. cpp_quote("// {148BD52A-A2AB-11CE-B11F-00AA00530503}")
  385. cpp_quote("DEFINE_GUID(CLSID_CTaskScheduler, 0x148BD52A, 0xA2AB, 0x11CE, 0xB1, 0x1F, 0x00, 0xAA, 0x00, 0x53, 0x05, 0x03);")
  386. cpp_quote(" ")
  387. //
  388. // NOTE: Definition of HPROPSHEETPAGE is from sdk\inc\prsht.h
  389. // Including this header file causes numerous redefinition errors.
  390. //
  391. struct _PSP;
  392. typedef struct _PSP * HPROPSHEETPAGE;
  393. typedef enum _TASKPAGE {
  394. TASKPAGE_TASK = 0,
  395. TASKPAGE_SCHEDULE = 1,
  396. TASKPAGE_SETTINGS = 2
  397. } TASKPAGE;
  398. //+----------------------------------------------------------------------------
  399. //
  400. // Interface: IProvideTaskPage
  401. //
  402. // Synopsis: Task property page retrieval interface. With this interface,
  403. // it is possible to retrieve one or more property pages
  404. // associated with a task object. Task objects inherit this
  405. // interface.
  406. //
  407. //-----------------------------------------------------------------------------
  408. cpp_quote("// {4086658a-cbbb-11cf-b604-00c04fd8d565}")
  409. cpp_quote("DEFINE_GUID(IID_IProvideTaskPage, 0x4086658aL, 0xcbbb, 0x11cf, 0xb6, 0x04, 0x00, 0xc0, 0x4f, 0xd8, 0xd5, 0x65);")
  410. interface IProvideTaskPage;
  411. [
  412. local,
  413. object,
  414. uuid(4086658a-cbbb-11cf-b604-00c04fd8d565),
  415. pointer_default(unique)
  416. ]
  417. interface IProvideTaskPage : IUnknown
  418. {
  419. // Methods:
  420. HRESULT GetPage(
  421. [in] TASKPAGE tpType,
  422. [in] BOOL fPersistChanges,
  423. [out] HPROPSHEETPAGE * phPage);
  424. }
  425. cpp_quote("#define ISchedulingAgent ITaskScheduler")
  426. cpp_quote("#define IEnumTasks IEnumWorkItems")
  427. cpp_quote("#define IID_ISchedulingAgent IID_ITaskScheduler")
  428. cpp_quote("#define CLSID_CSchedulingAgent CLSID_CTaskScheduler")