Signed-off-by: Dmitry Timoshkov dmitry@baikal.ru --- dlls/mstask/task_scheduler.c | 23 ++++++++++++++++++----- dlls/mstask/tests/task_scheduler.c | 17 +++++++++++++---- 2 files changed, 31 insertions(+), 9 deletions(-)
diff --git a/dlls/mstask/task_scheduler.c b/dlls/mstask/task_scheduler.c index 42e773849c..416a3218d0 100644 --- a/dlls/mstask/task_scheduler.c +++ b/dlls/mstask/task_scheduler.c @@ -302,12 +302,25 @@ static HRESULT WINAPI MSTASK_ITaskScheduler_Activate(ITaskScheduler *iface, return hr; }
-static HRESULT WINAPI MSTASK_ITaskScheduler_Delete( - ITaskScheduler* iface, - LPCWSTR pwszName) +static HRESULT WINAPI MSTASK_ITaskScheduler_Delete(ITaskScheduler *iface, LPCWSTR name) { - FIXME("%p, %s: stub\n", iface, debugstr_w(pwszName)); - return E_NOTIMPL; + static const WCHAR tasksW[] = { '\','T','a','s','k','s','\',0 }; + static const WCHAR jobW[] = { '.','j','o','b',0 }; + WCHAR task_name[MAX_PATH]; + + TRACE("%p, %s\n", iface, debugstr_w(name)); + + if (strchrW(name, '.')) return E_INVALIDARG; + + GetWindowsDirectoryW(task_name, MAX_PATH); + lstrcatW(task_name, tasksW); + lstrcatW(task_name, name); + lstrcatW(task_name, jobW); + + if (!DeleteFileW(task_name)) + return HRESULT_FROM_WIN32(GetLastError()); + + return S_OK; }
static HRESULT WINAPI MSTASK_ITaskScheduler_NewWorkItem( diff --git a/dlls/mstask/tests/task_scheduler.c b/dlls/mstask/tests/task_scheduler.c index 8b93b56dce..d4766382ec 100644 --- a/dlls/mstask/tests/task_scheduler.c +++ b/dlls/mstask/tests/task_scheduler.c @@ -249,7 +249,7 @@ static void test_save_task_curfile(ITask *task) curfile = NULL; hr = IPersistFile_GetCurFile(pfile, &curfile); ok(hr == S_OK, "GetCurFile error %#x\n", hr); - ok(curfile && curfile[0] , "curfile should not be NULL\n"); + ok(curfile && curfile[0], "curfile should not be NULL\n");
ok(file_exists(curfile), "curfile should exist\n");
@@ -343,6 +343,12 @@ static void test_task_storage(void) return; }
+ hr = ITaskScheduler_Delete(scheduler, Task1_ext); + ok(hr == E_INVALIDARG, "wrong error %#x\n", hr); + + hr = ITaskScheduler_Delete(scheduler, Task1); + ok(hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND), "wrong error %#x\n", hr); + hr = ITaskScheduler_NewWorkItem(scheduler, Task1_ext, &CLSID_CTask, &IID_ITask, (IUnknown **)&task); ok(hr == E_INVALIDARG, "wrong error %#x\n", hr);
@@ -418,9 +424,12 @@ static void test_task_storage(void)
test_save_task_curfile(task);
- DeleteFileW(task1_full_name); - DeleteFileW(task2_full_name); - DeleteFileW(task3_full_name); + hr = ITaskScheduler_Delete(scheduler, Task1); + ok(hr == S_OK, "got %#x\n", hr); + hr = ITaskScheduler_Delete(scheduler, Task2); + ok(hr == S_OK, "got %#x\n", hr); + hr = ITaskScheduler_Delete(scheduler, Task3); + ok(hr == S_OK, "got %#x\n", hr);
ITask_Release(task); ITaskScheduler_Release(scheduler);