include/mscvpdb.h: Use flexible array members for the rest of structures.
[wine.git] / dlls / setupapi / tests / query.c
blobd5de41b368ab7553d861964eec7fcb86efb9afd2
1 /*
2 * Unit tests for setupapi.dll query functions
4 * Copyright (C) 2006 James Hawkins
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include <stdio.h>
22 #include <windows.h>
23 #include <setupapi.h>
24 #include "wine/test.h"
26 static CHAR CURR_DIR[MAX_PATH];
27 static CHAR WIN_DIR[MAX_PATH];
29 static void get_directories(void)
31 int len;
33 GetCurrentDirectoryA(MAX_PATH, CURR_DIR);
34 len = lstrlenA(CURR_DIR);
36 if(len && (CURR_DIR[len-1] == '\\'))
37 CURR_DIR[len-1] = 0;
39 GetWindowsDirectoryA(WIN_DIR, MAX_PATH);
40 len = lstrlenA(WIN_DIR);
42 if (len && (WIN_DIR[len-1] == '\\'))
43 WIN_DIR[len-1] = 0;
46 static const char inf_data1[] =
47 "[Version]\n"
48 "Signature=\"$Chicago$\"\n"
49 "AdvancedINF=2.5\n"
50 "[copy_section]\n"
51 "one.txt,,2\n"
52 "two.txt\n"
53 "four.txt,five.txt\n"
54 "six.txt,seven.txt\n"
55 "[SourceDisksNames]\n"
56 "2 = %SrcDiskName%, LANCOM\\LANtools\\lanconf.cab\n"
57 "4=,,,here\n"
58 "8=name\n"
59 "[SourceDisksFiles]\n"
60 "one.txt=2\n"
61 "two.txt=4,there\n"
62 "three.txt=6\n"
63 "five.txt=8\n"
64 "six.txt=10\n"
65 "[DestinationDirs]\n"
66 "DefaultDestDir = 24, %DefaultDest%\n"
67 "[Strings]\n"
68 "LangDir = english\n"
69 "DefaultDest = LANCOM\n"
70 "SrcDiskName = \"LANCOM Software CD\"\n";
72 static const char inf_data2[] =
73 "[SourceFileInfo]\n"
74 "sp1qfe\\bitsinst.exe=250B3702C7CCD7C2F9E4DAA1555C933E,000600060A28062C,27136,SP1QFE\n"
75 "sp1qfe\\bitsprx2.dll=4EBEA67F4BB4EB402E725CA7CA2857AE,000600060A280621,7680,SP1QFE\n"
76 "sp1qfe\\bitsprx3.dll=C788A1D9330DA011EF25E95D3BC7BDE5,000600060A280621,7168,SP1QFE\n"
77 "sp1qfe\\qmgr.dll=696AC82FB290A03F205901442E0E9589,000600060A280621,361984,SP1QFE\n"
78 "sp1qfe\\qmgrprxy.dll=8B5848144829E1BC985EA4C3D8CA7E3F,000600060A280621,17408,SP1QFE\n"
79 "sp1qfe\\winhttp.dll=3EC6F518114606CA59D4160322077437,000500010A280615,331776,SP1QFE\n"
80 "sp1qfe\\xpob2res.dll=DB83156B9F496F20D1EA70E4ABEC0166,000500010A280622,158720,SP1QFE\n";
82 static const char inf_data3[] =
83 "[Version]\n"
84 "Signature = \"$Windows NT$\"\n"
85 "[DestinationDirs]\n"
86 "CopyAlways.Windir.files = 10\n"
87 "[CopyAlways.Windir.Files]\n"
88 "WindowsCodecs.dll\n";
90 static const char inf_data4[] =
91 "[Version]\n"
92 "Signature = \"$Windows NT$\"\n"
93 "[CopyAlways.System32.Files]\n"
94 "WindowsCodecs.dll\n";
96 static const char inf_data5[] =
97 "[Version]\n"
98 "Signature = \"$Windows NT$\"\n"
99 "[DestinationDirs]\n"
100 "DefaultDestDir = 11\n"
101 "CopyAlways.Windir.files = 10\n"
102 "[CopyAlways.Windir.Files]\n"
103 "WindowsCodecs.dll\n";
105 static const char inf_data6[] =
106 "[Version]\n"
107 "Signature = \"$Windows NT$\"\n"
108 "[DestinationDirs]\n"
109 "DefaultDestDir = 10\n"
110 "[CopyAlways.Windir.Files]\n"
111 "WindowsCodecs.dll\n";
113 static BOOL create_inf_file(LPSTR filename, const char *data, DWORD size)
115 BOOL ret;
116 DWORD dwNumberOfBytesWritten;
117 HANDLE hf = CreateFileA(filename, GENERIC_WRITE, 0, NULL,
118 CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
119 if (hf == INVALID_HANDLE_VALUE) return FALSE;
120 ret = WriteFile(hf, data, size, &dwNumberOfBytesWritten, NULL);
121 CloseHandle(hf);
122 return ret;
125 static BOOL check_info_filename(PSP_INF_INFORMATION info, LPSTR test)
127 LPSTR filename;
128 DWORD size;
129 BOOL ret = FALSE;
131 if (!SetupQueryInfFileInformationA(info, 0, NULL, 0, &size))
132 return FALSE;
134 filename = malloc(size);
135 if (!filename)
136 return FALSE;
138 SetupQueryInfFileInformationA(info, 0, filename, size, &size);
140 if (!lstrcmpiA(test, filename))
141 ret = TRUE;
143 free(filename);
144 return ret;
147 static PSP_INF_INFORMATION alloc_inf_info(LPCSTR filename, DWORD search, PDWORD size)
149 PSP_INF_INFORMATION info;
150 BOOL ret;
152 ret = SetupGetInfInformationA(filename, search, NULL, 0, size);
153 if (!ret)
154 return NULL;
156 info = malloc(*size);
157 return info;
160 static void test_SetupGetInfInformation(void)
162 PSP_INF_INFORMATION info;
163 CHAR inf_filename[MAX_PATH];
164 CHAR inf_one[MAX_PATH], inf_two[MAX_PATH];
165 LPSTR revfile;
166 DWORD size;
167 HINF hinf;
168 BOOL ret;
170 lstrcpyA(inf_filename, CURR_DIR);
171 lstrcatA(inf_filename, "\\");
172 lstrcatA(inf_filename, "test.inf");
174 /* try an invalid inf handle */
175 size = 0xdeadbeef;
176 SetLastError(0xbeefcafe);
177 ret = SetupGetInfInformationA(NULL, INFINFO_INF_SPEC_IS_HINF, NULL, 0, &size);
178 ok(ret == FALSE, "Expected SetupGetInfInformation to fail\n");
179 ok(GetLastError() == ERROR_INVALID_HANDLE ||
180 broken(GetLastError() == ERROR_BAD_PATHNAME) || /* win95 */
181 broken(GetLastError() == ERROR_FILE_NOT_FOUND) || /* win98 */
182 broken(GetLastError() == ERROR_PATH_NOT_FOUND) || /* NT4 */
183 broken(GetLastError() == ERROR_INVALID_NAME) || /* win2k */
184 broken(GetLastError() == ERROR_GENERAL_SYNTAX), /* another win2k / winMe */
185 "Expected ERROR_INVALID_HANDLE, got %ld\n", GetLastError());
186 ok(size == 0xdeadbeef, "Expected size to remain unchanged\n");
188 /* try an invalid inf filename */
189 /* do not use NULL as absolute inf filename on win9x/winMe (crash) */
190 if ((GetLastError() != ERROR_BAD_PATHNAME) && /* win95 */
191 (GetLastError() != ERROR_FILE_NOT_FOUND) && /* win98 */
192 (GetLastError() != ERROR_GENERAL_SYNTAX)) /* winMe */
194 size = 0xdeadbeef;
195 SetLastError(0xbeefcafe);
196 ret = SetupGetInfInformationA(NULL, INFINFO_INF_NAME_IS_ABSOLUTE, NULL, 0, &size);
197 ok(ret == FALSE, "Expected SetupGetInfInformation to fail\n");
198 ok(GetLastError() == ERROR_INVALID_PARAMETER,
199 "Expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
200 ok(size == 0xdeadbeef, "Expected size to remain unchanged\n");
203 create_inf_file(inf_filename, inf_data1, sizeof(inf_data1) - 1);
205 /* try an invalid search flag */
206 size = 0xdeadbeef;
207 SetLastError(0xbeefcafe);
208 ret = SetupGetInfInformationA(inf_filename, -1, NULL, 0, &size);
209 ok(ret == FALSE, "Expected SetupGetInfInformation to fail\n");
210 ok(GetLastError() == ERROR_INVALID_PARAMETER,
211 "Expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
212 ok(size == 0xdeadbeef, "Expected size to remain unchanged\n");
214 /* try a nonexistent inf file */
215 size = 0xdeadbeef;
216 SetLastError(0xbeefcafe);
217 ret = SetupGetInfInformationA("idontexist", INFINFO_INF_NAME_IS_ABSOLUTE, NULL, 0, &size);
218 ok(ret == FALSE, "Expected SetupGetInfInformation to fail\n");
219 ok(GetLastError() == ERROR_FILE_NOT_FOUND,
220 "Expected ERROR_FILE_NOT_FOUND, got %ld\n", GetLastError());
221 ok(size == 0xdeadbeef, "Expected size to remain unchanged\n");
223 /* successfully open the inf file */
224 size = 0xdeadbeef;
225 ret = SetupGetInfInformationA(inf_filename, INFINFO_INF_NAME_IS_ABSOLUTE, NULL, 0, &size);
226 ok(ret == TRUE, "Expected SetupGetInfInformation to succeed\n");
227 ok(size != 0xdeadbeef, "Expected a valid size on return\n");
229 /* set ReturnBuffer to NULL and ReturnBufferSize to non-zero value 'size' */
230 SetLastError(0xbeefcafe);
231 ret = SetupGetInfInformationA(inf_filename, INFINFO_INF_NAME_IS_ABSOLUTE, NULL, size, &size);
232 ok(ret == FALSE, "Expected SetupGetInfInformation to fail\n");
233 ok(GetLastError() == ERROR_INVALID_PARAMETER,
234 "Expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
236 /* set ReturnBuffer to NULL and ReturnBufferSize to non-zero value 'size-1' */
237 ret = SetupGetInfInformationA(inf_filename, INFINFO_INF_NAME_IS_ABSOLUTE, NULL, size-1, &size);
238 ok(ret == TRUE, "Expected SetupGetInfInformation to succeed\n");
240 /* some tests for behaviour with a NULL RequiredSize pointer */
241 ret = SetupGetInfInformationA(inf_filename, INFINFO_INF_NAME_IS_ABSOLUTE, NULL, 0, NULL);
242 ok(ret == TRUE, "Expected SetupGetInfInformation to succeed\n");
243 ret = SetupGetInfInformationA(inf_filename, INFINFO_INF_NAME_IS_ABSOLUTE, NULL, size - 1, NULL);
244 ok(ret == TRUE, "Expected SetupGetInfInformation to succeed\n");
245 ret = SetupGetInfInformationA(inf_filename, INFINFO_INF_NAME_IS_ABSOLUTE, NULL, size, NULL);
246 ok(ret == FALSE, "Expected SetupGetInfInformation to fail\n");
248 info = malloc(size);
250 /* try valid ReturnBuffer but too small size */
251 SetLastError(0xbeefcafe);
252 ret = SetupGetInfInformationA(inf_filename, INFINFO_INF_NAME_IS_ABSOLUTE, info, size - 1, &size);
253 ok(ret == FALSE, "Expected SetupGetInfInformation to fail\n");
254 ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER,
255 "Expected ERROR_INSUFFICIENT_BUFFER, got %ld\n", GetLastError());
257 /* successfully get the inf information */
258 ret = SetupGetInfInformationA(inf_filename, INFINFO_INF_NAME_IS_ABSOLUTE, info, size, &size);
259 ok(ret == TRUE, "Expected SetupGetInfInformation to succeed\n");
260 ok(check_info_filename(info, inf_filename), "Expected returned filename to be equal\n");
262 free(info);
264 /* try the INFINFO_INF_SPEC_IS_HINF search flag */
265 hinf = SetupOpenInfFileA(inf_filename, NULL, INF_STYLE_WIN4, NULL);
266 info = alloc_inf_info(hinf, INFINFO_INF_SPEC_IS_HINF, &size);
267 ret = SetupGetInfInformationA(hinf, INFINFO_INF_SPEC_IS_HINF, info, size, &size);
268 ok(ret == TRUE, "Expected SetupGetInfInformation to succeed\n");
269 ok(check_info_filename(info, inf_filename), "Expected returned filename to be equal\n");
270 SetupCloseInfFile(hinf);
272 lstrcpyA(inf_two, WIN_DIR);
273 lstrcatA(inf_two, "\\system32\\");
274 lstrcatA(inf_two, "test.inf");
275 ret = create_inf_file(inf_two, inf_data1, sizeof(inf_data1) - 1);
276 if (!ret && GetLastError() == ERROR_ACCESS_DENIED)
278 skip("need admin rights\n");
279 goto done;
281 ok(ret, "can't create inf file %lu\n", GetLastError());
283 free(info);
284 info = alloc_inf_info("test.inf", INFINFO_DEFAULT_SEARCH, &size);
286 /* check if system32 is searched for inf */
287 ret = SetupGetInfInformationA("test.inf", INFINFO_DEFAULT_SEARCH, info, size, &size);
288 if (!ret && GetLastError() == ERROR_FILE_NOT_FOUND)
289 revfile = inf_one; /* Vista */
290 else
291 revfile = inf_two;
293 lstrcpyA(inf_one, WIN_DIR);
294 lstrcatA(inf_one, "\\inf\\");
295 lstrcatA(inf_one, "test.inf");
296 create_inf_file(inf_one, inf_data1, sizeof(inf_data1) - 1);
298 free(info);
299 info = alloc_inf_info("test.inf", INFINFO_DEFAULT_SEARCH, &size);
301 /* test the INFINFO_DEFAULT_SEARCH search flag */
302 ret = SetupGetInfInformationA("test.inf", INFINFO_DEFAULT_SEARCH, info, size, &size);
303 ok(ret == TRUE, "Expected SetupGetInfInformation to succeed: %ld\n", GetLastError());
304 ok(check_info_filename(info, inf_one), "Expected returned filename to be equal\n");
306 free(info);
307 info = alloc_inf_info("test.inf", INFINFO_REVERSE_DEFAULT_SEARCH, &size);
309 /* test the INFINFO_REVERSE_DEFAULT_SEARCH search flag */
310 ret = SetupGetInfInformationA("test.inf", INFINFO_REVERSE_DEFAULT_SEARCH, info, size, &size);
311 ok(ret == TRUE, "Expected SetupGetInfInformation to succeed\n");
312 ok(check_info_filename(info, revfile), "Expected returned filename to be equal\n");
314 done:
315 free(info);
316 DeleteFileA(inf_filename);
317 DeleteFileA(inf_one);
318 DeleteFileA(inf_two);
321 static void test_SetupGetSourceFileLocation(void)
323 char buffer[MAX_PATH] = "not empty", inf_filename[MAX_PATH];
324 UINT source_id;
325 DWORD required, error;
326 INFCONTEXT ctx;
327 HINF hinf;
328 BOOL ret;
330 lstrcpyA(inf_filename, CURR_DIR);
331 lstrcatA(inf_filename, "\\");
332 lstrcatA(inf_filename, "test.inf");
334 create_inf_file(inf_filename, inf_data1, sizeof(inf_data1) - 1);
336 hinf = SetupOpenInfFileA(inf_filename, NULL, INF_STYLE_WIN4, NULL);
337 ok(hinf != INVALID_HANDLE_VALUE, "could not open inf file\n");
339 required = 0;
340 source_id = 0;
342 ret = SetupGetSourceFileLocationA(hinf, NULL, "one.txt", &source_id, buffer, sizeof(buffer), &required);
343 ok(ret, "SetupGetSourceFileLocation failed\n");
345 ok(required == 1, "unexpected required size: %ld\n", required);
346 ok(source_id == 2, "unexpected source id: %d\n", source_id);
347 ok(!lstrcmpA("", buffer), "unexpected result string: %s\n", buffer);
349 ret = SetupGetSourceFileLocationA(hinf, NULL, "two.txt", &source_id, buffer, sizeof(buffer), NULL);
350 ok(ret, "Got error %lu.\n", GetLastError());
351 ok(source_id == 4, "Got source id %u.\n", source_id);
352 ok(!strcmp(buffer, "there"), "Got relative path %s.\n", debugstr_a(buffer));
354 ret = SetupFindFirstLineA(hinf, "copy_section", NULL, &ctx);
355 ok(ret, "Got error %lu.\n", GetLastError());
357 ret = SetupGetSourceFileLocationA(hinf, &ctx, "two.txt", &source_id, buffer, sizeof(buffer), NULL);
358 ok(ret, "Got error %lu.\n", GetLastError());
359 ok(source_id == 2, "Got source id %u.\n", source_id);
360 ok(!strcmp(buffer, ""), "Got relative path %s.\n", debugstr_a(buffer));
362 /* ctx should not be changed. */
363 ret = SetupGetLineTextA(&ctx, NULL, NULL, NULL, buffer, sizeof(buffer), NULL);
364 ok(!strcmp(buffer, "one.txt,,2"), "Got line %s.\n", debugstr_a(buffer));
366 /* Test when the source name differs from the destination name.
367 * It seems SetupGetSourceFileLocation() is buggy and doesn't take that
368 * into account; it always uses the destination name. */
370 ret = SetupFindNextLine(&ctx, &ctx);
371 ok(ret, "Got error %lu.\n", GetLastError());
372 ret = SetupFindNextLine(&ctx, &ctx);
373 ok(ret, "Got error %lu.\n", GetLastError());
375 SetLastError(0xdeadbeef);
376 ret = SetupGetSourceFileLocationA(hinf, &ctx, "two.txt", &source_id, buffer, sizeof(buffer), NULL);
377 ok(!ret, "Expected failure.\n");
378 ok(GetLastError() == ERROR_LINE_NOT_FOUND, "Got error %lu.\n", GetLastError());
380 ret = SetupFindNextLine(&ctx, &ctx);
381 ok(ret, "Got error %lu.\n", GetLastError());
383 ret = SetupGetSourceFileLocationA(hinf, &ctx, "two.txt", &source_id, buffer, sizeof(buffer), NULL);
384 ok(ret, "Got error %lu.\n", GetLastError());
385 ok(source_id == 10, "Got source id %u.\n", source_id);
386 ok(!strcmp(buffer, ""), "Got relative path %s.\n", debugstr_a(buffer));
388 ret = SetupGetSourceFileLocationA(hinf, NULL, "three.txt", &source_id, buffer, sizeof(buffer), NULL);
389 ok(ret, "Got error %lu.\n", GetLastError());
390 ok(source_id == 6, "Got source id %u.\n", source_id);
391 ok(!strcmp(buffer, ""), "Got relative path %s.\n", debugstr_a(buffer));
393 SetLastError(0xdeadbeef);
394 ret = SetupGetSourceFileLocationA(hinf, NULL, "four.txt", &source_id, buffer, sizeof(buffer), NULL);
395 ok(!ret, "Expected failure.\n");
396 ok(GetLastError() == ERROR_LINE_NOT_FOUND, "Got error %lu.\n", GetLastError());
398 ret = SetupGetSourceFileLocationA(hinf, NULL, "five.txt", &source_id, buffer, sizeof(buffer), NULL);
399 ok(ret, "Got error %lu.\n", GetLastError());
400 ok(source_id == 8, "Got source id %u.\n", source_id);
401 ok(!strcmp(buffer, ""), "Got relative path %s.\n", debugstr_a(buffer));
403 SetupCloseInfFile(hinf);
404 DeleteFileA(inf_filename);
406 create_inf_file(inf_filename, inf_data2, sizeof(inf_data2) - 1);
408 SetLastError(0xdeadbeef);
409 hinf = SetupOpenInfFileA(inf_filename, NULL, INF_STYLE_WIN4, NULL);
410 error = GetLastError();
411 ok(hinf == INVALID_HANDLE_VALUE, "could open inf file\n");
412 ok(error == ERROR_WRONG_INF_STYLE, "got wrong error: %ld\n", error);
414 hinf = SetupOpenInfFileA(inf_filename, NULL, INF_STYLE_OLDNT, NULL);
415 ok(hinf != INVALID_HANDLE_VALUE, "could not open inf file\n");
417 SetLastError(0xdeadbeef);
418 ret = SetupGetSourceFileLocationA(hinf, NULL, "", &source_id, buffer, sizeof(buffer), &required);
419 ok(!ret, "SetupGetSourceFileLocation succeeded\n");
420 ok(GetLastError() == ERROR_LINE_NOT_FOUND, "Got error %lu.\n", GetLastError());
422 SetupCloseInfFile(hinf);
423 DeleteFileA(inf_filename);
426 static void test_SetupGetSourceInfo(void)
428 char buffer[MAX_PATH], inf_filename[MAX_PATH];
429 DWORD required;
430 HINF hinf;
431 BOOL ret;
433 lstrcpyA(inf_filename, CURR_DIR);
434 lstrcatA(inf_filename, "\\");
435 lstrcatA(inf_filename, "test.inf");
437 create_inf_file(inf_filename, inf_data1, sizeof(inf_data1) - 1);
439 hinf = SetupOpenInfFileA(inf_filename, NULL, INF_STYLE_WIN4, NULL);
440 ok(hinf != INVALID_HANDLE_VALUE, "could not open inf file\n");
442 required = 0;
444 ret = SetupGetSourceInfoA(hinf, 2, SRCINFO_PATH, buffer, sizeof(buffer), &required);
445 ok(ret, "SetupGetSourceInfoA failed\n");
447 ok(required == 1, "unexpected required size: %ld\n", required);
448 ok(!lstrcmpA("", buffer), "unexpected result string: %s\n", buffer);
450 required = 0;
451 buffer[0] = 0;
453 ret = SetupGetSourceInfoA(hinf, 2, SRCINFO_TAGFILE, buffer, sizeof(buffer), &required);
454 ok(ret, "SetupGetSourceInfoA failed\n");
456 ok(required == 28, "unexpected required size: %ld\n", required);
457 ok(!lstrcmpA("LANCOM\\LANtools\\lanconf.cab", buffer), "unexpected result string: %s\n", buffer);
459 required = 0;
460 buffer[0] = 0;
462 ret = SetupGetSourceInfoA(hinf, 2, SRCINFO_DESCRIPTION, buffer, sizeof(buffer), &required);
463 ok(ret, "SetupGetSourceInfoA failed\n");
465 ok(required == 19, "unexpected required size: %ld\n", required);
466 ok(!lstrcmpA("LANCOM Software CD", buffer), "unexpected result string: %s\n", buffer);
468 SetupCloseInfFile(hinf);
469 DeleteFileA(inf_filename);
472 static void test_SetupGetTargetPath(void)
474 char buffer[MAX_PATH], inf_filename[MAX_PATH];
475 char destfile[MAX_PATH];
476 DWORD required;
477 HINF hinf;
478 INFCONTEXT ctx;
479 BOOL ret;
481 lstrcpyA(inf_filename, CURR_DIR);
482 lstrcatA(inf_filename, "\\");
483 lstrcatA(inf_filename, "test.inf");
485 create_inf_file(inf_filename, inf_data1, sizeof(inf_data1) - 1);
487 hinf = SetupOpenInfFileA(inf_filename, NULL, INF_STYLE_WIN4, NULL);
488 ok(hinf != INVALID_HANDLE_VALUE, "could not open inf file\n");
490 ctx.Inf = hinf;
491 ctx.CurrentInf = hinf;
492 ctx.Section = 7;
493 ctx.Line = 0;
495 required = 0;
497 ret = SetupGetTargetPathA(hinf, &ctx, NULL, buffer, sizeof(buffer), &required);
498 ok(ret, "SetupGetTargetPathA failed\n");
499 ok(required == 10, "unexpected required size: %ld\n", required);
500 /* Retrieve the system drive from the windows directory.
501 * (%SystemDrive% is not available on Win9x)
503 lstrcpyA(destfile, WIN_DIR);
504 destfile[3] = '\0';
505 lstrcatA(destfile, "LANCOM");
506 ok(!lstrcmpiA(destfile, buffer), "unexpected result string: %s\n", buffer);
508 SetupCloseInfFile(hinf);
509 DeleteFileA(inf_filename);
511 create_inf_file(inf_filename, inf_data3, sizeof(inf_data3) - 1);
513 hinf = SetupOpenInfFileA(inf_filename, NULL, INF_STYLE_WIN4, NULL);
514 ok(hinf != INVALID_HANDLE_VALUE, "could not open inf file\n");
516 required = 0;
518 ret = SetupGetTargetPathA(hinf, NULL, "CopyAlways.Windir.Files", buffer, sizeof(buffer), &required);
519 ok(ret, "SetupGetTargetPathA failed\n");
521 lstrcpyA(destfile, WIN_DIR);
523 ok(required == lstrlenA(destfile) + 1, "unexpected required size: %ld\n", required);
524 ok(!lstrcmpiA(buffer, destfile), "unexpected path: %s\n", buffer);
526 SetupCloseInfFile(hinf);
527 DeleteFileA(inf_filename);
529 create_inf_file(inf_filename, inf_data4, sizeof(inf_data4) - 1);
531 hinf = SetupOpenInfFileA(inf_filename, NULL, INF_STYLE_WIN4, NULL);
532 ok(hinf != INVALID_HANDLE_VALUE, "could not open inf file\n");
534 required = 0;
536 ret = SetupGetTargetPathA(hinf, NULL, "CopyAlways.System32.Files", buffer, sizeof(buffer), &required);
537 ok(ret, "SetupGetTargetPathA failed\n");
539 GetSystemDirectoryA(destfile, MAX_PATH);
541 ok(required == lstrlenA(destfile) + 1, "unexpected required size: %ld\n", required);
542 ok(!lstrcmpiA(buffer, destfile), "unexpected path: %s\n", buffer);
544 SetupCloseInfFile(hinf);
545 DeleteFileA(inf_filename);
547 create_inf_file(inf_filename, inf_data5, sizeof(inf_data5) - 1);
549 hinf = SetupOpenInfFileA(inf_filename, NULL, INF_STYLE_WIN4, NULL);
550 ok(hinf != INVALID_HANDLE_VALUE, "could not open inf file\n");
552 required = 0;
554 ret = SetupGetTargetPathA(hinf, NULL, "CopyAlways.Windir.Files", buffer, sizeof(buffer), &required);
555 ok(ret, "SetupGetTargetPathA failed\n");
557 lstrcpyA(destfile, WIN_DIR);
559 ok(required == lstrlenA(destfile) + 1, "unexpected required size: %ld\n", required);
560 ok(!lstrcmpiA(buffer, destfile), "unexpected path: %s\n", buffer);
562 SetupCloseInfFile(hinf);
563 DeleteFileA(inf_filename);
565 create_inf_file(inf_filename, inf_data6, sizeof(inf_data6) - 1);
567 hinf = SetupOpenInfFileA(inf_filename, NULL, INF_STYLE_WIN4, NULL);
568 ok(hinf != INVALID_HANDLE_VALUE, "could not open inf file\n");
570 required = 0;
572 ret = SetupGetTargetPathA(hinf, NULL, "CopyAlways.Windir.Files", buffer, sizeof(buffer), &required);
573 ok(ret, "SetupGetTargetPathA failed\n");
575 lstrcpyA(destfile, WIN_DIR);
577 ok(required == lstrlenA(destfile) + 1, "unexpected required size: %ld\n", required);
578 ok(!lstrcmpiA(buffer, destfile), "unexpected path: %s\n", buffer);
580 SetupCloseInfFile(hinf);
581 DeleteFileA(inf_filename);
584 START_TEST(query)
586 get_directories();
588 test_SetupGetInfInformation();
589 test_SetupGetSourceFileLocation();
590 test_SetupGetSourceInfo();
591 test_SetupGetTargetPath();