2 * Unit test for setupapi.dll install functions
4 * Copyright 2007 Misha Koshelev
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
35 #include "wine/test.h"
37 static const char inffile
[] = "test.inf";
38 static const WCHAR inffileW
[] = {'t','e','s','t','.','i','n','f',0};
39 static char CURR_DIR
[MAX_PATH
];
41 /* Notes on InstallHinfSectionA/W:
42 * - InstallHinfSectionW on Win98 and InstallHinfSectionA on WinXP seem to be stubs - they do not do anything
43 * and simply return without displaying any error message or setting last error. We test whether
44 * InstallHinfSectionA sets last error, and if it doesn't we set it to NULL and use the W version if available.
45 * - These functions do not return a value and do not always set last error to ERROR_SUCCESS when installation still
46 * occurs (e.g., unquoted inf file with spaces, registry keys are written but last error is 6). Also, on Win98 last error
47 * is set to ERROR_SUCCESS even if install fails (e.g., quoted inf file with spaces, no registry keys set, MessageBox with
48 * "Installation Error" displayed). Thus, we must use functional tests (e.g., is registry key created) to determine whether
49 * or not installation occurred.
50 * - On installation problems, a MessageBox() is displayed and a Beep() is issued. The MessageBox() is disabled with a
54 static void (WINAPI
*pInstallHinfSectionA
)(HWND
, HINSTANCE
, LPCSTR
, INT
);
55 static void (WINAPI
*pInstallHinfSectionW
)(HWND
, HINSTANCE
, LPCWSTR
, INT
);
56 static BOOL (WINAPI
*pSetupGetInfFileListW
)(PCWSTR
, DWORD
, PWSTR
, DWORD
, PDWORD
);
62 static void create_inf_file(LPCSTR filename
, const char *data
)
65 HANDLE handle
= CreateFile(filename
, GENERIC_WRITE
, 0, NULL
,
66 CREATE_ALWAYS
, FILE_ATTRIBUTE_NORMAL
, NULL
);
67 assert(handle
!= INVALID_HANDLE_VALUE
);
68 assert(WriteFile(handle
, data
, strlen(data
), &res
, NULL
));
72 /* CBT hook to ensure a window (e.g., MessageBox) cannot be created */
74 static LRESULT CALLBACK
cbt_hook_proc(int nCode
, WPARAM wParam
, LPARAM lParam
)
76 return nCode
== HCBT_CREATEWND
? 1: CallNextHookEx(hhook
, nCode
, wParam
, lParam
);
83 static const char *cmdline_inf
= "[Version]\n"
84 "Signature=\"$Chicago$\"\n"
86 "AddReg=Add.Settings\n"
88 "HKCU,Software\\Wine\\setupapitest,,\n";
90 static void run_cmdline(LPCSTR section
, int mode
, LPCSTR path
)
92 CHAR cmdline
[MAX_PATH
* 2];
94 sprintf(cmdline
, "%s %d %s", section
, mode
, path
);
95 if (pInstallHinfSectionA
) pInstallHinfSectionA(NULL
, NULL
, cmdline
, 0);
98 WCHAR cmdlinew
[MAX_PATH
* 2];
99 MultiByteToWideChar(CP_ACP
, 0, cmdline
, -1, cmdlinew
, MAX_PATH
*2);
100 pInstallHinfSectionW(NULL
, NULL
, cmdlinew
, 0);
104 static void ok_registry(BOOL expectsuccess
)
108 /* Functional tests for success of install and clean up */
109 ret
= RegDeleteKey(HKEY_CURRENT_USER
, "Software\\Wine\\setupapitest");
110 ok((expectsuccess
&& ret
== ERROR_SUCCESS
) ||
111 (!expectsuccess
&& ret
== ERROR_FILE_NOT_FOUND
),
112 "Expected registry key Software\\Wine\\setupapitest to %s, RegDeleteKey returned %d\n",
113 expectsuccess
? "exist" : "not exist",
117 /* Test command line processing */
118 static void test_cmdline(void)
120 static const char infwithspaces
[] = "test file.inf";
123 create_inf_file(inffile
, cmdline_inf
);
124 sprintf(path
, "%s\\%s", CURR_DIR
, inffile
);
125 run_cmdline("DefaultInstall", 128, path
);
127 ok(DeleteFile(inffile
), "Expected source inf to exist, last error was %d\n", GetLastError());
129 /* Test handling of spaces in path, unquoted and quoted */
130 create_inf_file(infwithspaces
, cmdline_inf
);
132 sprintf(path
, "%s\\%s", CURR_DIR
, infwithspaces
);
133 run_cmdline("DefaultInstall", 128, path
);
136 sprintf(path
, "\"%s\\%s\"", CURR_DIR
, infwithspaces
);
137 run_cmdline("DefaultInstall", 128, path
);
140 ok(DeleteFile(infwithspaces
), "Expected source inf to exist, last error was %d\n", GetLastError());
143 static const char *cmdline_inf_reg
= "[Version]\n"
144 "Signature=\"$Chicago$\"\n"
146 "DelReg=Del.Settings\n"
148 "HKCU,Software\\Wine\\setupapitest\n";
150 static void test_registry(void)
156 /* First create a registry structure we would like to be deleted */
157 ok(!RegCreateKeyA(HKEY_CURRENT_USER
, "Software\\Wine\\setupapitest\\setupapitest", &key
),
158 "Expected RegCreateKeyA to succeed\n");
160 /* Doublecheck if the registry key is present */
161 ok(!RegOpenKeyA(HKEY_CURRENT_USER
, "Software\\Wine\\setupapitest\\setupapitest", &key
),
162 "Expected registry key to exist\n");
164 create_inf_file(inffile
, cmdline_inf_reg
);
165 sprintf(path
, "%s\\%s", CURR_DIR
, inffile
);
166 run_cmdline("DefaultInstall", 128, path
);
168 /* Check if the registry key is recursively deleted */
169 res
= RegOpenKeyA(HKEY_CURRENT_USER
, "Software\\Wine\\setupapitest", &key
);
171 ok(res
== ERROR_FILE_NOT_FOUND
, "Didn't expect the registry key to exist\n");
173 if (res
== ERROR_SUCCESS
)
175 RegDeleteKeyA(HKEY_CURRENT_USER
, "Software\\Wine\\setupapitest\\setupapitest");
176 RegDeleteKeyA(HKEY_CURRENT_USER
, "Software\\Wine\\setupapitest");
178 ok(DeleteFile(inffile
), "Expected source inf to exist, last error was %d\n", GetLastError());
181 static void test_install_svc_from(void)
187 SC_HANDLE scm_handle
, svc_handle
;
189 /* Bail out if we are on win98 */
190 SetLastError(0xdeadbeef);
191 scm_handle
= OpenSCManagerA(NULL
, NULL
, GENERIC_ALL
);
193 if (!scm_handle
&& (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED
))
195 win_skip("OpenSCManagerA is not implemented, we are most likely on win9x\n");
198 CloseServiceHandle(scm_handle
);
200 /* Basic inf file to satisfy SetupOpenInfFileA */
201 strcpy(inf
, "[Version]\nSignature=\"$Chicago$\"\n");
202 create_inf_file(inffile
, inf
);
203 sprintf(path
, "%s\\%s", CURR_DIR
, inffile
);
204 infhandle
= SetupOpenInfFileA(path
, NULL
, INF_STYLE_WIN4
, NULL
);
206 /* Nothing but the Version section */
207 SetLastError(0xdeadbeef);
208 ret
= SetupInstallServicesFromInfSectionA(infhandle
, "Winetest.Services", 0);
209 ok(!ret
, "Expected failure\n");
210 ok(GetLastError() == ERROR_SECTION_NOT_FOUND
,
211 "Expected ERROR_SECTION_NOT_FOUND, got %08x\n", GetLastError());
212 SetupCloseInfFile(infhandle
);
215 /* Add the section */
216 strcat(inf
, "[Winetest.Services]\n");
217 create_inf_file(inffile
, inf
);
218 infhandle
= SetupOpenInfFileA(path
, NULL
, INF_STYLE_WIN4
, NULL
);
219 SetLastError(0xdeadbeef);
220 ret
= SetupInstallServicesFromInfSectionA(infhandle
, "Winetest.Services", 0);
221 ok(!ret
, "Expected failure\n");
222 ok(GetLastError() == ERROR_SECTION_NOT_FOUND
,
223 "Expected ERROR_SECTION_NOT_FOUND, got %08x\n", GetLastError());
224 SetupCloseInfFile(infhandle
);
227 /* Add a reference */
228 strcat(inf
, "AddService=Winetest,,Winetest.Service\n");
229 create_inf_file(inffile
, inf
);
230 infhandle
= SetupOpenInfFileA(path
, NULL
, INF_STYLE_WIN4
, NULL
);
231 SetLastError(0xdeadbeef);
232 ret
= SetupInstallServicesFromInfSectionA(infhandle
, "Winetest.Services", 0);
233 ok(!ret
, "Expected failure\n");
234 ok(GetLastError() == ERROR_BAD_SERVICE_INSTALLSECT
,
235 "Expected ERROR_BAD_SERVICE_INSTALLSECT, got %08x\n", GetLastError());
236 SetupCloseInfFile(infhandle
);
239 /* Add the section */
240 strcat(inf
, "[Winetest.Service]\n");
241 create_inf_file(inffile
, inf
);
242 infhandle
= SetupOpenInfFileA(path
, NULL
, INF_STYLE_WIN4
, NULL
);
243 SetLastError(0xdeadbeef);
244 ret
= SetupInstallServicesFromInfSectionA(infhandle
, "Winetest.Services", 0);
245 ok(!ret
, "Expected failure\n");
246 ok(GetLastError() == ERROR_BAD_SERVICE_INSTALLSECT
,
247 "Expected ERROR_BAD_SERVICE_INSTALLSECT, got %08x\n", GetLastError());
248 SetupCloseInfFile(infhandle
);
251 /* Just the ServiceBinary */
252 strcat(inf
, "ServiceBinary=%12%\\winetest.sys\n");
253 create_inf_file(inffile
, inf
);
254 infhandle
= SetupOpenInfFileA(path
, NULL
, INF_STYLE_WIN4
, NULL
);
255 SetLastError(0xdeadbeef);
256 ret
= SetupInstallServicesFromInfSectionA(infhandle
, "Winetest.Services", 0);
257 ok(!ret
, "Expected failure\n");
258 ok(GetLastError() == ERROR_BAD_SERVICE_INSTALLSECT
,
259 "Expected ERROR_BAD_SERVICE_INSTALLSECT, got %08x\n", GetLastError());
260 SetupCloseInfFile(infhandle
);
263 /* Add the ServiceType */
264 strcat(inf
, "ServiceType=1\n");
265 create_inf_file(inffile
, inf
);
266 infhandle
= SetupOpenInfFileA(path
, NULL
, INF_STYLE_WIN4
, NULL
);
267 SetLastError(0xdeadbeef);
268 ret
= SetupInstallServicesFromInfSectionA(infhandle
, "Winetest.Services", 0);
269 ok(!ret
, "Expected failure\n");
270 ok(GetLastError() == ERROR_BAD_SERVICE_INSTALLSECT
,
271 "Expected ERROR_BAD_SERVICE_INSTALLSECT, got %08x\n", GetLastError());
272 SetupCloseInfFile(infhandle
);
275 /* Add the StartType */
276 strcat(inf
, "StartType=4\n");
277 create_inf_file(inffile
, inf
);
278 infhandle
= SetupOpenInfFileA(path
, NULL
, INF_STYLE_WIN4
, NULL
);
279 SetLastError(0xdeadbeef);
280 ret
= SetupInstallServicesFromInfSectionA(infhandle
, "Winetest.Services", 0);
281 ok(!ret
, "Expected failure\n");
282 ok(GetLastError() == ERROR_BAD_SERVICE_INSTALLSECT
,
283 "Expected ERROR_BAD_SERVICE_INSTALLSECT, got %08x\n", GetLastError());
284 SetupCloseInfFile(infhandle
);
287 /* This should be it, the minimal entries to install a service */
288 strcat(inf
, "ErrorControl=1");
289 create_inf_file(inffile
, inf
);
290 infhandle
= SetupOpenInfFileA(path
, NULL
, INF_STYLE_WIN4
, NULL
);
291 SetLastError(0xdeadbeef);
292 ret
= SetupInstallServicesFromInfSectionA(infhandle
, "Winetest.Services", 0);
293 if (!ret
&& GetLastError() == ERROR_ACCESS_DENIED
)
295 skip("Not enough rights to install the service\n");
296 SetupCloseInfFile(infhandle
);
300 ok(ret
, "Expected success\n");
301 ok(GetLastError() == ERROR_SUCCESS
,
302 "Expected ERROR_SUCCESS, got %08x\n", GetLastError());
303 SetupCloseInfFile(infhandle
);
306 scm_handle
= OpenSCManagerA(NULL
, NULL
, GENERIC_ALL
);
308 /* Open the service to see if it's really there */
309 svc_handle
= OpenServiceA(scm_handle
, "Winetest", DELETE
);
310 ok(svc_handle
!= NULL
, "Service was not created\n");
312 SetLastError(0xdeadbeef);
313 ret
= DeleteService(svc_handle
);
314 ok(ret
, "Service could not be deleted : %d\n", GetLastError());
316 CloseServiceHandle(svc_handle
);
317 CloseServiceHandle(scm_handle
);
319 /* TODO: Test the Flags */
322 static void test_driver_install(void)
325 SC_HANDLE scm_handle
, svc_handle
;
327 char path
[MAX_PATH
], windir
[MAX_PATH
], driver
[MAX_PATH
];
329 /* Minimal stuff needed */
330 static const char *inf
=
332 "Signature=\"$Chicago$\"\n"
333 "[DestinationDirs]\n"
334 "Winetest.DriverFiles=12\n"
336 "CopyFiles=Winetest.DriverFiles\n"
337 "[DefaultInstall.Services]\n"
338 "AddService=Winetest,,Winetest.Service\n"
339 "[Winetest.Service]\n"
340 "ServiceBinary=%12%\\winetest.sys\n"
344 "[Winetest.DriverFiles]\n"
347 /* Bail out if we are on win98 */
348 SetLastError(0xdeadbeef);
349 scm_handle
= OpenSCManagerA(NULL
, NULL
, GENERIC_ALL
);
351 if (!scm_handle
&& (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED
))
353 win_skip("OpenSCManagerA is not implemented, we are most likely on win9x\n");
356 else if (!scm_handle
&& (GetLastError() == ERROR_ACCESS_DENIED
))
358 skip("Not enough rights to install the service\n");
361 CloseServiceHandle(scm_handle
);
363 /* Place where we expect the driver to be installed */
364 GetWindowsDirectoryA(windir
, MAX_PATH
);
365 lstrcpyA(driver
, windir
);
366 lstrcatA(driver
, "\\system32\\drivers\\winetest.sys");
368 /* Create a dummy driver file */
369 handle
= CreateFileA("winetest.sys", GENERIC_WRITE
, 0, NULL
,
370 CREATE_ALWAYS
, FILE_ATTRIBUTE_NORMAL
, NULL
);
373 create_inf_file(inffile
, inf
);
374 sprintf(path
, "%s\\%s", CURR_DIR
, inffile
);
375 run_cmdline("DefaultInstall", 128, path
);
377 /* Driver should have been installed */
378 attrs
= GetFileAttributes(driver
);
379 ok(attrs
!= INVALID_FILE_ATTRIBUTES
, "Expected driver to exist\n");
381 scm_handle
= OpenSCManagerA(NULL
, NULL
, GENERIC_ALL
);
383 /* Open the service to see if it's really there */
384 svc_handle
= OpenServiceA(scm_handle
, "Winetest", DELETE
);
385 ok(svc_handle
!= NULL
, "Service was not created\n");
387 SetLastError(0xdeadbeef);
388 ret
= DeleteService(svc_handle
);
389 ok(ret
, "Service could not be deleted : %d\n", GetLastError());
391 CloseServiceHandle(svc_handle
);
392 CloseServiceHandle(scm_handle
);
396 DeleteFile("winetest.sys");
400 static void test_profile_items(void)
402 char path
[MAX_PATH
], commonprogs
[MAX_PATH
];
404 BOOL (WINAPI
*pSHGetFolderPathA
)(HWND hwnd
, int nFolder
, HANDLE hToken
, DWORD dwFlags
, LPSTR pszPath
);
406 static const char *inf
=
408 "Signature=\"$Chicago$\"\n"
410 "ProfileItems=TestItem,TestItem2,TestGroup\n"
413 "CmdLine=11,,notepad.exe\n"
416 "CmdLine=11,,notepad.exe\n"
422 hShell32
= LoadLibraryA("shell32");
423 pSHGetFolderPathA
= (void*)GetProcAddress(hShell32
, "SHGetFolderPathA");
424 if (!pSHGetFolderPathA
)
426 win_skip("SHGetFolderPathA is not available\n");
430 if (S_OK
!= pSHGetFolderPathA(NULL
, CSIDL_COMMON_PROGRAMS
, NULL
, SHGFP_TYPE_CURRENT
, commonprogs
))
432 skip("No common program files directory exists\n");
436 create_inf_file(inffile
, inf
);
437 sprintf(path
, "%s\\%s", CURR_DIR
, inffile
);
438 run_cmdline("DefaultInstall", 128, path
);
440 snprintf(path
, MAX_PATH
, "%s\\TestItem.lnk", commonprogs
);
441 if (INVALID_FILE_ATTRIBUTES
== GetFileAttributes(path
))
443 win_skip("ProfileItems not implemented on this system\n");
447 snprintf(path
, MAX_PATH
, "%s\\TestDir", commonprogs
);
448 ok(INVALID_FILE_ATTRIBUTES
!= GetFileAttributes(path
), "directory not created\n");
449 snprintf(path
, MAX_PATH
, "%s\\TestDir\\TestItem2.lnk", commonprogs
);
450 ok(INVALID_FILE_ATTRIBUTES
!= GetFileAttributes(path
), "link not created\n");
451 snprintf(path
, MAX_PATH
, "%s\\TestGroup", commonprogs
);
452 ok(INVALID_FILE_ATTRIBUTES
!= GetFileAttributes(path
), "group not created\n");
455 snprintf(path
, MAX_PATH
, "%s\\TestItem.lnk", commonprogs
);
457 snprintf(path
, MAX_PATH
, "%s\\TestDir\\TestItem2.lnk", commonprogs
);
459 snprintf(path
, MAX_PATH
, "%s\\TestItem2.lnk", commonprogs
);
461 snprintf(path
, MAX_PATH
, "%s\\TestDir", commonprogs
);
462 RemoveDirectory(path
);
463 snprintf(path
, MAX_PATH
, "%s\\TestGroup", commonprogs
);
464 RemoveDirectory(path
);
467 if (hShell32
) FreeLibrary(hShell32
);
471 static void test_inffilelist(void)
473 static const char inffile2
[] = "test2.inf";
474 static const WCHAR inffile2W
[] = {'t','e','s','t','2','.','i','n','f',0};
475 static const char invalid_inf
[] = "invalid.inf";
476 static const WCHAR invalid_infW
[] = {'i','n','v','a','l','i','d','.','i','n','f',0};
477 static const char *inf
=
479 "Signature=\"$Chicago$\"";
480 static const char *inf2
=
482 "Signature=\"$CHICAGO$\"";
483 static const char *infNT
=
485 "Signature=\"$WINDOWS NT$\"";
489 WCHAR dir
[MAX_PATH
] = { 0 };
490 WCHAR buffer
[MAX_PATH
] = { 0 };
491 DWORD expected
, outsize
;
494 if(!pSetupGetInfFileListW
)
496 win_skip("SetupGetInfFileListW not present\n");
500 /* NULL means %windir%\\inf
501 * get the value as reference
504 SetLastError(0xdeadbeef);
505 ret
= pSetupGetInfFileListW(NULL
, INF_STYLE_WIN4
, NULL
, 0, &expected
);
506 if (!ret
&& GetLastError() == ERROR_CALL_NOT_IMPLEMENTED
)
508 win_skip("SetupGetInfFileListW not implemented\n");
511 ok(ret
, "expected SetupGetInfFileListW to succeed! Error: %d\n", GetLastError());
512 ok(expected
> 0, "expected required buffersize to be at least 1\n");
514 /* check if an empty string doesn't behaves like NULL */
516 SetLastError(0xdeadbeef);
517 ret
= pSetupGetInfFileListW(dir
, INF_STYLE_WIN4
, NULL
, 0, &outsize
);
518 ok(!ret
, "expected SetupGetInfFileListW to fail!\n");
520 /* create a private directory, the temp directory may contain some
521 * inf files left over from old installations
523 if (!GetTempFileNameA(CURR_DIR
, "inftest", 1, dirA
))
525 win_skip("GetTempFileNameA failed with error %d\n", GetLastError());
528 if (!CreateDirectoryA(dirA
, NULL
))
530 win_skip("CreateDirectoryA(%s) failed with error %d\n", dirA
, GetLastError());
533 if (!SetCurrentDirectoryA(dirA
))
535 win_skip("SetCurrentDirectoryA failed with error %d\n", GetLastError());
536 RemoveDirectoryA(dirA
);
540 MultiByteToWideChar(CP_ACP
, 0, dirA
, -1, dir
, MAX_PATH
);
541 /* check a not existing directory
543 ptr
= dir
+ lstrlenW(dir
);
544 MultiByteToWideChar(CP_ACP
, 0, "\\not_existent", -1, ptr
, MAX_PATH
- lstrlenW(dir
));
545 outsize
= 0xffffffff;
546 SetLastError(0xdeadbeef);
547 ret
= pSetupGetInfFileListW(dir
, INF_STYLE_WIN4
, NULL
, 0, &outsize
);
548 ok(ret
, "expected SetupGetInfFileListW to succeed!\n");
549 ok(outsize
== 1, "expected required buffersize to be 1, got %d\n", outsize
);
550 ok(ERROR_PATH_NOT_FOUND
== GetLastError(),
551 "expected error ERROR_PATH_NOT_FOUND, got %d\n", GetLastError());
553 create_inf_file(inffile
, inf
);
554 create_inf_file(inffile2
, inf
);
555 create_inf_file(invalid_inf
, "This content does not match the inf file format");
557 /* pass a filename instead of a directory
560 MultiByteToWideChar(CP_ACP
, 0, invalid_inf
, -1, ptr
+1, MAX_PATH
- lstrlenW(dir
));
561 outsize
= 0xffffffff;
562 SetLastError(0xdeadbeef);
563 ret
= pSetupGetInfFileListW(dir
, INF_STYLE_WIN4
, NULL
, 0, &outsize
);
564 ok(!ret
, "expected SetupGetInfFileListW to fail!\n");
565 ok(ERROR_DIRECTORY
== GetLastError(),
566 "expected error ERROR_DIRECTORY, got %d\n", GetLastError());
568 /* make the filename look like directory
570 dir
[1 + lstrlenW(dir
)] = 0;
571 dir
[lstrlenW(dir
)] = '\\';
572 SetLastError(0xdeadbeef);
573 ret
= pSetupGetInfFileListW(dir
, INF_STYLE_WIN4
, NULL
, 0, &outsize
);
574 ok(!ret
, "expected SetupGetInfFileListW to fail!\n");
575 ok(ERROR_DIRECTORY
== GetLastError(),
576 "expected error ERROR_DIRECTORY, got %d\n", GetLastError());
578 /* now check the buffer content of a vaild call
581 expected
= 3 + strlen(inffile
) + strlen(inffile2
);
582 ret
= pSetupGetInfFileListW(dir
, INF_STYLE_WIN4
, buffer
, MAX_PATH
, &outsize
);
583 ok(ret
, "expected SetupGetInfFileListW to succeed!\n");
584 ok(expected
== outsize
, "expected required buffersize to be %d, got %d\n",
586 for(p
= buffer
; lstrlenW(p
) && (outsize
> (p
- buffer
)); p
+=lstrlenW(p
) + 1)
587 ok(!lstrcmpW(p
,inffile2W
) || !lstrcmpW(p
,inffileW
),
588 "unexpected filename %s\n",wine_dbgstr_w(p
));
592 create_inf_file(inffile2
, inf2
);
593 ret
= pSetupGetInfFileListW(dir
, INF_STYLE_WIN4
, buffer
, MAX_PATH
, &outsize
);
594 ok(ret
, "expected SetupGetInfFileListW to succeed!\n");
595 ok(expected
== outsize
, "expected required buffersize to be %d, got %d\n",
597 for(p
= buffer
; lstrlenW(p
) && (outsize
> (p
- buffer
)); p
+=lstrlenW(p
) + 1)
598 ok(!lstrcmpW(p
,inffile2W
) || !lstrcmpW(p
,inffileW
),
599 "unexpected filename %s\n",wine_dbgstr_w(p
));
601 /* signature Windows NT is also inf style win4
603 create_inf_file(inffile2
, infNT
);
604 expected
= 3 + strlen(inffile
) + strlen(inffile2
);
605 ret
= pSetupGetInfFileListW(dir
, INF_STYLE_WIN4
, buffer
, MAX_PATH
, &outsize
);
606 ok(ret
, "expected SetupGetInfFileListW to succeed!\n");
607 ok(expected
== outsize
, "expected required buffersize to be %d, got %d\n",
609 for(p
= buffer
; lstrlenW(p
) && (outsize
> (p
- buffer
)); p
+=lstrlenW(p
) + 1)
610 ok(!lstrcmpW(p
,inffile2W
) || !lstrcmpW(p
,inffileW
),
611 "unexpected filename %s\n",wine_dbgstr_w(p
));
615 expected
= 2 + strlen(invalid_inf
);
616 ret
= pSetupGetInfFileListW(dir
, INF_STYLE_OLDNT
, buffer
, MAX_PATH
, &outsize
);
617 ok(ret
, "expected SetupGetInfFileListW to succeed!\n");
618 ok(expected
== outsize
, "expected required buffersize to be %d, got %d\n",
620 for(p
= buffer
; lstrlenW(p
) && (outsize
> (p
- buffer
)); p
+=lstrlenW(p
) + 1)
621 ok(!lstrcmpW(p
,invalid_infW
), "unexpected filename %s\n",wine_dbgstr_w(p
));
625 expected
= 4 + strlen(inffile
) + strlen(inffile2
) + strlen(invalid_inf
);
626 ret
= pSetupGetInfFileListW(dir
, INF_STYLE_OLDNT
| INF_STYLE_WIN4
, buffer
,
628 ok(ret
, "expected SetupGetInfFileListW to succeed!\n");
629 ok(expected
== outsize
, "expected required buffersize to be %d, got %d\n",
631 for(p
= buffer
; lstrlenW(p
) && (outsize
> (p
- buffer
)); p
+=lstrlenW(p
) + 1)
632 ok(!lstrcmpW(p
,inffile2W
) || !lstrcmpW(p
,inffileW
) || !lstrcmpW(p
,invalid_infW
),
633 "unexpected filename %s\n",wine_dbgstr_w(p
));
636 DeleteFile(inffile2
);
637 DeleteFile(invalid_inf
);
638 SetCurrentDirectoryA(CURR_DIR
);
639 RemoveDirectoryA(dirA
);
644 HMODULE hsetupapi
= GetModuleHandle("setupapi.dll");
645 char temp_path
[MAX_PATH
], prev_path
[MAX_PATH
];
648 GetCurrentDirectory(MAX_PATH
, prev_path
);
649 GetTempPath(MAX_PATH
, temp_path
);
650 SetCurrentDirectory(temp_path
);
652 strcpy(CURR_DIR
, temp_path
);
653 len
= strlen(CURR_DIR
);
654 if(len
&& (CURR_DIR
[len
- 1] == '\\'))
655 CURR_DIR
[len
- 1] = 0;
657 pInstallHinfSectionA
= (void *)GetProcAddress(hsetupapi
, "InstallHinfSectionA");
658 pInstallHinfSectionW
= (void *)GetProcAddress(hsetupapi
, "InstallHinfSectionW");
659 pSetupGetInfFileListW
= (void *)GetProcAddress(hsetupapi
, "SetupGetInfFileListW");
661 if (pInstallHinfSectionA
)
663 /* Check if pInstallHinfSectionA sets last error or is a stub (as on WinXP) */
664 static const char *minimal_inf
= "[Version]\nSignature=\"$Chicago$\"\n";
665 char cmdline
[MAX_PATH
*2];
666 create_inf_file(inffile
, minimal_inf
);
667 sprintf(cmdline
, "DefaultInstall 128 %s\\%s", CURR_DIR
, inffile
);
668 SetLastError(0xdeadbeef);
669 pInstallHinfSectionA(NULL
, NULL
, cmdline
, 0);
670 if (GetLastError() == 0xdeadbeef)
672 skip("InstallHinfSectionA is broken (stub)\n");
673 pInstallHinfSectionA
= NULL
;
675 ok(DeleteFile(inffile
), "Expected source inf to exist, last error was %d\n", GetLastError());
677 if (!pInstallHinfSectionW
&& !pInstallHinfSectionA
)
678 win_skip("InstallHinfSectionA and InstallHinfSectionW are not available\n");
681 /* Set CBT hook to disallow MessageBox creation in current thread */
682 hhook
= SetWindowsHookExA(WH_CBT
, cbt_hook_proc
, 0, GetCurrentThreadId());
687 test_install_svc_from();
688 test_driver_install();
690 UnhookWindowsHookEx(hhook
);
692 /* We have to run this test after the CBT hook is disabled because
693 ProfileItems needs to create a window on Windows XP. */
694 test_profile_items();
699 SetCurrentDirectory(prev_path
);