winex11: Load a monochrome cursor instead of converting a color one when possible.
[wine.git] / dlls / mstask / task.c
blob97ae8b7b6714e36ddaddc20eae60bfc5b716dae0
1 /*
2 * Copyright (C) 2008 Google (Roy Shea)
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #include "mstask_private.h"
20 #include "wine/debug.h"
22 WINE_DEFAULT_DEBUG_CHANNEL(mstask);
24 typedef struct
26 ITask ITask_iface;
27 IPersistFile IPersistFile_iface;
28 LONG ref;
29 LPWSTR taskName;
30 LPWSTR applicationName;
31 LPWSTR parameters;
32 LPWSTR comment;
33 DWORD maxRunTime;
34 LPWSTR accountName;
35 } TaskImpl;
37 static inline TaskImpl *impl_from_ITask(ITask *iface)
39 return CONTAINING_RECORD(iface, TaskImpl, ITask_iface);
42 static inline TaskImpl *impl_from_IPersistFile( IPersistFile *iface )
44 return CONTAINING_RECORD(iface, TaskImpl, IPersistFile_iface);
47 static void TaskDestructor(TaskImpl *This)
49 TRACE("%p\n", This);
50 HeapFree(GetProcessHeap(), 0, This->accountName);
51 HeapFree(GetProcessHeap(), 0, This->comment);
52 HeapFree(GetProcessHeap(), 0, This->parameters);
53 HeapFree(GetProcessHeap(), 0, This->taskName);
54 HeapFree(GetProcessHeap(), 0, This);
55 InterlockedDecrement(&dll_ref);
58 static HRESULT WINAPI MSTASK_ITask_QueryInterface(
59 ITask* iface,
60 REFIID riid,
61 void **ppvObject)
63 TaskImpl * This = impl_from_ITask(iface);
65 TRACE("IID: %s\n", debugstr_guid(riid));
66 if (ppvObject == NULL)
67 return E_POINTER;
69 if (IsEqualGUID(riid, &IID_IUnknown) ||
70 IsEqualGUID(riid, &IID_ITask))
72 *ppvObject = &This->ITask_iface;
73 ITask_AddRef(iface);
74 return S_OK;
76 else if (IsEqualGUID(riid, &IID_IPersistFile))
78 *ppvObject = &This->IPersistFile_iface;
79 ITask_AddRef(iface);
80 return S_OK;
83 WARN("Unknown interface: %s\n", debugstr_guid(riid));
84 *ppvObject = NULL;
85 return E_NOINTERFACE;
88 static ULONG WINAPI MSTASK_ITask_AddRef(
89 ITask* iface)
91 TaskImpl *This = impl_from_ITask(iface);
92 ULONG ref;
93 TRACE("\n");
94 ref = InterlockedIncrement(&This->ref);
95 return ref;
98 static ULONG WINAPI MSTASK_ITask_Release(
99 ITask* iface)
101 TaskImpl * This = impl_from_ITask(iface);
102 ULONG ref;
103 TRACE("\n");
104 ref = InterlockedDecrement(&This->ref);
105 if (ref == 0)
106 TaskDestructor(This);
107 return ref;
110 static HRESULT WINAPI MSTASK_ITask_CreateTrigger(
111 ITask* iface,
112 WORD *piNewTrigger,
113 ITaskTrigger **ppTrigger)
115 TRACE("(%p, %p, %p)\n", iface, piNewTrigger, ppTrigger);
116 return TaskTriggerConstructor((LPVOID *)ppTrigger);
119 static HRESULT WINAPI MSTASK_ITask_DeleteTrigger(
120 ITask* iface,
121 WORD iTrigger)
123 FIXME("(%p, %d): stub\n", iface, iTrigger);
124 return E_NOTIMPL;
127 static HRESULT WINAPI MSTASK_ITask_GetTriggerCount(
128 ITask* iface,
129 WORD *plCount)
131 FIXME("(%p, %p): stub\n", iface, plCount);
132 return E_NOTIMPL;
135 static HRESULT WINAPI MSTASK_ITask_GetTrigger(
136 ITask* iface,
137 WORD iTrigger,
138 ITaskTrigger **ppTrigger)
140 FIXME("(%p, %d, %p): stub\n", iface, iTrigger, ppTrigger);
141 return E_NOTIMPL;
144 static HRESULT WINAPI MSTASK_ITask_GetTriggerString(
145 ITask* iface,
146 WORD iTrigger,
147 LPWSTR *ppwszTrigger)
149 FIXME("(%p, %d, %p): stub\n", iface, iTrigger, ppwszTrigger);
150 return E_NOTIMPL;
153 static HRESULT WINAPI MSTASK_ITask_GetRunTimes(
154 ITask* iface,
155 const LPSYSTEMTIME pstBegin,
156 const LPSYSTEMTIME pstEnd,
157 WORD *pCount,
158 LPSYSTEMTIME *rgstTaskTimes)
160 FIXME("(%p, %p, %p, %p, %p): stub\n", iface, pstBegin, pstEnd, pCount,
161 rgstTaskTimes);
162 return E_NOTIMPL;
165 static HRESULT WINAPI MSTASK_ITask_GetNextRunTime(
166 ITask* iface,
167 SYSTEMTIME *pstNextRun)
169 FIXME("(%p, %p): stub\n", iface, pstNextRun);
170 return E_NOTIMPL;
173 static HRESULT WINAPI MSTASK_ITask_SetIdleWait(
174 ITask* iface,
175 WORD wIdleMinutes,
176 WORD wDeadlineMinutes)
178 FIXME("(%p, %d, %d): stub\n", iface, wIdleMinutes, wDeadlineMinutes);
179 return E_NOTIMPL;
182 static HRESULT WINAPI MSTASK_ITask_GetIdleWait(
183 ITask* iface,
184 WORD *pwIdleMinutes,
185 WORD *pwDeadlineMinutes)
187 FIXME("(%p, %p, %p): stub\n", iface, pwIdleMinutes, pwDeadlineMinutes);
188 return E_NOTIMPL;
191 static HRESULT WINAPI MSTASK_ITask_Run(
192 ITask* iface)
194 FIXME("(%p): stub\n", iface);
195 return E_NOTIMPL;
198 static HRESULT WINAPI MSTASK_ITask_Terminate(
199 ITask* iface)
201 FIXME("(%p): stub\n", iface);
202 return E_NOTIMPL;
205 static HRESULT WINAPI MSTASK_ITask_EditWorkItem(
206 ITask* iface,
207 HWND hParent,
208 DWORD dwReserved)
210 FIXME("(%p, %p, %d): stub\n", iface, hParent, dwReserved);
211 return E_NOTIMPL;
214 static HRESULT WINAPI MSTASK_ITask_GetMostRecentRunTime(
215 ITask* iface,
216 SYSTEMTIME *pstLastRun)
218 FIXME("(%p, %p): stub\n", iface, pstLastRun);
219 return E_NOTIMPL;
222 static HRESULT WINAPI MSTASK_ITask_GetStatus(
223 ITask* iface,
224 HRESULT *phrStatus)
226 FIXME("(%p, %p): stub\n", iface, phrStatus);
227 return E_NOTIMPL;
230 static HRESULT WINAPI MSTASK_ITask_GetExitCode(
231 ITask* iface,
232 DWORD *pdwExitCode)
234 FIXME("(%p, %p): stub\n", iface, pdwExitCode);
235 return E_NOTIMPL;
238 static HRESULT WINAPI MSTASK_ITask_SetComment(
239 ITask* iface,
240 LPCWSTR pwszComment)
242 DWORD n;
243 TaskImpl *This = impl_from_ITask(iface);
244 LPWSTR tmp_comment;
246 TRACE("(%p, %s)\n", iface, debugstr_w(pwszComment));
248 /* Empty comment */
249 if (pwszComment[0] == 0)
251 HeapFree(GetProcessHeap(), 0, This->comment);
252 This->comment = NULL;
253 return S_OK;
256 /* Set to pwszComment */
257 n = (lstrlenW(pwszComment) + 1);
258 tmp_comment = HeapAlloc(GetProcessHeap(), 0, n * sizeof(WCHAR));
259 if (!tmp_comment)
260 return E_OUTOFMEMORY;
261 lstrcpyW(tmp_comment, pwszComment);
262 HeapFree(GetProcessHeap(), 0, This->comment);
263 This->comment = tmp_comment;
265 return S_OK;
268 static HRESULT WINAPI MSTASK_ITask_GetComment(
269 ITask* iface,
270 LPWSTR *ppwszComment)
272 DWORD n;
273 TaskImpl *This = impl_from_ITask(iface);
275 TRACE("(%p, %p)\n", iface, ppwszComment);
277 n = This->comment ? lstrlenW(This->comment) + 1 : 1;
278 *ppwszComment = CoTaskMemAlloc(n * sizeof(WCHAR));
279 if (!*ppwszComment)
280 return E_OUTOFMEMORY;
282 if (!This->comment)
283 *ppwszComment[0] = 0;
284 else
285 lstrcpyW(*ppwszComment, This->comment);
287 return S_OK;
290 static HRESULT WINAPI MSTASK_ITask_SetCreator(
291 ITask* iface,
292 LPCWSTR pwszCreator)
294 FIXME("(%p, %p): stub\n", iface, pwszCreator);
295 return E_NOTIMPL;
298 static HRESULT WINAPI MSTASK_ITask_GetCreator(
299 ITask* iface,
300 LPWSTR *ppwszCreator)
302 FIXME("(%p, %p): stub\n", iface, ppwszCreator);
303 return E_NOTIMPL;
306 static HRESULT WINAPI MSTASK_ITask_SetWorkItemData(
307 ITask* iface,
308 WORD cBytes,
309 BYTE rgbData[])
311 FIXME("(%p, %d, %p): stub\n", iface, cBytes, rgbData);
312 return E_NOTIMPL;
315 static HRESULT WINAPI MSTASK_ITask_GetWorkItemData(
316 ITask* iface,
317 WORD *pcBytes,
318 BYTE **ppBytes)
320 FIXME("(%p, %p, %p): stub\n", iface, pcBytes, ppBytes);
321 return E_NOTIMPL;
324 static HRESULT WINAPI MSTASK_ITask_SetErrorRetryCount(
325 ITask* iface,
326 WORD wRetryCount)
328 FIXME("(%p, %d): stub\n", iface, wRetryCount);
329 return E_NOTIMPL;
332 static HRESULT WINAPI MSTASK_ITask_GetErrorRetryCount(
333 ITask* iface,
334 WORD *pwRetryCount)
336 FIXME("(%p, %p): stub\n", iface, pwRetryCount);
337 return E_NOTIMPL;
340 static HRESULT WINAPI MSTASK_ITask_SetErrorRetryInterval(
341 ITask* iface,
342 WORD wRetryInterval)
344 FIXME("(%p, %d): stub\n", iface, wRetryInterval);
345 return E_NOTIMPL;
348 static HRESULT WINAPI MSTASK_ITask_GetErrorRetryInterval(
349 ITask* iface,
350 WORD *pwRetryInterval)
352 FIXME("(%p, %p): stub\n", iface, pwRetryInterval);
353 return E_NOTIMPL;
356 static HRESULT WINAPI MSTASK_ITask_SetFlags(
357 ITask* iface,
358 DWORD dwFlags)
360 FIXME("(%p, 0x%08x): stub\n", iface, dwFlags);
361 return E_NOTIMPL;
364 static HRESULT WINAPI MSTASK_ITask_GetFlags(
365 ITask* iface,
366 DWORD *pdwFlags)
368 FIXME("(%p, %p): stub\n", iface, pdwFlags);
369 return E_NOTIMPL;
372 static HRESULT WINAPI MSTASK_ITask_SetAccountInformation(
373 ITask* iface,
374 LPCWSTR pwszAccountName,
375 LPCWSTR pwszPassword)
377 DWORD n;
378 TaskImpl *This = impl_from_ITask(iface);
379 LPWSTR tmp_account_name;
381 TRACE("(%p, %s, %s): partial stub\n", iface, debugstr_w(pwszAccountName),
382 debugstr_w(pwszPassword));
384 if (pwszPassword)
385 FIXME("Partial stub ignores passwords\n");
387 n = (lstrlenW(pwszAccountName) + 1);
388 tmp_account_name = HeapAlloc(GetProcessHeap(), 0, n * sizeof(WCHAR));
389 if (!tmp_account_name)
390 return E_OUTOFMEMORY;
391 lstrcpyW(tmp_account_name, pwszAccountName);
392 HeapFree(GetProcessHeap(), 0, This->accountName);
393 This->accountName = tmp_account_name;
394 return S_OK;
397 static HRESULT WINAPI MSTASK_ITask_GetAccountInformation(
398 ITask* iface,
399 LPWSTR *ppwszAccountName)
401 DWORD n;
402 TaskImpl *This = impl_from_ITask(iface);
404 TRACE("(%p, %p): partial stub\n", iface, ppwszAccountName);
406 /* This implements the WinXP behavior when accountName has not yet
407 * set. Win2K behaves differently, returning SCHED_E_CANNOT_OPEN_TASK */
408 if (!This->accountName)
409 return HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND);
411 n = (lstrlenW(This->accountName) + 1);
412 *ppwszAccountName = CoTaskMemAlloc(n * sizeof(WCHAR));
413 if (!*ppwszAccountName)
414 return E_OUTOFMEMORY;
415 lstrcpyW(*ppwszAccountName, This->accountName);
416 return S_OK;
419 static HRESULT WINAPI MSTASK_ITask_SetApplicationName(
420 ITask* iface,
421 LPCWSTR pwszApplicationName)
423 DWORD n;
424 TaskImpl *This = impl_from_ITask(iface);
425 LPWSTR tmp_name;
427 TRACE("(%p, %s)\n", iface, debugstr_w(pwszApplicationName));
429 /* Empty application name */
430 if (pwszApplicationName[0] == 0)
432 HeapFree(GetProcessHeap(), 0, This->applicationName);
433 This->applicationName = NULL;
434 return S_OK;
437 /* Attempt to set pwszApplicationName to a path resolved application name */
438 n = SearchPathW(NULL, pwszApplicationName, NULL, 0, NULL, NULL);
439 if (n)
441 tmp_name = HeapAlloc(GetProcessHeap(), 0, n * sizeof(WCHAR));
442 if (!tmp_name)
443 return E_OUTOFMEMORY;
444 n = SearchPathW(NULL, pwszApplicationName, NULL, n, tmp_name, NULL);
445 if (n)
447 HeapFree(GetProcessHeap(), 0, This->applicationName);
448 This->applicationName = tmp_name;
449 return S_OK;
451 else
452 HeapFree(GetProcessHeap(), 0, tmp_name);
455 /* If unable to path resolve name, simply set to pwszApplicationName */
456 n = (lstrlenW(pwszApplicationName) + 1);
457 tmp_name = HeapAlloc(GetProcessHeap(), 0, n * sizeof(WCHAR));
458 if (!tmp_name)
459 return E_OUTOFMEMORY;
460 lstrcpyW(tmp_name, pwszApplicationName);
461 HeapFree(GetProcessHeap(), 0, This->applicationName);
462 This->applicationName = tmp_name;
463 return S_OK;
466 static HRESULT WINAPI MSTASK_ITask_GetApplicationName(
467 ITask* iface,
468 LPWSTR *ppwszApplicationName)
470 DWORD n;
471 TaskImpl *This = impl_from_ITask(iface);
473 TRACE("(%p, %p)\n", iface, ppwszApplicationName);
475 n = This->applicationName ? lstrlenW(This->applicationName) + 1 : 1;
476 *ppwszApplicationName = CoTaskMemAlloc(n * sizeof(WCHAR));
477 if (!*ppwszApplicationName)
478 return E_OUTOFMEMORY;
480 if (!This->applicationName)
481 *ppwszApplicationName[0] = 0;
482 else
483 lstrcpyW(*ppwszApplicationName, This->applicationName);
485 return S_OK;
488 static HRESULT WINAPI MSTASK_ITask_SetParameters(
489 ITask* iface,
490 LPCWSTR pwszParameters)
492 DWORD n;
493 TaskImpl *This = impl_from_ITask(iface);
494 LPWSTR tmp_parameters;
496 TRACE("(%p, %s)\n", iface, debugstr_w(pwszParameters));
498 /* Empty parameter list */
499 if (pwszParameters[0] == 0)
501 HeapFree(GetProcessHeap(), 0, This->parameters);
502 This->parameters = NULL;
503 return S_OK;
506 /* Set to pwszParameters */
507 n = (lstrlenW(pwszParameters) + 1);
508 tmp_parameters = HeapAlloc(GetProcessHeap(), 0, n * sizeof(WCHAR));
509 if (!tmp_parameters)
510 return E_OUTOFMEMORY;
511 lstrcpyW(tmp_parameters, pwszParameters);
512 HeapFree(GetProcessHeap(), 0, This->parameters);
513 This->parameters = tmp_parameters;
514 return S_OK;
517 static HRESULT WINAPI MSTASK_ITask_GetParameters(
518 ITask* iface,
519 LPWSTR *ppwszParameters)
521 DWORD n;
522 TaskImpl *This = impl_from_ITask(iface);
524 TRACE("(%p, %p)\n", iface, ppwszParameters);
526 n = This->parameters ? lstrlenW(This->parameters) + 1 : 1;
527 *ppwszParameters = CoTaskMemAlloc(n * sizeof(WCHAR));
528 if (!*ppwszParameters)
529 return E_OUTOFMEMORY;
531 if (!This->parameters)
532 *ppwszParameters[0] = 0;
533 else
534 lstrcpyW(*ppwszParameters, This->parameters);
536 return S_OK;
539 static HRESULT WINAPI MSTASK_ITask_SetWorkingDirectory(
540 ITask* iface,
541 LPCWSTR pwszWorkingDirectory)
543 FIXME("(%p, %s): stub\n", iface, debugstr_w(pwszWorkingDirectory));
544 return E_NOTIMPL;
547 static HRESULT WINAPI MSTASK_ITask_GetWorkingDirectory(
548 ITask* iface,
549 LPWSTR *ppwszWorkingDirectory)
551 FIXME("(%p, %p): stub\n", iface, ppwszWorkingDirectory);
552 return E_NOTIMPL;
555 static HRESULT WINAPI MSTASK_ITask_SetPriority(
556 ITask* iface,
557 DWORD dwPriority)
559 FIXME("(%p, 0x%08x): stub\n", iface, dwPriority);
560 return E_NOTIMPL;
563 static HRESULT WINAPI MSTASK_ITask_GetPriority(
564 ITask* iface,
565 DWORD *pdwPriority)
567 FIXME("(%p, %p): stub\n", iface, pdwPriority);
568 return E_NOTIMPL;
571 static HRESULT WINAPI MSTASK_ITask_SetTaskFlags(
572 ITask* iface,
573 DWORD dwFlags)
575 FIXME("(%p, 0x%08x): stub\n", iface, dwFlags);
576 return E_NOTIMPL;
579 static HRESULT WINAPI MSTASK_ITask_GetTaskFlags(
580 ITask* iface,
581 DWORD *pdwFlags)
583 FIXME("(%p, %p): stub\n", iface, pdwFlags);
584 return E_NOTIMPL;
587 static HRESULT WINAPI MSTASK_ITask_SetMaxRunTime(
588 ITask* iface,
589 DWORD dwMaxRunTime)
591 TaskImpl *This = impl_from_ITask(iface);
593 TRACE("(%p, %d)\n", iface, dwMaxRunTime);
595 This->maxRunTime = dwMaxRunTime;
596 return S_OK;
599 static HRESULT WINAPI MSTASK_ITask_GetMaxRunTime(
600 ITask* iface,
601 DWORD *pdwMaxRunTime)
603 TaskImpl *This = impl_from_ITask(iface);
605 TRACE("(%p, %p)\n", iface, pdwMaxRunTime);
607 *pdwMaxRunTime = This->maxRunTime;
608 return S_OK;
611 static HRESULT WINAPI MSTASK_IPersistFile_QueryInterface(
612 IPersistFile* iface,
613 REFIID riid,
614 void **ppvObject)
616 TaskImpl *This = impl_from_IPersistFile(iface);
617 TRACE("(%p, %s, %p)\n", iface, debugstr_guid(riid), ppvObject);
618 return ITask_QueryInterface(&This->ITask_iface, riid, ppvObject);
621 static ULONG WINAPI MSTASK_IPersistFile_AddRef(
622 IPersistFile* iface)
624 TaskImpl *This = impl_from_IPersistFile(iface);
625 ULONG ref;
626 TRACE("\n");
627 ref = InterlockedIncrement(&This->ref);
628 return ref;
631 static ULONG WINAPI MSTASK_IPersistFile_Release(
632 IPersistFile* iface)
634 TaskImpl *This = impl_from_IPersistFile(iface);
635 ULONG ref;
636 TRACE("\n");
637 ref = InterlockedDecrement(&This->ref);
638 if (ref == 0)
639 TaskDestructor(This);
640 return ref;
643 static HRESULT WINAPI MSTASK_IPersistFile_GetClassID(
644 IPersistFile* iface,
645 CLSID *pClassID)
647 FIXME("(%p, %p): stub\n", iface, pClassID);
648 return E_NOTIMPL;
651 static HRESULT WINAPI MSTASK_IPersistFile_IsDirty(
652 IPersistFile* iface)
654 FIXME("(%p): stub\n", iface);
655 return E_NOTIMPL;
658 static HRESULT WINAPI MSTASK_IPersistFile_Load(
659 IPersistFile* iface,
660 LPCOLESTR pszFileName,
661 DWORD dwMode)
663 FIXME("(%p, %p, 0x%08x): stub\n", iface, pszFileName, dwMode);
664 return E_NOTIMPL;
667 static HRESULT WINAPI MSTASK_IPersistFile_Save(
668 IPersistFile* iface,
669 LPCOLESTR pszFileName,
670 BOOL fRemember)
672 FIXME("(%p, %p, %d): stub\n", iface, pszFileName, fRemember);
673 WARN("Returning S_OK but not writing to disk: %s %d\n",
674 debugstr_w(pszFileName), fRemember);
675 return S_OK;
678 static HRESULT WINAPI MSTASK_IPersistFile_SaveCompleted(
679 IPersistFile* iface,
680 LPCOLESTR pszFileName)
682 FIXME("(%p, %p): stub\n", iface, pszFileName);
683 return E_NOTIMPL;
686 static HRESULT WINAPI MSTASK_IPersistFile_GetCurFile(
687 IPersistFile* iface,
688 LPOLESTR *ppszFileName)
690 FIXME("(%p, %p): stub\n", iface, ppszFileName);
691 return E_NOTIMPL;
695 static const ITaskVtbl MSTASK_ITaskVtbl =
697 MSTASK_ITask_QueryInterface,
698 MSTASK_ITask_AddRef,
699 MSTASK_ITask_Release,
700 MSTASK_ITask_CreateTrigger,
701 MSTASK_ITask_DeleteTrigger,
702 MSTASK_ITask_GetTriggerCount,
703 MSTASK_ITask_GetTrigger,
704 MSTASK_ITask_GetTriggerString,
705 MSTASK_ITask_GetRunTimes,
706 MSTASK_ITask_GetNextRunTime,
707 MSTASK_ITask_SetIdleWait,
708 MSTASK_ITask_GetIdleWait,
709 MSTASK_ITask_Run,
710 MSTASK_ITask_Terminate,
711 MSTASK_ITask_EditWorkItem,
712 MSTASK_ITask_GetMostRecentRunTime,
713 MSTASK_ITask_GetStatus,
714 MSTASK_ITask_GetExitCode,
715 MSTASK_ITask_SetComment,
716 MSTASK_ITask_GetComment,
717 MSTASK_ITask_SetCreator,
718 MSTASK_ITask_GetCreator,
719 MSTASK_ITask_SetWorkItemData,
720 MSTASK_ITask_GetWorkItemData,
721 MSTASK_ITask_SetErrorRetryCount,
722 MSTASK_ITask_GetErrorRetryCount,
723 MSTASK_ITask_SetErrorRetryInterval,
724 MSTASK_ITask_GetErrorRetryInterval,
725 MSTASK_ITask_SetFlags,
726 MSTASK_ITask_GetFlags,
727 MSTASK_ITask_SetAccountInformation,
728 MSTASK_ITask_GetAccountInformation,
729 MSTASK_ITask_SetApplicationName,
730 MSTASK_ITask_GetApplicationName,
731 MSTASK_ITask_SetParameters,
732 MSTASK_ITask_GetParameters,
733 MSTASK_ITask_SetWorkingDirectory,
734 MSTASK_ITask_GetWorkingDirectory,
735 MSTASK_ITask_SetPriority,
736 MSTASK_ITask_GetPriority,
737 MSTASK_ITask_SetTaskFlags,
738 MSTASK_ITask_GetTaskFlags,
739 MSTASK_ITask_SetMaxRunTime,
740 MSTASK_ITask_GetMaxRunTime
743 static const IPersistFileVtbl MSTASK_IPersistFileVtbl =
745 MSTASK_IPersistFile_QueryInterface,
746 MSTASK_IPersistFile_AddRef,
747 MSTASK_IPersistFile_Release,
748 MSTASK_IPersistFile_GetClassID,
749 MSTASK_IPersistFile_IsDirty,
750 MSTASK_IPersistFile_Load,
751 MSTASK_IPersistFile_Save,
752 MSTASK_IPersistFile_SaveCompleted,
753 MSTASK_IPersistFile_GetCurFile
756 HRESULT TaskConstructor(LPCWSTR pwszTaskName, LPVOID *ppObj)
758 TaskImpl *This;
759 int n;
761 TRACE("(%s, %p)\n", debugstr_w(pwszTaskName), ppObj);
763 This = HeapAlloc(GetProcessHeap(), 0, sizeof(*This));
764 if (!This)
765 return E_OUTOFMEMORY;
767 This->ITask_iface.lpVtbl = &MSTASK_ITaskVtbl;
768 This->IPersistFile_iface.lpVtbl = &MSTASK_IPersistFileVtbl;
769 This->ref = 1;
770 n = (lstrlenW(pwszTaskName) + 1) * sizeof(WCHAR);
771 This->taskName = HeapAlloc(GetProcessHeap(), 0, n);
772 if (!This->taskName)
774 HeapFree(GetProcessHeap(), 0, This);
775 return E_OUTOFMEMORY;
777 lstrcpyW(This->taskName, pwszTaskName);
778 This->applicationName = NULL;
779 This->parameters = NULL;
780 This->comment = NULL;
781 This->accountName = NULL;
783 /* Default time is 3 days = 259200000 ms */
784 This->maxRunTime = 259200000;
786 *ppObj = &This->ITask_iface;
787 InterlockedIncrement(&dll_ref);
788 return S_OK;