mstask: Implemented (Set|Get)ApplicationName.
diff --git a/dlls/mstask/Makefile.in b/dlls/mstask/Makefile.in
index 9fb78ee..31d2eca 100644
--- a/dlls/mstask/Makefile.in
+++ b/dlls/mstask/Makefile.in
@@ -3,7 +3,7 @@
SRCDIR = @srcdir@
VPATH = @srcdir@
MODULE = mstask.dll
-IMPORTS = uuid kernel32
+IMPORTS = uuid ole32 kernel32
C_SRCS = \
factory.c \
diff --git a/dlls/mstask/mstask_private.h b/dlls/mstask/mstask_private.h
index e5de0dc..b0892fe 100644
--- a/dlls/mstask/mstask_private.h
+++ b/dlls/mstask/mstask_private.h
@@ -58,6 +58,7 @@
const IPersistFileVtbl *persistVtbl;
LONG ref;
LPWSTR taskName;
+ LPWSTR applicationName;
} TaskImpl;
extern HRESULT TaskConstructor(LPCWSTR pwszTaskName, LPVOID *ppObj);
diff --git a/dlls/mstask/task.c b/dlls/mstask/task.c
index 8a24b87..f1f5426 100644
--- a/dlls/mstask/task.c
+++ b/dlls/mstask/task.c
@@ -323,16 +323,69 @@
ITask* iface,
LPCWSTR pwszApplicationName)
{
- FIXME("(%p, %s): stub\n", iface, debugstr_w(pwszApplicationName));
- return E_NOTIMPL;
+ DWORD n;
+ TaskImpl *This = (TaskImpl *)iface;
+ LPWSTR tmp_name;
+
+ TRACE("(%p, %s)\n", iface, debugstr_w(pwszApplicationName));
+
+ /* Empty application name */
+ if (pwszApplicationName[0] == 0)
+ {
+ HeapFree(GetProcessHeap(), 0, This->applicationName);
+ This->applicationName = NULL;
+ return S_OK;
+ }
+
+ /* Attempt to set pwszApplicationName to a path resolved application name */
+ n = SearchPathW(NULL, pwszApplicationName, NULL, 0, NULL, NULL);
+ if (n)
+ {
+ tmp_name = HeapAlloc(GetProcessHeap(), 0, n * sizeof(WCHAR));
+ if (!tmp_name)
+ return E_OUTOFMEMORY;
+ n = SearchPathW(NULL, pwszApplicationName, NULL, n, tmp_name, NULL);
+ if (n)
+ {
+ HeapFree(GetProcessHeap(), 0, This->applicationName);
+ This->applicationName = tmp_name;
+ return S_OK;
+ }
+ else
+ HeapFree(GetProcessHeap(), 0, tmp_name);
+ }
+
+ /* If unable to path resolve name, simply set to pwszApplicationName */
+ n = (lstrlenW(pwszApplicationName) + 1);
+ tmp_name = HeapAlloc(GetProcessHeap(), 0, n * sizeof(WCHAR));
+ if (!tmp_name)
+ return E_OUTOFMEMORY;
+ lstrcpyW(tmp_name, pwszApplicationName);
+ HeapFree(GetProcessHeap(), 0, This->applicationName);
+ This->applicationName = tmp_name;
+ return S_OK;
}
static HRESULT WINAPI MSTASK_ITask_GetApplicationName(
ITask* iface,
LPWSTR *ppwszApplicationName)
{
- FIXME("(%p, %p): stub\n", iface, ppwszApplicationName);
- return E_NOTIMPL;
+ DWORD n;
+ TaskImpl *This = (TaskImpl *)iface;
+
+ TRACE("(%p, %p)\n", iface, ppwszApplicationName);
+
+ n = This->applicationName ? lstrlenW(This->applicationName) + 1 : 1;
+ *ppwszApplicationName = CoTaskMemAlloc(n * sizeof(WCHAR));
+ if (!*ppwszApplicationName)
+ return E_OUTOFMEMORY;
+
+ if (!This->applicationName)
+ *ppwszApplicationName[0] = 0;
+ else
+ lstrcpyW(*ppwszApplicationName, This->applicationName);
+
+ return S_OK;
}
static HRESULT WINAPI MSTASK_ITask_SetParameters(
@@ -571,6 +624,7 @@
return E_OUTOFMEMORY;
}
lstrcpyW(This->taskName, pwszTaskName);
+ This->applicationName = NULL;
*ppObj = &This->lpVtbl;
InterlockedIncrement(&dll_ref);
diff --git a/dlls/mstask/tests/task.c b/dlls/mstask/tests/task.c
index 7e9e831..ff35f52 100644
--- a/dlls/mstask/tests/task.c
+++ b/dlls/mstask/tests/task.c
@@ -118,10 +118,10 @@
/* Attempt getting before setting application name */
hres = ITask_GetApplicationName(test_task, &stored_name);
- todo_wine ok(hres == S_OK, "GetApplicationName failed: %08x\n", hres);
+ ok(hres == S_OK, "GetApplicationName failed: %08x\n", hres);
if (hres == S_OK)
{
- todo_wine ok(!lstrcmpW(stored_name, empty),
+ ok(!lstrcmpW(stored_name, empty),
"Got %s, expected empty string\n", dbgstr_w(stored_name));
CoTaskMemFree(stored_name);
}
@@ -129,14 +129,14 @@
/* Set application name to a non-existent application and then get
* the application name that is actually stored */
hres = ITask_SetApplicationName(test_task, non_application_name);
- todo_wine ok(hres == S_OK, "Failed setting name %s: %08x\n",
+ ok(hres == S_OK, "Failed setting name %s: %08x\n",
dbgstr_w(non_application_name), hres);
hres = ITask_GetApplicationName(test_task, &stored_name);
- todo_wine ok(hres == S_OK, "GetApplicationName failed: %08x\n", hres);
+ ok(hres == S_OK, "GetApplicationName failed: %08x\n", hres);
if (hres == S_OK)
{
full_name = path_resolve_name(non_application_name);
- todo_wine ok(!lstrcmpW(stored_name, full_name), "Got %s, expected %s\n",
+ ok(!lstrcmpW(stored_name, full_name), "Got %s, expected %s\n",
dbgstr_w(stored_name), dbgstr_w(full_name));
CoTaskMemFree(stored_name);
}
@@ -144,14 +144,14 @@
/* Set a valid application name with program type extension and then
* get the stored name */
hres = ITask_SetApplicationName(test_task, notepad_exe);
- todo_wine ok(hres == S_OK, "Failed setting name %s: %08x\n",
+ ok(hres == S_OK, "Failed setting name %s: %08x\n",
dbgstr_w(notepad_exe), hres);
hres = ITask_GetApplicationName(test_task, &stored_name);
- todo_wine ok(hres == S_OK, "GetApplicationName failed: %08x\n", hres);
+ ok(hres == S_OK, "GetApplicationName failed: %08x\n", hres);
if (hres == S_OK)
{
full_name = path_resolve_name(notepad_exe);
- todo_wine ok(!lstrcmpW(stored_name, full_name), "Got %s, expected %s\n",
+ ok(!lstrcmpW(stored_name, full_name), "Got %s, expected %s\n",
dbgstr_w(stored_name), dbgstr_w(full_name));
CoTaskMemFree(stored_name);
}
@@ -159,13 +159,13 @@
/* Set a valid application name without program type extension and
* then get the stored name */
hres = ITask_SetApplicationName(test_task, notepad);
- todo_wine ok(hres == S_OK, "Failed setting name %s: %08x\n", dbgstr_w(notepad), hres);
+ ok(hres == S_OK, "Failed setting name %s: %08x\n", dbgstr_w(notepad), hres);
hres = ITask_GetApplicationName(test_task, &stored_name);
- todo_wine ok(hres == S_OK, "GetApplicationName failed: %08x\n", hres);
+ ok(hres == S_OK, "GetApplicationName failed: %08x\n", hres);
if (hres == S_OK)
{
full_name = path_resolve_name(notepad);
- todo_wine ok(!lstrcmpW(stored_name, full_name), "Got %s, expected %s\n",
+ ok(!lstrcmpW(stored_name, full_name), "Got %s, expected %s\n",
dbgstr_w(stored_name), dbgstr_w(full_name));
CoTaskMemFree(stored_name);
}
@@ -174,26 +174,26 @@
* to a non-existant application and then get the name that is
* actually stored */
hres = ITask_SetApplicationName(test_task, non_application_name);
- todo_wine ok(hres == S_OK, "Failed setting name %s: %08x\n",
+ ok(hres == S_OK, "Failed setting name %s: %08x\n",
dbgstr_w(non_application_name), hres);
hres = ITask_GetApplicationName(test_task, &stored_name);
- todo_wine ok(hres == S_OK, "GetApplicationName failed: %08x\n", hres);
+ ok(hres == S_OK, "GetApplicationName failed: %08x\n", hres);
if (hres == S_OK)
{
full_name = path_resolve_name(non_application_name);
- todo_wine ok(!lstrcmpW(stored_name, full_name), "Got %s, expected %s\n",
+ ok(!lstrcmpW(stored_name, full_name), "Got %s, expected %s\n",
dbgstr_w(stored_name), dbgstr_w(full_name));
CoTaskMemFree(stored_name);
}
/* Clear application name */
hres = ITask_SetApplicationName(test_task, empty);
- todo_wine ok(hres == S_OK, "Failed setting name %s: %08x\n", dbgstr_w(empty), hres);
+ ok(hres == S_OK, "Failed setting name %s: %08x\n", dbgstr_w(empty), hres);
hres = ITask_GetApplicationName(test_task, &stored_name);
- todo_wine ok(hres == S_OK, "GetApplicationName failed: %08x\n", hres);
+ ok(hres == S_OK, "GetApplicationName failed: %08x\n", hres);
if (hres == S_OK)
{
- todo_wine ok(!lstrcmpW(stored_name, empty),
+ ok(!lstrcmpW(stored_name, empty),
"Got %s, expected empty string\n", dbgstr_w(stored_name));
CoTaskMemFree(stored_name);
}