wmvcore: Print the debug string and not the pointer to it.
[wine.git] / dlls / schedsvc / tests / rpcapi.c
blobbe1e5eb4cae192771253e3dea8a751fdcc1ddead
1 /*
2 * Copyright 2014 Dmitry Timoshkov
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 <stdio.h>
20 #include <windows.h>
21 #include <ole2.h>
22 #include <rpcdce.h>
23 #include <taskschd.h>
24 #include "schrpc.h"
26 #include "wine/test.h"
28 extern handle_t rpc_handle;
30 static LONG CALLBACK rpc_exception_filter(EXCEPTION_POINTERS *ptrs)
32 skip("Can't connect to Scheduler service: %#x\n", ptrs->ExceptionRecord->ExceptionCode);
34 if (winetest_debug)
36 fprintf(stdout, "%04x:rpcapi: 0 tests executed (0 marked as todo, 0 failures), 1 skipped.\n", GetCurrentProcessId());
37 fflush(stdout);
39 ExitProcess(0);
42 START_TEST(rpcapi)
44 static unsigned char ncalrpc[] = "ncalrpc";
45 static const WCHAR empty[] = { 0 };
46 static const WCHAR Wine[] = { '\\','W','i','n','e',0 };
47 static const WCHAR Wine_Folder1[] = { '\\','W','i','n','e','\\','F','o','l','d','e','r','1',0 };
48 static const WCHAR Wine_Folder2[] = { '\\','W','i','n','e','\\','F','o','l','d','e','r','2',0 };
49 static const WCHAR Folder1[] = { 'F','o','l','d','e','r','1',0 };
50 static const WCHAR Folder2[] = { 'F','o','l','d','e','r','2',0 };
51 static const WCHAR Wine_Task1[] = { '\\','W','i','n','e','\\','T','a','s','k','1',0 };
52 static const WCHAR Wine_Task2[] = { '\\','W','i','n','e','\\','T','a','s','k','2',0 };
53 static const WCHAR Wine_Task3[] = { '\\','W','i','n','e','\\','T','a','s','k','3',0 };
54 static const WCHAR Wine_Folder1_Task1[] = { '\\','W','i','n','e','\\','F','o','l','d','e','r','1','\\','T','a','s','k','1',0 };
55 static const WCHAR Task1[] = { 'T','a','s','k','1',0 };
56 static const WCHAR Task2[] = { 'T','a','s','k','2',0 };
57 static const WCHAR Task3[] = { 'T','a','s','k','3',0 };
58 static const char xml1[] =
59 "<?xml version=\"1.0\"?>\n"
60 "<Task xmlns=\"http://schemas.microsoft.com/windows/2004/02/mit/task\">\n"
61 " <RegistrationInfo>\n"
62 " <Description>\"Task1\"</Description>\n"
63 " </RegistrationInfo>\n"
64 " <Settings>\n"
65 " <Enabled>false</Enabled>\n"
66 " <Hidden>false</Hidden>\n"
67 " </Settings>\n"
68 " <Actions>\n"
69 " <Exec>\n"
70 " <Command>\"task1.exe\"</Command>\n"
71 " </Exec>\n"
72 " </Actions>\n"
73 "</Task>\n";
74 static const struct
76 DWORD flags, hr;
77 } create_new_task[] =
79 { 0, S_OK },
80 { TASK_CREATE, S_OK },
81 { TASK_UPDATE, 0x80070002 /* HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) */ },
82 { TASK_CREATE | TASK_UPDATE, S_OK }
84 static const struct
86 DWORD flags, hr;
87 } open_existing_task[] =
89 { 0, 0x800700b7 /* HRESULT_FROM_WIN32(ERROR_ALREADY_EXISTS) */ },
90 { TASK_CREATE, 0x800700b7 /* HRESULT_FROM_WIN32(ERROR_ALREADY_EXISTS) */ },
91 { TASK_UPDATE, S_OK },
92 { TASK_CREATE | TASK_UPDATE, S_OK }
94 WCHAR xmlW[sizeof(xml1)], *xml;
95 HRESULT hr;
96 DWORD version, start_index, count, i, enumed, enabled, state;
97 WCHAR *path;
98 TASK_XML_ERROR_INFO *info;
99 TASK_NAMES names;
100 unsigned char *binding_str;
101 PTOP_LEVEL_EXCEPTION_FILTER old_exception_filter;
102 IID iid;
104 hr = RpcStringBindingComposeA(NULL, ncalrpc, NULL, NULL, NULL, &binding_str);
105 ok(hr == RPC_S_OK, "RpcStringBindingCompose error %#x\n", hr);
106 hr = RpcBindingFromStringBindingA(binding_str, &rpc_handle);
107 ok(hr == RPC_S_OK, "RpcBindingFromStringBinding error %#x\n", hr);
108 hr = RpcStringFreeA(&binding_str);
109 ok(hr == RPC_S_OK, "RpcStringFree error %#x\n", hr);
111 /* widl generated RpcTryExcept/RpcExcept can't catch raised exceptions */
112 old_exception_filter = SetUnhandledExceptionFilter(rpc_exception_filter);
114 version = 0;
115 hr = SchRpcHighestVersion(&version);
116 ok(hr == S_OK, "expected S_OK, got %#x\n", hr);
117 ok(version == 0x10002 /* vista */ || version == 0x10003 /* win7 */ ||
118 version == 0x10004 /* win8 */ || version == 0x10005 /* win10 */,
119 "wrong version %#x\n", version);
121 SetUnhandledExceptionFilter(old_exception_filter);
123 hr = SchRpcCreateFolder(Wine_Folder1, NULL, 1);
124 ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got %#x\n", hr);
126 hr = SchRpcCreateFolder(Wine_Folder1, NULL, 0);
127 ok(hr == S_OK, "expected S_OK, got %#x\n", hr);
129 hr = SchRpcCreateFolder(Wine_Folder1, NULL, 0);
130 ok(hr == HRESULT_FROM_WIN32(ERROR_ALREADY_EXISTS), "expected ERROR_ALREADY_EXISTS, got %#x\n", hr);
132 hr = SchRpcCreateFolder(Wine_Folder2+1, empty, 0);
133 ok(hr == S_OK, "expected S_OK, got %#x\n", hr);
135 hr = SchRpcDelete(Wine+1, 0);
136 ok(hr == HRESULT_FROM_WIN32(ERROR_DIR_NOT_EMPTY), "expected ERROR_DIR_NOT_EMPTY, got %#x\n", hr);
138 hr = SchRpcDelete(Wine_Folder1+1, 1);
139 ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got %#x\n", hr);
141 hr = SchRpcDelete(Wine_Folder1+1, 0);
142 ok(hr == S_OK, "expected S_OK, got %#x\n", hr);
144 hr = SchRpcDelete(Wine_Folder2, 0);
145 ok(hr == S_OK, "expected S_OK, got %#x\n", hr);
147 hr = SchRpcDelete(Wine, 0);
148 ok(hr == S_OK, "expected S_OK, got %#x\n", hr);
150 hr = SchRpcDelete(Wine, 0);
151 ok(hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) ||
152 broken(hr == S_OK), /* Early versions of Win 10 */
153 "expected ERROR_FILE_NOT_FOUND, got %#x\n", hr);
155 hr = SchRpcDelete(empty, 0);
156 ok(hr == E_ACCESSDENIED /* win7 */ || hr == E_INVALIDARG /* vista */, "expected E_ACCESSDENIED, got %#x\n", hr);
158 hr = SchRpcCreateFolder(Wine, NULL, 0);
159 ok(hr == S_OK, "expected S_OK, got %#x\n", hr);
161 MultiByteToWideChar(CP_ACP, 0, xml1, -1, xmlW, sizeof(xmlW)/sizeof(xmlW[0]));
163 path = NULL;
164 info = NULL;
165 hr = SchRpcRegisterTask(Wine+1, xmlW, TASK_VALIDATE_ONLY, NULL, TASK_LOGON_NONE, 0, NULL, &path, &info);
166 ok(hr == S_OK, "expected S_OK, got %#x\n", hr);
167 ok(!path, "expected NULL, path %p\n", path);
168 ok(!info, "expected NULL, info %p\n", info);
170 for (i = 0; i < sizeof(create_new_task)/sizeof(create_new_task[0]); i++)
172 path = NULL;
173 info = NULL;
174 hr = SchRpcRegisterTask(Wine_Task1, xmlW, create_new_task[i].flags, NULL, TASK_LOGON_NONE, 0, NULL, &path, &info);
175 ok(hr == create_new_task[i].hr, "%u: expected %#x, got %#x\n", i, create_new_task[i].hr, hr);
177 if (hr == S_OK)
179 hr = SchRpcDelete(Wine_Task1, 0);
180 ok(hr == S_OK, "expected S_OK, got %#x\n", hr);
181 ok(!info, "expected NULL, info %p\n", info);
182 MIDL_user_free(path);
186 path = NULL;
187 info = NULL;
188 hr = SchRpcRegisterTask(Wine_Task1, xmlW, TASK_VALIDATE_ONLY, NULL, TASK_LOGON_NONE, 0, NULL, &path, &info);
189 ok(hr == S_OK, "expected S_OK, got %#x\n", hr);
190 ok(!path, "expected NULL, path %p\n", path);
191 ok(!info, "expected NULL, info %p\n", info);
193 path = NULL;
194 info = NULL;
195 hr = SchRpcRegisterTask(NULL, xmlW, TASK_VALIDATE_ONLY, NULL, TASK_LOGON_NONE, 0, NULL, &path, &info);
196 ok(hr == S_OK, "expected S_OK, got %#x\n", hr);
197 ok(!path, "expected NULL, path %p\n", path);
198 ok(!info, "expected NULL, info %p\n", info);
200 path = NULL;
201 info = NULL;
202 hr = SchRpcRegisterTask(Wine_Folder1_Task1+1, xmlW, TASK_CREATE, NULL, TASK_LOGON_NONE, 0, NULL, &path, &info);
203 ok(hr == S_OK, "expected S_OK, got %#x\n", hr);
204 ok(!lstrcmpW(path, Wine_Folder1_Task1) /* win7 */ || !lstrcmpW(path, Wine_Folder1_Task1+1) /* vista */,
205 "expected \\Wine\\Folder1\\Task1, task actual path %s\n", wine_dbgstr_w(path));
206 ok(!info, "expected NULL, info %p\n", info);
207 MIDL_user_free(path);
209 for (i = 0; i < sizeof(open_existing_task)/sizeof(open_existing_task[0]); i++)
211 path = NULL;
212 info = NULL;
213 hr = SchRpcRegisterTask(Wine_Folder1_Task1+1, xmlW, open_existing_task[i].flags, NULL, TASK_LOGON_NONE, 0, NULL, &path, &info);
214 ok(hr == open_existing_task[i].hr, "%u: expected %#x, got %#x\n", i, open_existing_task[i].hr, hr);
215 if (hr == S_OK)
217 ok(!lstrcmpW(path, Wine_Folder1_Task1) /* win7 */ || !lstrcmpW(path, Wine_Folder1_Task1+1) /* vista */,
218 "expected \\Wine\\Folder1\\Task1, task actual path %s\n", wine_dbgstr_w(path));
219 MIDL_user_free(path);
221 else
222 ok(!path, "%u: expected NULL, path %p\n", i, path);
223 ok(!info, "%u: expected NULL, info %p\n", i, info);
226 path = NULL;
227 info = NULL;
228 hr = SchRpcRegisterTask(Wine_Folder1_Task1+1, xmlW, TASK_CREATE, NULL, TASK_LOGON_NONE, 0, NULL, &path, &info);
229 ok(hr == HRESULT_FROM_WIN32(ERROR_ALREADY_EXISTS), "expected ERROR_ALREADY_EXISTS, got %#x\n", hr);
230 ok(!path, "expected NULL, path %p\n", path);
231 ok(!info, "expected NULL, info %p\n", info);
233 count = 0;
234 xml = NULL;
235 hr = SchRpcRetrieveTask(Wine_Folder1_Task1, empty, &count, &xml);
236 ok(hr == S_OK, "expected S_OK, got %#x\n", hr);
237 if (hr == S_OK) trace("%s\n", wine_dbgstr_w(xml));
238 MIDL_user_free(xml);
240 hr = SchRpcDelete(Wine_Folder1_Task1+1, 0);
241 ok(hr == S_OK, "expected S_OK, got %#x\n", hr);
242 hr = SchRpcDelete(Wine_Folder1+1, 0);
243 ok(hr == S_OK, "expected S_OK, got %#x\n", hr);
244 hr = SchRpcDelete(Wine+1, 0);
245 ok(hr == S_OK, "expected S_OK, got %#x\n", hr);
247 start_index = 0;
248 count = 0xdeadbeef;
249 names = NULL;
250 hr = SchRpcEnumFolders(Wine, TASK_ENUM_HIDDEN, &start_index, 0, &count, &names);
251 ok(hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND), "expected ERROR_FILE_NOT_FOUND, got %#x\n", hr);
252 ok(!count, "expected 0, got %u\n", count);
253 ok(!start_index, "expected 0, got %u\n", start_index);
254 ok(!names, "expected NULL, got %p\n", names);
256 hr = SchRpcCreateFolder(Wine, NULL, 0);
257 ok(hr == S_OK, "expected S_OK, got %#x\n", hr);
259 start_index = 0;
260 count = 0xdeadbeef;
261 names = NULL;
262 hr = SchRpcEnumFolders(Wine, 0, &start_index, 0, &count, &names);
263 ok(hr == S_OK, "expected S_OK, got %#x\n", hr);
264 ok(!count, "expected 0, got %u\n", count);
265 ok(!start_index, "expected 0, got %u\n", start_index);
266 ok(!names, "expected NULL, got %p\n", names);
268 hr = SchRpcCreateFolder(Wine_Folder1, NULL, 0);
269 ok(hr == S_OK, "expected S_OK, got %#x\n", hr);
270 hr = SchRpcCreateFolder(Wine_Folder2, NULL, 0);
271 ok(hr == S_OK, "expected S_OK, got %#x\n", hr);
273 start_index = 0;
274 count = 0xdeadbeef;
275 names = NULL;
276 hr = SchRpcEnumFolders(Wine, 0, &start_index, 0, &count, &names);
277 ok(hr == S_OK, "expected S_OK, got %#x\n", hr);
278 ok(count == 2, "expected 2, got %u\n", count);
279 ok(start_index == 2, "expected 2, got %u\n", start_index);
280 ok(names != NULL, "names should not be NULL\n");
281 enumed = 0;
282 for (i = 0; i < count; i++)
284 if (!lstrcmpW(names[i], Folder1))
285 enumed += 1;
286 else if (!lstrcmpW(names[i], Folder2))
287 enumed += 2;
288 MIDL_user_free(names[i]);
290 MIDL_user_free(names);
291 ok(enumed == 3, "expected 3, got %u\n", enumed);
293 start_index = 0;
294 count = 0xdeadbeef;
295 names = NULL;
296 hr = SchRpcEnumFolders(Wine, 0, &start_index, 1, &count, &names);
297 ok(hr == S_FALSE, "expected S_FALSE, got %#x\n", hr);
298 ok(count == 1, "expected 1, got %u\n", count);
299 ok(start_index == 1, "expected 1, got %u\n", start_index);
300 ok(names != NULL, "names should not be NULL\n");
301 ok(!lstrcmpW(names[0], Folder1) || !lstrcmpW(names[0], Folder2), "got %s\n", wine_dbgstr_w(names[0]));
302 MIDL_user_free(names[0]);
303 MIDL_user_free(names);
305 start_index = 0;
306 count = 0xdeadbeef;
307 names = NULL;
308 hr = SchRpcEnumFolders(Wine, 0, &start_index, 2, &count, &names);
309 ok(hr == S_FALSE, "expected S_FALSE, got %#x\n", hr);
310 ok(count == 2, "expected 2, got %u\n", count);
311 ok(start_index == 2, "expected 2, got %u\n", start_index);
312 ok(names != NULL, "names should not be NULL\n");
313 enumed = 0;
314 for (i = 0; i < count; i++)
316 if (!lstrcmpW(names[i], Folder1))
317 enumed += 1;
318 else if (!lstrcmpW(names[i], Folder2))
319 enumed += 2;
320 MIDL_user_free(names[i]);
322 MIDL_user_free(names);
323 ok(enumed == 3, "expected 3, got %u\n", enumed);
325 start_index = 0;
326 count = 0xdeadbeef;
327 names = NULL;
328 hr = SchRpcEnumFolders(Wine, 0, &start_index, 10, &count, &names);
329 ok(hr == S_OK, "expected S_OK, got %#x\n", hr);
330 ok(count == 2, "expected 2, got %u\n", count);
331 ok(start_index == 2, "expected 2, got %u\n", start_index);
332 ok(names != NULL, "names should not be NULL\n");
333 enumed = 0;
334 for (i = 0; i < count; i++)
336 if (!lstrcmpW(names[i], Folder1))
337 enumed += 1;
338 else if (!lstrcmpW(names[i], Folder2))
339 enumed += 2;
340 MIDL_user_free(names[i]);
342 MIDL_user_free(names);
343 ok(enumed == 3, "expected 3, got %u\n", enumed);
345 start_index = 10;
346 count = 0xdeadbeef;
347 names = NULL;
348 hr = SchRpcEnumFolders(Wine, 0, &start_index, 0, &count, &names);
349 ok(hr == S_FALSE, "expected S_FALSE, got %#x\n", hr);
350 ok(!count, "expected 0, got %u\n", count);
351 ok(start_index == 10, "expected 10, got %u\n", start_index);
352 ok(!names, "expected NULL, got %p\n", names);
354 hr = SchRpcDelete(Wine_Folder1+1, 0);
355 ok(hr == S_OK, "expected S_OK, got %#x\n", hr);
356 hr = SchRpcDelete(Wine_Folder2, 0);
357 ok(hr == S_OK, "expected S_OK, got %#x\n", hr);
359 start_index = 0;
360 count = 0xdeadbeef;
361 names = NULL;
362 hr = SchRpcEnumTasks(Wine_Folder1, TASK_ENUM_HIDDEN, &start_index, 0, &count, &names);
363 ok(hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND), "expected ERROR_FILE_NOT_FOUND, got %#x\n", hr);
364 ok(!count, "expected 0, got %u\n", count);
365 ok(!start_index, "expected 0, got %u\n", start_index);
366 ok(!names, "expected NULL, got %p\n", names);
368 path = NULL;
369 info = NULL;
370 hr = SchRpcRegisterTask(Wine_Task1+1, xmlW, TASK_CREATE, NULL, TASK_LOGON_NONE, 0, NULL, &path, &info);
371 ok(hr == S_OK, "expected S_OK, got %#x\n", hr);
372 ok(!lstrcmpW(path, Wine_Task1) /* win7 */ || !lstrcmpW(path, Wine_Task1+1) /* vista */,
373 "expected \\Wine\\Task1, task actual path %s\n", wine_dbgstr_w(path));
374 ok(!info, "expected NULL, info %p\n", info);
375 MIDL_user_free(path);
377 path = NULL;
378 info = NULL;
379 hr = SchRpcRegisterTask(Wine_Task2, xmlW, TASK_CREATE, NULL, TASK_LOGON_NONE, 0, NULL, &path, &info);
380 ok(hr == S_OK, "expected S_OK, got %#x\n", hr);
381 ok(!lstrcmpW(path, Wine_Task2), "expected \\Wine\\Task2, task actual path %s\n", wine_dbgstr_w(path));
382 ok(!info, "expected NULL, info %p\n", info);
383 MIDL_user_free(path);
385 start_index = 0;
386 count = 0xdeadbeef;
387 names = NULL;
388 hr = SchRpcEnumTasks(Wine, 0, &start_index, 0, &count, &names);
389 ok(hr == S_OK, "expected S_OK, got %#x\n", hr);
390 ok(count == 2, "expected 2, got %u\n", count);
391 ok(start_index == 2, "expected 2, got %u\n", start_index);
392 ok(names != NULL, "names should not be NULL\n");
393 enumed = 0;
394 for (i = 0; i < count; i++)
396 if (!lstrcmpW(names[i], Task1))
397 enumed += 1;
398 else if (!lstrcmpW(names[i], Task2))
399 enumed += 2;
400 MIDL_user_free(names[i]);
402 MIDL_user_free(names);
403 ok(enumed == 3, "expected 3, got %u\n", enumed);
405 start_index = 0;
406 count = 0xdeadbeef;
407 names = NULL;
408 hr = SchRpcEnumTasks(Wine, 0, &start_index, 1, &count, &names);
409 ok(hr == S_FALSE, "expected S_FALSE, got %#x\n", hr);
410 ok(count == 1, "expected 1, got %u\n", count);
411 ok(start_index == 1, "expected 1, got %u\n", start_index);
412 ok(names != NULL, "names should not be NULL\n");
413 /* returned name depends whether directory randomization is on */
414 ok(!lstrcmpW(names[0], Task1) || !lstrcmpW(names[0], Task2),
415 "expected Task1, got %s\n", wine_dbgstr_w(names[0]));
416 MIDL_user_free(names[0]);
417 MIDL_user_free(names);
419 start_index = 0;
420 count = 0xdeadbeef;
421 names = NULL;
422 hr = SchRpcEnumTasks(Wine, 0, &start_index, 2, &count, &names);
423 ok(hr == S_FALSE, "expected S_FALSE, got %#x\n", hr);
424 ok(count == 2, "expected 2, got %u\n", count);
425 ok(start_index == 2, "expected 2, got %u\n", start_index);
426 ok(names != NULL, "names should not be NULL\n");
427 enumed = 0;
428 for (i = 0; i < count; i++)
430 if (!lstrcmpW(names[i], Task1))
431 enumed += 1;
432 else if (!lstrcmpW(names[i], Task2))
433 enumed += 2;
434 MIDL_user_free(names[i]);
436 MIDL_user_free(names);
437 ok(enumed == 3, "expected 3, got %u\n", enumed);
439 start_index = 0;
440 count = 0xdeadbeef;
441 names = NULL;
442 hr = SchRpcEnumTasks(Wine, 0, &start_index, 10, &count, &names);
443 ok(hr == S_OK, "expected S_OK, got %#x\n", hr);
444 ok(count == 2, "expected 2, got %u\n", count);
445 ok(start_index == 2, "expected 2, got %u\n", start_index);
446 ok(names != NULL, "names should not be NULL\n");
447 enumed = 0;
448 for (i = 0; i < count; i++)
450 if (!lstrcmpW(names[i], Task1))
451 enumed += 1;
452 else if (!lstrcmpW(names[i], Task2))
453 enumed += 2;
454 MIDL_user_free(names[i]);
456 MIDL_user_free(names);
457 ok(enumed == 3, "expected 3, got %u\n", enumed);
459 path = NULL;
460 info = NULL;
461 hr = SchRpcRegisterTask(Wine_Task3+1, xmlW, TASK_CREATE, NULL, TASK_LOGON_NONE, 0, NULL, &path, &info);
462 ok(hr == S_OK, "expected S_OK, got %#x\n", hr);
463 ok(!lstrcmpW(path, Wine_Task3) /* win7 */ || !lstrcmpW(path, Wine_Task3+1) /* vista */,
464 "expected \\Wine\\Task3, task actual path %s\n", wine_dbgstr_w(path));
465 ok(!info, "expected NULL, info %p\n", info);
466 MIDL_user_free(path);
468 count = 0xdeadbeef;
469 names = NULL;
470 hr = SchRpcEnumTasks(Wine+1, 0, &start_index, 10, &count, &names);
471 ok(hr == S_OK, "expected S_OK, got %#x\n", hr);
472 ok(count == 1, "expected 1, got %u\n", count);
473 ok(start_index == 3, "expected 3, got %u\n", start_index);
474 ok(names != NULL, "names should not be NULL\n");
475 /* returned name depends whether directory randomization is on */
476 ok(!lstrcmpW(names[0], Task1) || !lstrcmpW(names[0], Task2) || !lstrcmpW(names[0], Task3),
477 "expected Task3, got %s\n", wine_dbgstr_w(names[0]));
478 MIDL_user_free(names[0]);
479 MIDL_user_free(names);
481 if (0) /* crashes under win7 */
483 hr = SchRpcGetTaskInfo(NULL, 0, NULL, NULL);
484 hr = SchRpcGetTaskInfo(Task1, 0, NULL, NULL);
485 hr = SchRpcGetTaskInfo(Task1, 0, &enabled, NULL);
486 hr = SchRpcGetTaskInfo(Task1, 0, NULL, &state);
489 hr = SchRpcGetTaskInfo(Task1, 0, &enabled, &state);
490 ok(hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND), "expected ERROR_FILE_NOT_FOUND, got %#x\n", hr);
492 enabled = state = 0xdeadbeef;
493 hr = SchRpcGetTaskInfo(Wine_Task1, 0, &enabled, &state);
494 ok(hr == S_OK, "expected S_OK, got %#x\n", hr);
495 ok(enabled == 0, "expected 0, got %u\n", enabled);
496 ok(state == TASK_STATE_UNKNOWN, "expected TASK_STATE_UNKNOWN, got %u\n", state);
498 enabled = state = 0xdeadbeef;
499 hr = SchRpcGetTaskInfo(Wine_Task1, SCH_FLAG_STATE, &enabled, &state);
500 ok(hr == S_OK, "expected S_OK, got %#x\n", hr);
501 ok(enabled == 0, "expected 0, got %u\n", enabled);
502 ok(state == TASK_STATE_DISABLED, "expected TASK_STATE_DISABLED, got %u\n", state);
504 hr = SchRpcEnableTask(Wine_Task1, 0xdeadbeef);
505 todo_wine
506 ok(hr == S_OK, "expected S_OK, got %#x\n", hr);
508 enabled = state = 0xdeadbeef;
509 hr = SchRpcGetTaskInfo(Wine_Task1, SCH_FLAG_STATE, &enabled, &state);
510 ok(hr == S_OK, "expected S_OK, got %#x\n", hr);
511 todo_wine
512 ok(enabled == 1, "expected 1, got %u\n", enabled);
513 todo_wine
514 ok(state == TASK_STATE_READY, "expected TASK_STATE_READY, got %u\n", state);
516 hr = SchRpcDelete(Wine_Task1+1, 0);
517 ok(hr == S_OK, "expected S_OK, got %#x\n", hr);
518 hr = SchRpcDelete(Wine_Task2+1, 0);
519 ok(hr == S_OK, "expected S_OK, got %#x\n", hr);
520 hr = SchRpcDelete(Wine_Task3+1, 0);
521 ok(hr == S_OK, "expected S_OK, got %#x\n", hr);
522 hr = SchRpcDelete(Wine, 0);
523 ok(hr == S_OK, "expected S_OK, got %#x\n", hr);
525 path = NULL;
526 info = NULL;
527 hr = SchRpcRegisterTask(NULL, xmlW, TASK_CREATE, NULL, TASK_LOGON_NONE, 0, NULL, &path, &info);
528 ok(hr == S_OK, "expected S_OK, got %#x\n", hr);
529 ok(!info, "expected NULL, info %p\n", info);
530 hr = IIDFromString(path, &iid);
531 ok(hr == S_OK, "IIDFromString(%s) error %#x\n", wine_dbgstr_w(path), hr);
532 hr = SchRpcDelete(path, 0);
533 ok(hr == S_OK, "expected S_OK, got %#x\n", hr);
534 MIDL_user_free(path);
536 hr = RpcBindingFree(&rpc_handle);
537 ok(hr == RPC_S_OK, "RpcBindingFree error %#x\n", hr);
540 void __RPC_FAR *__RPC_USER MIDL_user_allocate(SIZE_T n)
542 return HeapAlloc(GetProcessHeap(), 0, n);
545 void __RPC_USER MIDL_user_free(void __RPC_FAR *p)
547 HeapFree(GetProcessHeap(), 0, p);