2 * Advpack install functions
4 * Copyright 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
33 #include "wine/debug.h"
34 #include "wine/unicode.h"
35 #include "advpack_private.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(advpack);
39 #define SPAPI_ERROR 0xE0000000L
40 #define SPAPI_PREFIX 0x800F0000L
41 #define SPAPI_MASK 0xFFFFL
42 #define HRESULT_FROM_SPAPI(x) ((x & SPAPI_MASK) | SPAPI_PREFIX)
44 #define ADV_HRESULT(x) ((x & SPAPI_ERROR) ? HRESULT_FROM_SPAPI(x) : HRESULT_FROM_WIN32(x))
46 /* contains information about a specific install instance */
47 typedef struct _ADVInfo
57 typedef HRESULT (*iterate_fields_func)(HINF hinf, PCWSTR field, void *arg);
59 /* Advanced INF commands */
60 static const WCHAR CheckAdminRights[] = {
61 'C','h','e','c','k','A','d','m','i','n','R','i','g','h','t','s',0
63 static const WCHAR DelDirs[] = {'D','e','l','D','i','r','s',0};
64 static const WCHAR PerUserInstall[] = {'P','e','r','U','s','e','r','I','n','s','t','a','l','l',0};
65 static const WCHAR RegisterOCXs[] = {'R','e','g','i','s','t','e','r','O','C','X','s',0};
66 static const WCHAR RunPreSetupCommands[] = {
67 'R','u','n','P','r','e','S','e','t','u','p','C','o','m','m','a','n','d','s',0
69 static const WCHAR RunPostSetupCommands[] = {
70 'R','u','n','P','o','s','t','S','e','t','u','p','C','o','m','m','a','n','d','s',0
73 /* Advanced INF callbacks */
74 static HRESULT del_dirs_callback(HINF hinf, PCWSTR field, void *arg)
80 BOOL ok = SetupFindFirstLineW(hinf, field, NULL, &context);
82 for (; ok; ok = SetupFindNextLine(&context, &context))
84 WCHAR directory[MAX_INF_STRING_LENGTH];
86 if (!SetupGetLineTextW(&context, NULL, NULL, NULL, directory,
87 MAX_INF_STRING_LENGTH, &size))
90 if (DelNodeW(directory, ADN_DEL_IF_EMPTY))
97 static HRESULT per_user_install_callback(HINF hinf, PCWSTR field, void *arg)
99 PERUSERSECTIONW per_user;
103 static const WCHAR disp_name[] = {'D','i','s','p','l','a','y','N','a','m','e',0};
104 static const WCHAR version[] = {'V','e','r','s','i','o','n',0};
105 static const WCHAR is_installed[] = {'I','s','I','n','s','t','a','l','l','e','d',0};
106 static const WCHAR comp_id[] = {'C','o','m','p','o','n','e','n','t','I','D',0};
107 static const WCHAR guid[] = {'G','U','I','D',0};
108 static const WCHAR locale[] = {'L','o','c','a','l','e',0};
109 static const WCHAR stub_path[] = {'S','t','u','b','P','a','t','h',0};
111 per_user.bRollback = FALSE;
112 per_user.dwIsInstalled = 0;
114 SetupGetLineTextW(NULL, hinf, field, disp_name, per_user.szDispName,
115 sizeof(per_user.szDispName) / sizeof(WCHAR), &size);
117 SetupGetLineTextW(NULL, hinf, field, version, per_user.szVersion,
118 sizeof(per_user.szVersion) / sizeof(WCHAR), &size);
120 if (SetupFindFirstLineW(hinf, field, is_installed, &context))
122 SetupGetIntField(&context, 1, (PINT)&per_user.dwIsInstalled);
125 SetupGetLineTextW(NULL, hinf, field, comp_id, per_user.szCompID,
126 sizeof(per_user.szCompID) / sizeof(WCHAR), &size);
128 SetupGetLineTextW(NULL, hinf, field, guid, per_user.szGUID,
129 sizeof(per_user.szGUID) / sizeof(WCHAR), &size);
131 SetupGetLineTextW(NULL, hinf, field, locale, per_user.szLocale,
132 sizeof(per_user.szLocale) / sizeof(WCHAR), &size);
134 SetupGetLineTextW(NULL, hinf, field, stub_path, per_user.szStub,
135 sizeof(per_user.szStub) / sizeof(WCHAR), &size);
137 return SetPerUserSecValuesW(&per_user);
140 static HRESULT register_ocxs_callback(HINF hinf, PCWSTR field, void *arg)
146 BOOL ok = SetupFindFirstLineW(hinf, field, NULL, &context);
148 for (; ok; ok = SetupFindNextLine(&context, &context))
150 WCHAR buffer[MAX_INF_STRING_LENGTH];
152 /* get OCX filename */
153 if (!SetupGetStringFieldW(&context, 1, buffer,
154 sizeof(buffer) / sizeof(WCHAR), NULL))
157 hm = LoadLibraryExW(buffer, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
161 if (do_ocx_reg(hm, TRUE))
170 static HRESULT run_setup_commands_callback(HINF hinf, PCWSTR field, void *arg)
172 ADVInfo *info = (ADVInfo *)arg;
177 BOOL ok = SetupFindFirstLineW(hinf, field, NULL, &context);
179 for (; ok; ok = SetupFindNextLine(&context, &context))
181 WCHAR buffer[MAX_INF_STRING_LENGTH];
183 if (!SetupGetLineTextW(&context, NULL, NULL, NULL, buffer,
184 MAX_INF_STRING_LENGTH, &size))
187 if (launch_exe(buffer, info->working_dir, NULL))
194 /* sequentially returns pointers to parameters in a parameter list
195 * returns NULL if the parameter is empty, e.g. one,,three */
196 LPWSTR get_parameter(LPWSTR *params, WCHAR separator)
198 LPWSTR token = *params;
203 *params = strchrW(*params, separator);
213 static BOOL is_full_path(LPWSTR path)
215 const int MIN_PATH_LEN = 3;
217 if (!path || lstrlenW(path) < MIN_PATH_LEN)
220 if (path[1] == ':' || (path[0] == '\\' && path[1] == '\\'))
226 /* retrieves the contents of a field, dynamically growing the buffer if necessary */
227 static WCHAR *get_field_string(INFCONTEXT *context, DWORD index, WCHAR *buffer,
228 WCHAR *static_buffer, DWORD *size)
232 if (SetupGetStringFieldW(context, index, buffer, *size, &required)) return buffer;
234 if (GetLastError() == ERROR_INSUFFICIENT_BUFFER)
236 /* now grow the buffer */
237 if (buffer != static_buffer) HeapFree(GetProcessHeap(), 0, buffer);
238 if (!(buffer = HeapAlloc(GetProcessHeap(), 0, required*sizeof(WCHAR)))) return NULL;
240 if (SetupGetStringFieldW(context, index, buffer, *size, &required)) return buffer;
243 if (buffer != static_buffer) HeapFree(GetProcessHeap(), 0, buffer);
247 /* iterates over all fields of a certain key of a certain section */
248 static HRESULT iterate_section_fields(HINF hinf, PCWSTR section, PCWSTR key,
249 iterate_fields_func callback, void *arg)
251 WCHAR static_buffer[200];
252 WCHAR *buffer = static_buffer;
253 DWORD size = sizeof(static_buffer) / sizeof(WCHAR);
257 BOOL ok = SetupFindFirstLineW(hinf, section, key, &context);
260 UINT i, count = SetupGetFieldCount(&context);
262 for (i = 1; i <= count; i++)
264 if (!(buffer = get_field_string(&context, i, buffer, static_buffer, &size)))
267 if ((hr = callback(hinf, buffer, arg)) != S_OK)
271 ok = SetupFindNextMatchLineW(&context, key, &context);
277 if (buffer && buffer != static_buffer) HeapFree(GetProcessHeap(), 0, buffer);
281 static HRESULT check_admin_rights(ADVInfo *info)
287 if (!SetupFindFirstLineW(info->hinf, info->install_sec,
288 CheckAdminRights, &context))
291 if (!SetupGetIntField(&context, 1, &check))
295 hr = IsNTAdmin(0, NULL) ? S_OK : E_FAIL;
300 /* performs a setupapi-level install of the INF file */
301 static HRESULT spapi_install(ADVInfo *info)
307 context = SetupInitDefaultQueueCallbackEx(NULL, INVALID_HANDLE_VALUE, 0, 0, NULL);
309 return ADV_HRESULT(GetLastError());
311 ret = SetupInstallFromInfSectionW(NULL, info->hinf, info->install_sec,
312 SPINST_FILES, NULL, info->working_dir,
313 SP_COPY_NEWER, SetupDefaultQueueCallbackW,
314 context, NULL, NULL);
317 res = ADV_HRESULT(GetLastError());
318 SetupTermDefaultQueueCallback(context);
323 SetupTermDefaultQueueCallback(context);
325 ret = SetupInstallFromInfSectionW(NULL, info->hinf, info->install_sec,
326 SPINST_INIFILES | SPINST_REGISTRY,
327 HKEY_LOCAL_MACHINE, NULL, 0,
328 NULL, NULL, NULL, NULL);
330 return ADV_HRESULT(GetLastError());
335 /* processes the Advanced INF commands */
336 static HRESULT adv_install(ADVInfo *info)
340 hr = check_admin_rights(info);
344 hr = iterate_section_fields(info->hinf, info->install_sec, RunPreSetupCommands,
345 run_setup_commands_callback, info);
349 hr = iterate_section_fields(info->hinf, info->install_sec,
350 RegisterOCXs, register_ocxs_callback, NULL);
354 hr = iterate_section_fields(info->hinf, info->install_sec,
355 PerUserInstall, per_user_install_callback, info);
359 hr = iterate_section_fields(info->hinf, info->install_sec, RunPostSetupCommands,
360 run_setup_commands_callback, info);
364 hr = iterate_section_fields(info->hinf, info->install_sec,
365 DelDirs, del_dirs_callback, info);
372 /* loads the INF file and performs checks on it */
373 HRESULT install_init(LPCWSTR inf_filename, LPCWSTR install_sec,
374 LPCWSTR working_dir, DWORD flags, ADVInfo *info)
379 static const WCHAR default_install[] = {
380 'D','e','f','a','u','l','t','I','n','s','t','a','l','l',0
383 len = lstrlenW(inf_filename);
385 info->inf_filename = HeapAlloc(GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR));
386 if (!info->inf_filename)
387 return E_OUTOFMEMORY;
389 lstrcpyW(info->inf_filename, inf_filename);
391 /* FIXME: determine the proper platform to install (NTx86, etc) */
392 if (!install_sec || !*install_sec)
394 len = sizeof(default_install) - 1;
395 ptr = default_install;
399 len = lstrlenW(install_sec);
403 info->install_sec = HeapAlloc(GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR));
404 if (!info->install_sec)
405 return E_OUTOFMEMORY;
407 lstrcpyW(info->install_sec, ptr);
409 /* FIXME: need to get the real working directory */
410 if (!working_dir || !*working_dir)
412 ptr = strrchrW(info->inf_filename, '\\');
413 len = ptr - info->inf_filename + 1;
414 ptr = info->inf_filename;
418 len = lstrlenW(working_dir) + 1;
422 info->working_dir = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
423 if (!info->working_dir)
424 return E_OUTOFMEMORY;
426 lstrcpynW(info->working_dir, ptr, len);
428 info->hinf = SetupOpenInfFileW(info->inf_filename, NULL, INF_STYLE_WIN4, NULL);
429 if (info->hinf == INVALID_HANDLE_VALUE)
430 return ADV_HRESULT(GetLastError());
432 set_ldids(info->hinf, info->install_sec, info->working_dir);
434 /* FIXME: check that the INF is advanced */
437 info->need_reboot = FALSE;
442 /* release the install instance information */
443 void install_release(ADVInfo *info)
445 if (info->hinf && info->hinf != INVALID_HANDLE_VALUE)
446 SetupCloseInfFile(info->hinf);
448 HeapFree(GetProcessHeap(), 0, info->inf_filename);
449 HeapFree(GetProcessHeap(), 0, info->install_sec);
450 HeapFree(GetProcessHeap(), 0, info->working_dir);
453 /* this structure very closely resembles parameters of RunSetupCommand() */
461 } SETUPCOMMAND_PARAMS;
463 /***********************************************************************
464 * DoInfInstall (ADVPACK.@)
466 * Install an INF section.
469 * setup [I] Structure containing install information.
473 * HRESULT_FROM_WIN32(GetLastError()) Some other error
475 HRESULT WINAPI DoInfInstall(const SETUPCOMMAND_PARAMS *setup)
479 void *callback_context;
481 TRACE("(%p)\n", setup);
483 hinf = SetupOpenInfFileA(setup->inf_name, NULL, INF_STYLE_WIN4, NULL);
484 if (hinf == INVALID_HANDLE_VALUE) return HRESULT_FROM_WIN32(GetLastError());
486 callback_context = SetupInitDefaultQueueCallback(setup->hwnd);
488 ret = SetupInstallFromInfSectionA(NULL, hinf, setup->section_name, SPINST_ALL,
489 NULL, NULL, 0, SetupDefaultQueueCallbackA,
490 callback_context, NULL, NULL);
491 SetupTermDefaultQueueCallback(callback_context);
492 SetupCloseInfFile(hinf);
494 return ret ? S_OK : HRESULT_FROM_WIN32(GetLastError());
497 /***********************************************************************
498 * ExecuteCabA (ADVPACK.@)
502 HRESULT WINAPI ExecuteCabA(HWND hwnd, CABINFOA* pCab, LPVOID pReserved)
504 UNICODE_STRING cab, inf, section;
508 TRACE("(%p, %p, %p)\n", hwnd, pCab, pReserved);
515 RtlCreateUnicodeStringFromAsciiz(&cab, pCab->pszCab);
516 cabinfo.pszCab = cab.Buffer;
519 cabinfo.pszCab = NULL;
521 RtlCreateUnicodeStringFromAsciiz(&inf, pCab->pszInf);
522 RtlCreateUnicodeStringFromAsciiz(§ion, pCab->pszSection);
524 MultiByteToWideChar(CP_ACP, 0, pCab->szSrcPath, -1, cabinfo.szSrcPath,
525 sizeof(cabinfo.szSrcPath) / sizeof(WCHAR));
527 cabinfo.pszInf = inf.Buffer;
528 cabinfo.pszSection = section.Buffer;
529 cabinfo.dwFlags = pCab->dwFlags;
531 hr = ExecuteCabW(hwnd, &cabinfo, pReserved);
534 RtlFreeUnicodeString(&cab);
536 RtlFreeUnicodeString(&inf);
537 RtlFreeUnicodeString(§ion);
542 /***********************************************************************
543 * ExecuteCabW (ADVPACK.@)
545 * Installs the INF file extracted from a specified cabinet file.
548 * hwnd [I] Handle to the window used for the display.
549 * pCab [I] Information about the cabinet file.
550 * pReserved [I] Reserved. Must be NULL.
556 HRESULT WINAPI ExecuteCabW(HWND hwnd, CABINFOW* pCab, LPVOID pReserved)
561 TRACE("(%p, %p, %p)\n", hwnd, pCab, pReserved);
563 ZeroMemory(&info, sizeof(ADVInfo));
565 if (pCab->pszCab && *pCab->pszCab)
566 FIXME("Cab archive not extracted!\n");
568 hr = install_init(pCab->pszInf, pCab->pszSection, pCab->szSrcPath, pCab->dwFlags, &info);
572 hr = spapi_install(&info);
576 hr = adv_install(&info);
579 install_release(&info);
584 /***********************************************************************
585 * LaunchINFSectionA (ADVPACK.@)
587 * See LaunchINFSectionW.
589 INT WINAPI LaunchINFSectionA(HWND hWnd, HINSTANCE hInst, LPSTR cmdline, INT show)
594 TRACE("(%p, %p, %s, %i)\n", hWnd, hInst, debugstr_a(cmdline), show);
596 RtlCreateUnicodeStringFromAsciiz(&cmd, cmdline);
598 hr = LaunchINFSectionW(hWnd, hInst, cmd.Buffer, show);
600 RtlFreeUnicodeString(&cmd);
605 /***********************************************************************
606 * LaunchINFSectionW (ADVPACK.@)
608 * Installs an INF section without BACKUP/ROLLBACK capabilities.
611 * hWnd [I] Handle to parent window, NULL for desktop.
612 * hInst [I] Instance of the process.
613 * cmdline [I] Contains parameters in the order INF,section,flags,reboot.
614 * show [I] How the window should be shown.
621 * INF - Filename of the INF to launch.
622 * section - INF section to install.
623 * flags - see advpub.h.
624 * reboot - smart reboot behavior
626 * 'I' Reboot if needed (default).
629 INT WINAPI LaunchINFSectionW(HWND hWnd, HINSTANCE hInst, LPWSTR cmdline, INT show)
632 LPWSTR cmdline_copy, cmdline_ptr;
633 LPWSTR inf_filename, install_sec;
638 TRACE("(%p, %p, %s, %d)\n", hWnd, hInst, debugstr_w(cmdline), show);
643 cmdline_copy = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(cmdline) + 1) * sizeof(WCHAR));
644 cmdline_ptr = cmdline_copy;
645 lstrcpyW(cmdline_copy, cmdline);
647 inf_filename = get_parameter(&cmdline_ptr, ',');
648 install_sec = get_parameter(&cmdline_ptr, ',');
650 str_flags = get_parameter(&cmdline_ptr, ',');
652 flags = atolW(str_flags);
654 ZeroMemory(&info, sizeof(ADVInfo));
656 hr = install_init(inf_filename, install_sec, NULL, flags, &info);
660 hr = spapi_install(&info);
664 hr = adv_install(&info);
667 install_release(&info);
668 HeapFree(GetProcessHeap(), 0, cmdline_copy);
673 /***********************************************************************
674 * LaunchINFSectionExA (ADVPACK.@)
676 * See LaunchINFSectionExW.
678 HRESULT WINAPI LaunchINFSectionExA(HWND hWnd, HINSTANCE hInst, LPSTR cmdline, INT show)
683 TRACE("(%p, %p, %s, %i)\n", hWnd, hInst, debugstr_a(cmdline), show);
685 RtlCreateUnicodeStringFromAsciiz(&cmd, cmdline);
687 hr = LaunchINFSectionExW(hWnd, hInst, cmd.Buffer, show);
689 RtlFreeUnicodeString(&cmd);
694 /***********************************************************************
695 * LaunchINFSectionExW (ADVPACK.@)
697 * Installs an INF section with BACKUP/ROLLBACK capabilities.
700 * hWnd [I] Handle to parent window, NULL for desktop.
701 * hInst [I] Instance of the process.
702 * cmdline [I] Contains parameters in the order INF,section,CAB,flags,reboot.
703 * show [I] How the window should be shown.
710 * INF - Filename of the INF to launch.
711 * section - INF section to install.
712 * flags - see advpub.h.
713 * reboot - smart reboot behavior
715 * 'I' Reboot if needed (default).
719 * Doesn't handle the reboot flag.
721 HRESULT WINAPI LaunchINFSectionExW(HWND hWnd, HINSTANCE hInst, LPWSTR cmdline, INT show)
723 LPWSTR cmdline_copy, cmdline_ptr;
728 TRACE("(%p, %p, %s, %d)\n", hWnd, hInst, debugstr_w(cmdline), show);
733 cmdline_copy = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(cmdline) + 1) * sizeof(WCHAR));
734 cmdline_ptr = cmdline_copy;
735 lstrcpyW(cmdline_copy, cmdline);
737 cabinfo.pszInf = get_parameter(&cmdline_ptr, ',');
738 cabinfo.pszSection = get_parameter(&cmdline_ptr, ',');
739 cabinfo.pszCab = get_parameter(&cmdline_ptr, ',');
740 *cabinfo.szSrcPath = '\0';
742 flags = get_parameter(&cmdline_ptr, ',');
744 cabinfo.dwFlags = atolW(flags);
746 /* get the source path from the cab filename */
747 if (cabinfo.pszCab && *cabinfo.pszCab)
749 if (!is_full_path(cabinfo.pszCab))
752 lstrcpyW(cabinfo.szSrcPath, cabinfo.pszCab);
753 ptr = strrchrW(cabinfo.szSrcPath, '\\');
757 hr = ExecuteCabW(hWnd, &cabinfo, NULL);
760 HeapFree(GetProcessHeap(), 0, cmdline_copy);
765 HRESULT launch_exe(LPCWSTR cmd, LPCWSTR dir, HANDLE *phEXE)
768 PROCESS_INFORMATION pi;
770 if (phEXE) *phEXE = NULL;
772 ZeroMemory(&pi, sizeof(pi));
773 ZeroMemory(&si, sizeof(si));
776 if (!CreateProcessW(NULL, (LPWSTR)cmd, NULL, NULL, FALSE,
777 CREATE_DEFAULT_ERROR_MODE | CREATE_NEW_PROCESS_GROUP,
778 NULL, dir, &si, &pi))
780 return HRESULT_FROM_WIN32(GetLastError());
783 CloseHandle(pi.hThread);
787 *phEXE = pi.hProcess;
788 return S_ASYNCHRONOUS;
791 /* wait for the child process to finish */
792 WaitForSingleObject(pi.hProcess, INFINITE);
793 CloseHandle(pi.hProcess);
798 /***********************************************************************
799 * RunSetupCommandA (ADVPACK.@)
801 * See RunSetupCommandW.
803 HRESULT WINAPI RunSetupCommandA(HWND hWnd, LPCSTR szCmdName,
804 LPCSTR szInfSection, LPCSTR szDir,
805 LPCSTR lpszTitle, HANDLE *phEXE,
806 DWORD dwFlags, LPVOID pvReserved)
808 UNICODE_STRING cmdname, infsec;
809 UNICODE_STRING dir, title;
812 TRACE("(%p, %s, %s, %s, %s, %p, %ld, %p)\n",
813 hWnd, debugstr_a(szCmdName), debugstr_a(szInfSection),
814 debugstr_a(szDir), debugstr_a(lpszTitle),
815 phEXE, dwFlags, pvReserved);
817 if (!szCmdName || !szDir)
820 RtlCreateUnicodeStringFromAsciiz(&cmdname, szCmdName);
821 RtlCreateUnicodeStringFromAsciiz(&infsec, szInfSection);
822 RtlCreateUnicodeStringFromAsciiz(&dir, szDir);
823 RtlCreateUnicodeStringFromAsciiz(&title, lpszTitle);
825 hr = RunSetupCommandW(hWnd, cmdname.Buffer, infsec.Buffer, dir.Buffer,
826 title.Buffer, phEXE, dwFlags, pvReserved);
828 RtlFreeUnicodeString(&cmdname);
829 RtlFreeUnicodeString(&infsec);
830 RtlFreeUnicodeString(&dir);
831 RtlFreeUnicodeString(&title);
836 /***********************************************************************
837 * RunSetupCommandW (ADVPACK.@)
839 * Executes an install section in an INF file or a program.
842 * hWnd [I] Handle to parent window, NULL for quiet mode
843 * szCmdName [I] Inf or EXE filename to execute
844 * szInfSection [I] Inf section to install, NULL for DefaultInstall
845 * szDir [I] Path to extracted files
846 * szTitle [I] Title of all dialogs
847 * phEXE [O] Handle of EXE to wait for
848 * dwFlags [I] Flags; see include/advpub.h
849 * pvReserved [I] Reserved
853 * S_ASYNCHRONOUS OK, required to wait on phEXE
854 * ERROR_SUCCESS_REBOOT_REQUIRED Reboot required
855 * E_INVALIDARG Invalid argument given
856 * HRESULT_FROM_WIN32(ERROR_OLD_WIN_VERSION)
857 * Not supported on this Windows version
858 * E_UNEXPECTED Unexpected error
859 * HRESULT_FROM_WIN32(GetLastError()) Some other error
861 HRESULT WINAPI RunSetupCommandW(HWND hWnd, LPCWSTR szCmdName,
862 LPCWSTR szInfSection, LPCWSTR szDir,
863 LPCWSTR lpszTitle, HANDLE *phEXE,
864 DWORD dwFlags, LPVOID pvReserved)
869 TRACE("(%p, %s, %s, %s, %s, %p, %ld, %p)\n",
870 hWnd, debugstr_w(szCmdName), debugstr_w(szInfSection),
871 debugstr_w(szDir), debugstr_w(lpszTitle),
872 phEXE, dwFlags, pvReserved);
874 if (dwFlags & RSC_FLAG_UPDHLPDLLS)
875 FIXME("Unhandled flag: RSC_FLAG_UPDHLPDLLS\n");
877 if (!szCmdName || !szDir)
880 if (!(dwFlags & RSC_FLAG_INF))
881 return launch_exe(szCmdName, szDir, phEXE);
883 ZeroMemory(&info, sizeof(ADVInfo));
885 hr = install_init(szCmdName, szInfSection, szDir, dwFlags, &info);
889 hr = spapi_install(&info);
893 hr = adv_install(&info);
896 install_release(&info);