schedsvc: Add support for generating new task name in SchRpcRegisterTask.

This commit is contained in:
Dmitry Timoshkov 2014-04-10 17:41:33 +09:00 committed by Alexandre Julliard
parent af0ede42d5
commit a484dadf4a
3 changed files with 28 additions and 22 deletions

View File

@ -1,5 +1,5 @@
MODULE = schedsvc.dll
IMPORTS = rpcrt4 advapi32
IMPORTS = rpcrt4 advapi32 ole32
C_SRCS = \
schedsvc.c \

View File

@ -180,27 +180,37 @@ HRESULT __cdecl SchRpcRegisterTask(const WCHAR *path, const WCHAR *xml, DWORD fl
/* FIXME: assume that validation is performed on the client side */
if (flags & TASK_VALIDATE_ONLY) return S_OK;
if (!path)
if (path)
{
FIXME("NULL name is not supported\n");
return E_INVALIDARG;
}
full_name = get_full_name(path, &relative_path);
if (!full_name) return E_OUTOFMEMORY;
full_name = get_full_name(path, &relative_path);
if (!full_name) return E_OUTOFMEMORY;
if (strchrW(path, '\\') || strchrW(path, '/'))
{
WCHAR *p = strrchrW(full_name, '/');
if (!p) p = strrchrW(full_name, '\\');
*p = 0;
hr = create_directory(full_name);
if (hr != S_OK && hr != HRESULT_FROM_WIN32(ERROR_ALREADY_EXISTS))
if (strchrW(path, '\\') || strchrW(path, '/'))
{
heap_free(full_name);
return hr;
WCHAR *p = strrchrW(full_name, '/');
if (!p) p = strrchrW(full_name, '\\');
*p = 0;
hr = create_directory(full_name);
if (hr != S_OK && hr != HRESULT_FROM_WIN32(ERROR_ALREADY_EXISTS))
{
heap_free(full_name);
return hr;
}
*p = '\\';
}
*p = '\\';
}
else
{
IID iid;
WCHAR uuid_str[39];
UuidCreate(&iid);
StringFromGUID2(&iid, uuid_str, 39);
full_name = get_full_name(uuid_str, &relative_path);
if (!full_name) return E_OUTOFMEMORY;
/* skip leading '\' */
relative_path++;
}
switch (flags & (TASK_CREATE | TASK_UPDATE))

View File

@ -521,17 +521,13 @@ todo_wine
path = NULL;
info = NULL;
hr = SchRpcRegisterTask(NULL, xmlW, TASK_CREATE, NULL, TASK_LOGON_NONE, 0, NULL, &path, &info);
todo_wine
ok(hr == S_OK, "expected S_OK, got %#x\n", hr);
ok(!info, "expected NULL, info %p\n", info);
if (hr == S_OK)
{
hr = IIDFromString(path, &iid);
ok(hr == S_OK, "IIDFromString(%s) error %#x\n", wine_dbgstr_w(path), hr);
hr = SchRpcDelete(path, 0);
ok(hr == S_OK, "expected S_OK, got %#x\n", hr);
MIDL_user_free(path);
}
hr = RpcBindingFree(&rpc_handle);
ok(hr == RPC_S_OK, "RpcBindingFree error %#x\n", hr);