user32: Update the Polish translation.
[wine/multimedia.git] / dlls / mstask / task.c
blob3815b19747fd93f1e0fd8f47671ef8f08e805f65
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 static inline TaskImpl *impl_from_IPersistFile( IPersistFile *iface )
26 return (TaskImpl*) ((char*)(iface) - FIELD_OFFSET(TaskImpl, persistVtbl));
29 static void TaskDestructor(TaskImpl *This)
31 TRACE("%p\n", This);
32 HeapFree(GetProcessHeap(), 0, This->accountName);
33 HeapFree(GetProcessHeap(), 0, This->comment);
34 HeapFree(GetProcessHeap(), 0, This->parameters);
35 HeapFree(GetProcessHeap(), 0, This->taskName);
36 HeapFree(GetProcessHeap(), 0, This);
37 InterlockedDecrement(&dll_ref);
40 static HRESULT WINAPI MSTASK_ITask_QueryInterface(
41 ITask* iface,
42 REFIID riid,
43 void **ppvObject)
45 TaskImpl * This = (TaskImpl *)iface;
47 TRACE("IID: %s\n", debugstr_guid(riid));
48 if (ppvObject == NULL)
49 return E_POINTER;
51 if (IsEqualGUID(riid, &IID_IUnknown) ||
52 IsEqualGUID(riid, &IID_ITask))
54 *ppvObject = &This->lpVtbl;
55 ITask_AddRef(iface);
56 return S_OK;
58 else if (IsEqualGUID(riid, &IID_IPersistFile))
60 *ppvObject = &This->persistVtbl;
61 ITask_AddRef(iface);
62 return S_OK;
65 WARN("Unknown interface: %s\n", debugstr_guid(riid));
66 *ppvObject = NULL;
67 return E_NOINTERFACE;
70 static ULONG WINAPI MSTASK_ITask_AddRef(
71 ITask* iface)
73 TaskImpl *This = (TaskImpl *)iface;
74 ULONG ref;
75 TRACE("\n");
76 ref = InterlockedIncrement(&This->ref);
77 return ref;
80 static ULONG WINAPI MSTASK_ITask_Release(
81 ITask* iface)
83 TaskImpl * This = (TaskImpl *)iface;
84 ULONG ref;
85 TRACE("\n");
86 ref = InterlockedDecrement(&This->ref);
87 if (ref == 0)
88 TaskDestructor(This);
89 return ref;
92 static HRESULT WINAPI MSTASK_ITask_CreateTrigger(
93 ITask* iface,
94 WORD *piNewTrigger,
95 ITaskTrigger **ppTrigger)
97 TRACE("(%p, %p, %p)\n", iface, piNewTrigger, ppTrigger);
98 return TaskTriggerConstructor((LPVOID *)ppTrigger);
101 static HRESULT WINAPI MSTASK_ITask_DeleteTrigger(
102 ITask* iface,
103 WORD iTrigger)
105 FIXME("(%p, %d): stub\n", iface, iTrigger);
106 return E_NOTIMPL;
109 static HRESULT WINAPI MSTASK_ITask_GetTriggerCount(
110 ITask* iface,
111 WORD *plCount)
113 FIXME("(%p, %p): stub\n", iface, plCount);
114 return E_NOTIMPL;
117 static HRESULT WINAPI MSTASK_ITask_GetTrigger(
118 ITask* iface,
119 WORD iTrigger,
120 ITaskTrigger **ppTrigger)
122 FIXME("(%p, %d, %p): stub\n", iface, iTrigger, ppTrigger);
123 return E_NOTIMPL;
126 static HRESULT WINAPI MSTASK_ITask_GetTriggerString(
127 ITask* iface,
128 WORD iTrigger,
129 LPWSTR *ppwszTrigger)
131 FIXME("(%p, %d, %p): stub\n", iface, iTrigger, ppwszTrigger);
132 return E_NOTIMPL;
135 static HRESULT WINAPI MSTASK_ITask_GetRunTimes(
136 ITask* iface,
137 const LPSYSTEMTIME pstBegin,
138 const LPSYSTEMTIME pstEnd,
139 WORD *pCount,
140 LPSYSTEMTIME *rgstTaskTimes)
142 FIXME("(%p, %p, %p, %p, %p): stub\n", iface, pstBegin, pstEnd, pCount,
143 rgstTaskTimes);
144 return E_NOTIMPL;
147 static HRESULT WINAPI MSTASK_ITask_GetNextRunTime(
148 ITask* iface,
149 SYSTEMTIME *pstNextRun)
151 FIXME("(%p, %p): stub\n", iface, pstNextRun);
152 return E_NOTIMPL;
155 static HRESULT WINAPI MSTASK_ITask_SetIdleWait(
156 ITask* iface,
157 WORD wIdleMinutes,
158 WORD wDeadlineMinutes)
160 FIXME("(%p, %d, %d): stub\n", iface, wIdleMinutes, wDeadlineMinutes);
161 return E_NOTIMPL;
164 static HRESULT WINAPI MSTASK_ITask_GetIdleWait(
165 ITask* iface,
166 WORD *pwIdleMinutes,
167 WORD *pwDeadlineMinutes)
169 FIXME("(%p, %p, %p): stub\n", iface, pwIdleMinutes, pwDeadlineMinutes);
170 return E_NOTIMPL;
173 static HRESULT WINAPI MSTASK_ITask_Run(
174 ITask* iface)
176 FIXME("(%p): stub\n", iface);
177 return E_NOTIMPL;
180 static HRESULT WINAPI MSTASK_ITask_Terminate(
181 ITask* iface)
183 FIXME("(%p): stub\n", iface);
184 return E_NOTIMPL;
187 static HRESULT WINAPI MSTASK_ITask_EditWorkItem(
188 ITask* iface,
189 HWND hParent,
190 DWORD dwReserved)
192 FIXME("(%p, %p, %d): stub\n", iface, hParent, dwReserved);
193 return E_NOTIMPL;
196 static HRESULT WINAPI MSTASK_ITask_GetMostRecentRunTime(
197 ITask* iface,
198 SYSTEMTIME *pstLastRun)
200 FIXME("(%p, %p): stub\n", iface, pstLastRun);
201 return E_NOTIMPL;
204 static HRESULT WINAPI MSTASK_ITask_GetStatus(
205 ITask* iface,
206 HRESULT *phrStatus)
208 FIXME("(%p, %p): stub\n", iface, phrStatus);
209 return E_NOTIMPL;
212 static HRESULT WINAPI MSTASK_ITask_GetExitCode(
213 ITask* iface,
214 DWORD *pdwExitCode)
216 FIXME("(%p, %p): stub\n", iface, pdwExitCode);
217 return E_NOTIMPL;
220 static HRESULT WINAPI MSTASK_ITask_SetComment(
221 ITask* iface,
222 LPCWSTR pwszComment)
224 DWORD n;
225 TaskImpl *This = (TaskImpl *)iface;
226 LPWSTR tmp_comment;
228 TRACE("(%p, %s)\n", iface, debugstr_w(pwszComment));
230 /* Empty comment */
231 if (pwszComment[0] == 0)
233 HeapFree(GetProcessHeap(), 0, This->comment);
234 This->comment = NULL;
235 return S_OK;
238 /* Set to pwszComment */
239 n = (lstrlenW(pwszComment) + 1);
240 tmp_comment = HeapAlloc(GetProcessHeap(), 0, n * sizeof(WCHAR));
241 if (!tmp_comment)
242 return E_OUTOFMEMORY;
243 lstrcpyW(tmp_comment, pwszComment);
244 HeapFree(GetProcessHeap(), 0, This->comment);
245 This->comment = tmp_comment;
247 return S_OK;
250 static HRESULT WINAPI MSTASK_ITask_GetComment(
251 ITask* iface,
252 LPWSTR *ppwszComment)
254 DWORD n;
255 TaskImpl *This = (TaskImpl *)iface;
257 TRACE("(%p, %p)\n", iface, ppwszComment);
259 n = This->comment ? lstrlenW(This->comment) + 1 : 1;
260 *ppwszComment = CoTaskMemAlloc(n * sizeof(WCHAR));
261 if (!*ppwszComment)
262 return E_OUTOFMEMORY;
264 if (!This->comment)
265 *ppwszComment[0] = 0;
266 else
267 lstrcpyW(*ppwszComment, This->comment);
269 return S_OK;
272 static HRESULT WINAPI MSTASK_ITask_SetCreator(
273 ITask* iface,
274 LPCWSTR pwszCreator)
276 FIXME("(%p, %p): stub\n", iface, pwszCreator);
277 return E_NOTIMPL;
280 static HRESULT WINAPI MSTASK_ITask_GetCreator(
281 ITask* iface,
282 LPWSTR *ppwszCreator)
284 FIXME("(%p, %p): stub\n", iface, ppwszCreator);
285 return E_NOTIMPL;
288 static HRESULT WINAPI MSTASK_ITask_SetWorkItemData(
289 ITask* iface,
290 WORD cBytes,
291 BYTE rgbData[])
293 FIXME("(%p, %d, %p): stub\n", iface, cBytes, rgbData);
294 return E_NOTIMPL;
297 static HRESULT WINAPI MSTASK_ITask_GetWorkItemData(
298 ITask* iface,
299 WORD *pcBytes,
300 BYTE **ppBytes)
302 FIXME("(%p, %p, %p): stub\n", iface, pcBytes, ppBytes);
303 return E_NOTIMPL;
306 static HRESULT WINAPI MSTASK_ITask_SetErrorRetryCount(
307 ITask* iface,
308 WORD wRetryCount)
310 FIXME("(%p, %d): stub\n", iface, wRetryCount);
311 return E_NOTIMPL;
314 static HRESULT WINAPI MSTASK_ITask_GetErrorRetryCount(
315 ITask* iface,
316 WORD *pwRetryCount)
318 FIXME("(%p, %p): stub\n", iface, pwRetryCount);
319 return E_NOTIMPL;
322 static HRESULT WINAPI MSTASK_ITask_SetErrorRetryInterval(
323 ITask* iface,
324 WORD wRetryInterval)
326 FIXME("(%p, %d): stub\n", iface, wRetryInterval);
327 return E_NOTIMPL;
330 static HRESULT WINAPI MSTASK_ITask_GetErrorRetryInterval(
331 ITask* iface,
332 WORD *pwRetryInterval)
334 FIXME("(%p, %p): stub\n", iface, pwRetryInterval);
335 return E_NOTIMPL;
338 static HRESULT WINAPI MSTASK_ITask_SetFlags(
339 ITask* iface,
340 DWORD dwFlags)
342 FIXME("(%p, 0x%08x): stub\n", iface, dwFlags);
343 return E_NOTIMPL;
346 static HRESULT WINAPI MSTASK_ITask_GetFlags(
347 ITask* iface,
348 DWORD *pdwFlags)
350 FIXME("(%p, %p): stub\n", iface, pdwFlags);
351 return E_NOTIMPL;
354 static HRESULT WINAPI MSTASK_ITask_SetAccountInformation(
355 ITask* iface,
356 LPCWSTR pwszAccountName,
357 LPCWSTR pwszPassword)
359 DWORD n;
360 TaskImpl *This = (TaskImpl *)iface;
361 LPWSTR tmp_account_name;
363 TRACE("(%p, %s, %s): partial stub\n", iface, debugstr_w(pwszAccountName),
364 debugstr_w(pwszPassword));
366 if (pwszPassword)
367 FIXME("Partial stub ignores passwords\n");
369 n = (lstrlenW(pwszAccountName) + 1);
370 tmp_account_name = HeapAlloc(GetProcessHeap(), 0, n * sizeof(WCHAR));
371 if (!tmp_account_name)
372 return E_OUTOFMEMORY;
373 lstrcpyW(tmp_account_name, pwszAccountName);
374 HeapFree(GetProcessHeap(), 0, This->accountName);
375 This->accountName = tmp_account_name;
376 return S_OK;
379 static HRESULT WINAPI MSTASK_ITask_GetAccountInformation(
380 ITask* iface,
381 LPWSTR *ppwszAccountName)
383 DWORD n;
384 TaskImpl *This = (TaskImpl *)iface;
386 TRACE("(%p, %p): partial stub\n", iface, ppwszAccountName);
388 /* This implements the WinXP behavior when accountName has not yet
389 * set. Win2K behaves differently, returning SCHED_E_CANNOT_OPEN_TASK */
390 if (!This->accountName)
391 return HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND);
393 n = (lstrlenW(This->accountName) + 1);
394 *ppwszAccountName = CoTaskMemAlloc(n * sizeof(WCHAR));
395 if (!*ppwszAccountName)
396 return E_OUTOFMEMORY;
397 lstrcpyW(*ppwszAccountName, This->accountName);
398 return S_OK;
401 static HRESULT WINAPI MSTASK_ITask_SetApplicationName(
402 ITask* iface,
403 LPCWSTR pwszApplicationName)
405 DWORD n;
406 TaskImpl *This = (TaskImpl *)iface;
407 LPWSTR tmp_name;
409 TRACE("(%p, %s)\n", iface, debugstr_w(pwszApplicationName));
411 /* Empty application name */
412 if (pwszApplicationName[0] == 0)
414 HeapFree(GetProcessHeap(), 0, This->applicationName);
415 This->applicationName = NULL;
416 return S_OK;
419 /* Attempt to set pwszApplicationName to a path resolved application name */
420 n = SearchPathW(NULL, pwszApplicationName, NULL, 0, NULL, NULL);
421 if (n)
423 tmp_name = HeapAlloc(GetProcessHeap(), 0, n * sizeof(WCHAR));
424 if (!tmp_name)
425 return E_OUTOFMEMORY;
426 n = SearchPathW(NULL, pwszApplicationName, NULL, n, tmp_name, NULL);
427 if (n)
429 HeapFree(GetProcessHeap(), 0, This->applicationName);
430 This->applicationName = tmp_name;
431 return S_OK;
433 else
434 HeapFree(GetProcessHeap(), 0, tmp_name);
437 /* If unable to path resolve name, simply set to pwszApplicationName */
438 n = (lstrlenW(pwszApplicationName) + 1);
439 tmp_name = HeapAlloc(GetProcessHeap(), 0, n * sizeof(WCHAR));
440 if (!tmp_name)
441 return E_OUTOFMEMORY;
442 lstrcpyW(tmp_name, pwszApplicationName);
443 HeapFree(GetProcessHeap(), 0, This->applicationName);
444 This->applicationName = tmp_name;
445 return S_OK;
448 static HRESULT WINAPI MSTASK_ITask_GetApplicationName(
449 ITask* iface,
450 LPWSTR *ppwszApplicationName)
452 DWORD n;
453 TaskImpl *This = (TaskImpl *)iface;
455 TRACE("(%p, %p)\n", iface, ppwszApplicationName);
457 n = This->applicationName ? lstrlenW(This->applicationName) + 1 : 1;
458 *ppwszApplicationName = CoTaskMemAlloc(n * sizeof(WCHAR));
459 if (!*ppwszApplicationName)
460 return E_OUTOFMEMORY;
462 if (!This->applicationName)
463 *ppwszApplicationName[0] = 0;
464 else
465 lstrcpyW(*ppwszApplicationName, This->applicationName);
467 return S_OK;
470 static HRESULT WINAPI MSTASK_ITask_SetParameters(
471 ITask* iface,
472 LPCWSTR pwszParameters)
474 DWORD n;
475 TaskImpl *This = (TaskImpl *)iface;
476 LPWSTR tmp_parameters;
478 TRACE("(%p, %s)\n", iface, debugstr_w(pwszParameters));
480 /* Empty parameter list */
481 if (pwszParameters[0] == 0)
483 HeapFree(GetProcessHeap(), 0, This->parameters);
484 This->parameters = NULL;
485 return S_OK;
488 /* Set to pwszParameters */
489 n = (lstrlenW(pwszParameters) + 1);
490 tmp_parameters = HeapAlloc(GetProcessHeap(), 0, n * sizeof(WCHAR));
491 if (!tmp_parameters)
492 return E_OUTOFMEMORY;
493 lstrcpyW(tmp_parameters, pwszParameters);
494 HeapFree(GetProcessHeap(), 0, This->parameters);
495 This->parameters = tmp_parameters;
496 return S_OK;
499 static HRESULT WINAPI MSTASK_ITask_GetParameters(
500 ITask* iface,
501 LPWSTR *ppwszParameters)
503 DWORD n;
504 TaskImpl *This = (TaskImpl *)iface;
506 TRACE("(%p, %p)\n", iface, ppwszParameters);
508 n = This->parameters ? lstrlenW(This->parameters) + 1 : 1;
509 *ppwszParameters = CoTaskMemAlloc(n * sizeof(WCHAR));
510 if (!*ppwszParameters)
511 return E_OUTOFMEMORY;
513 if (!This->parameters)
514 *ppwszParameters[0] = 0;
515 else
516 lstrcpyW(*ppwszParameters, This->parameters);
518 return S_OK;
521 static HRESULT WINAPI MSTASK_ITask_SetWorkingDirectory(
522 ITask* iface,
523 LPCWSTR pwszWorkingDirectory)
525 FIXME("(%p, %s): stub\n", iface, debugstr_w(pwszWorkingDirectory));
526 return E_NOTIMPL;
529 static HRESULT WINAPI MSTASK_ITask_GetWorkingDirectory(
530 ITask* iface,
531 LPWSTR *ppwszWorkingDirectory)
533 FIXME("(%p, %p): stub\n", iface, ppwszWorkingDirectory);
534 return E_NOTIMPL;
537 static HRESULT WINAPI MSTASK_ITask_SetPriority(
538 ITask* iface,
539 DWORD dwPriority)
541 FIXME("(%p, 0x%08x): stub\n", iface, dwPriority);
542 return E_NOTIMPL;
545 static HRESULT WINAPI MSTASK_ITask_GetPriority(
546 ITask* iface,
547 DWORD *pdwPriority)
549 FIXME("(%p, %p): stub\n", iface, pdwPriority);
550 return E_NOTIMPL;
553 static HRESULT WINAPI MSTASK_ITask_SetTaskFlags(
554 ITask* iface,
555 DWORD dwFlags)
557 FIXME("(%p, 0x%08x): stub\n", iface, dwFlags);
558 return E_NOTIMPL;
561 static HRESULT WINAPI MSTASK_ITask_GetTaskFlags(
562 ITask* iface,
563 DWORD *pdwFlags)
565 FIXME("(%p, %p): stub\n", iface, pdwFlags);
566 return E_NOTIMPL;
569 static HRESULT WINAPI MSTASK_ITask_SetMaxRunTime(
570 ITask* iface,
571 DWORD dwMaxRunTime)
573 TaskImpl *This = (TaskImpl *)iface;
575 TRACE("(%p, %d)\n", iface, dwMaxRunTime);
577 This->maxRunTime = dwMaxRunTime;
578 return S_OK;
581 static HRESULT WINAPI MSTASK_ITask_GetMaxRunTime(
582 ITask* iface,
583 DWORD *pdwMaxRunTime)
585 TaskImpl *This = (TaskImpl *)iface;
587 TRACE("(%p, %p)\n", iface, pdwMaxRunTime);
589 *pdwMaxRunTime = This->maxRunTime;
590 return S_OK;
593 static HRESULT WINAPI MSTASK_IPersistFile_QueryInterface(
594 IPersistFile* iface,
595 REFIID riid,
596 void **ppvObject)
598 TaskImpl *This = impl_from_IPersistFile(iface);
599 TRACE("(%p, %s, %p)\n", iface, debugstr_guid(riid), ppvObject);
600 return ITask_QueryInterface((ITask *) This, riid, ppvObject);
603 static ULONG WINAPI MSTASK_IPersistFile_AddRef(
604 IPersistFile* iface)
606 TaskImpl *This = impl_from_IPersistFile(iface);
607 ULONG ref;
608 TRACE("\n");
609 ref = InterlockedIncrement(&This->ref);
610 return ref;
613 static ULONG WINAPI MSTASK_IPersistFile_Release(
614 IPersistFile* iface)
616 TaskImpl *This = impl_from_IPersistFile(iface);
617 ULONG ref;
618 TRACE("\n");
619 ref = InterlockedDecrement(&This->ref);
620 if (ref == 0)
621 TaskDestructor(This);
622 return ref;
625 static HRESULT WINAPI MSTASK_IPersistFile_GetClassID(
626 IPersistFile* iface,
627 CLSID *pClassID)
629 FIXME("(%p, %p): stub\n", iface, pClassID);
630 return E_NOTIMPL;
633 static HRESULT WINAPI MSTASK_IPersistFile_IsDirty(
634 IPersistFile* iface)
636 FIXME("(%p): stub\n", iface);
637 return E_NOTIMPL;
640 static HRESULT WINAPI MSTASK_IPersistFile_Load(
641 IPersistFile* iface,
642 LPCOLESTR pszFileName,
643 DWORD dwMode)
645 FIXME("(%p, %p, 0x%08x): stub\n", iface, pszFileName, dwMode);
646 return E_NOTIMPL;
649 static HRESULT WINAPI MSTASK_IPersistFile_Save(
650 IPersistFile* iface,
651 LPCOLESTR pszFileName,
652 BOOL fRemember)
654 FIXME("(%p, %p, %d): stub\n", iface, pszFileName, fRemember);
655 WARN("Returning S_OK but not writing to disk: %s %d\n",
656 debugstr_w(pszFileName), fRemember);
657 return S_OK;
660 static HRESULT WINAPI MSTASK_IPersistFile_SaveCompleted(
661 IPersistFile* iface,
662 LPCOLESTR pszFileName)
664 FIXME("(%p, %p): stub\n", iface, pszFileName);
665 return E_NOTIMPL;
668 static HRESULT WINAPI MSTASK_IPersistFile_GetCurFile(
669 IPersistFile* iface,
670 LPOLESTR *ppszFileName)
672 FIXME("(%p, %p): stub\n", iface, ppszFileName);
673 return E_NOTIMPL;
677 static const ITaskVtbl MSTASK_ITaskVtbl =
679 MSTASK_ITask_QueryInterface,
680 MSTASK_ITask_AddRef,
681 MSTASK_ITask_Release,
682 MSTASK_ITask_CreateTrigger,
683 MSTASK_ITask_DeleteTrigger,
684 MSTASK_ITask_GetTriggerCount,
685 MSTASK_ITask_GetTrigger,
686 MSTASK_ITask_GetTriggerString,
687 MSTASK_ITask_GetRunTimes,
688 MSTASK_ITask_GetNextRunTime,
689 MSTASK_ITask_SetIdleWait,
690 MSTASK_ITask_GetIdleWait,
691 MSTASK_ITask_Run,
692 MSTASK_ITask_Terminate,
693 MSTASK_ITask_EditWorkItem,
694 MSTASK_ITask_GetMostRecentRunTime,
695 MSTASK_ITask_GetStatus,
696 MSTASK_ITask_GetExitCode,
697 MSTASK_ITask_SetComment,
698 MSTASK_ITask_GetComment,
699 MSTASK_ITask_SetCreator,
700 MSTASK_ITask_GetCreator,
701 MSTASK_ITask_SetWorkItemData,
702 MSTASK_ITask_GetWorkItemData,
703 MSTASK_ITask_SetErrorRetryCount,
704 MSTASK_ITask_GetErrorRetryCount,
705 MSTASK_ITask_SetErrorRetryInterval,
706 MSTASK_ITask_GetErrorRetryInterval,
707 MSTASK_ITask_SetFlags,
708 MSTASK_ITask_GetFlags,
709 MSTASK_ITask_SetAccountInformation,
710 MSTASK_ITask_GetAccountInformation,
711 MSTASK_ITask_SetApplicationName,
712 MSTASK_ITask_GetApplicationName,
713 MSTASK_ITask_SetParameters,
714 MSTASK_ITask_GetParameters,
715 MSTASK_ITask_SetWorkingDirectory,
716 MSTASK_ITask_GetWorkingDirectory,
717 MSTASK_ITask_SetPriority,
718 MSTASK_ITask_GetPriority,
719 MSTASK_ITask_SetTaskFlags,
720 MSTASK_ITask_GetTaskFlags,
721 MSTASK_ITask_SetMaxRunTime,
722 MSTASK_ITask_GetMaxRunTime
725 static const IPersistFileVtbl MSTASK_IPersistFileVtbl =
727 MSTASK_IPersistFile_QueryInterface,
728 MSTASK_IPersistFile_AddRef,
729 MSTASK_IPersistFile_Release,
730 MSTASK_IPersistFile_GetClassID,
731 MSTASK_IPersistFile_IsDirty,
732 MSTASK_IPersistFile_Load,
733 MSTASK_IPersistFile_Save,
734 MSTASK_IPersistFile_SaveCompleted,
735 MSTASK_IPersistFile_GetCurFile
738 HRESULT TaskConstructor(LPCWSTR pwszTaskName, LPVOID *ppObj)
740 TaskImpl *This;
741 int n;
743 TRACE("(%s, %p)\n", debugstr_w(pwszTaskName), ppObj);
745 This = HeapAlloc(GetProcessHeap(), 0, sizeof(*This));
746 if (!This)
747 return E_OUTOFMEMORY;
749 This->lpVtbl = &MSTASK_ITaskVtbl;
750 This->persistVtbl = &MSTASK_IPersistFileVtbl;
751 This->ref = 1;
752 n = (lstrlenW(pwszTaskName) + 1) * sizeof(WCHAR);
753 This->taskName = HeapAlloc(GetProcessHeap(), 0, n);
754 if (!This->taskName)
756 HeapFree(GetProcessHeap(), 0, This);
757 return E_OUTOFMEMORY;
759 lstrcpyW(This->taskName, pwszTaskName);
760 This->applicationName = NULL;
761 This->parameters = NULL;
762 This->comment = NULL;
763 This->accountName = NULL;
765 /* Default time is 3 days = 259200000 ms */
766 This->maxRunTime = 259200000;
768 *ppObj = &This->lpVtbl;
769 InterlockedIncrement(&dll_ref);
770 return S_OK;