/*********************************************************************** * UserInstStubWrapperW (ADVPACK.@) * * Launches the user stub wrapper specified by the RealStubPath * registry value under Installed Components\szParms. * * PARAMS * hWnd [I] Handle to the window used for the display. * hInstance [I] Instance of the process. * szParms [I] The GUID of the installation. * show [I] How the window should be shown. * * RETURNS * Success: S_OK. * Failure: E_FAIL. * * TODO * If the type of the StubRealPath value is REG_EXPAND_SZ, then * we should call ExpandEnvironmentStrings on the value and * launch the result. */ HRESULT WINAPI UserInstStubWrapperW(HWND hWnd, HINSTANCE hInstance, LPWSTR pszParms, INT nShow) { HKEY setup, guid; WCHAR stub[MAX_PATH]; DWORD size = MAX_PATH; HRESULT hr = S_OK; BOOL res; static const WCHAR real_stub_path[] = { 'R','e','a','l','S','t','u','b','P','a','t','h',0 }; TRACE("(%p, %p, %s, %i)\n", hWnd, hInstance, debugstr_w(pszParms), nShow); if (!pszParms || !*pszParms) return E_INVALIDARG; if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, setup_key, 0, KEY_READ, &setup)) { return E_FAIL; } if (RegOpenKeyExW(setup, pszParms, 0, KEY_READ, &guid)) { RegCloseKey(setup); return E_FAIL; } res = RegQueryValueExW(guid, real_stub_path, NULL, NULL, (LPBYTE)stub, &size); if (res || !*stub) goto done; /* launch the user stub wrapper */ hr = launch_exe(stub, NULL, NULL); done: RegCloseKey(setup); RegCloseKey(guid); return hr; }
/*********************************************************************** * RunSetupCommandW (ADVPACK.@) * * Executes an install section in an INF file or a program. * * PARAMS * hWnd [I] Handle to parent window, NULL for quiet mode * szCmdName [I] Inf or EXE filename to execute * szInfSection [I] Inf section to install, NULL for DefaultInstall * szDir [I] Path to extracted files * szTitle [I] Title of all dialogs * phEXE [O] Handle of EXE to wait for * dwFlags [I] Flags; see include/advpub.h * pvReserved [I] Reserved * * RETURNS * S_OK Everything OK * S_ASYNCHRONOUS OK, required to wait on phEXE * ERROR_SUCCESS_REBOOT_REQUIRED Reboot required * E_INVALIDARG Invalid argument given * HRESULT_FROM_WIN32(ERROR_OLD_WIN_VERSION) * Not supported on this Windows version * E_UNEXPECTED Unexpected error * HRESULT_FROM_WIN32(GetLastError()) Some other error */ HRESULT WINAPI RunSetupCommandW(HWND hWnd, LPCWSTR szCmdName, LPCWSTR szInfSection, LPCWSTR szDir, LPCWSTR lpszTitle, HANDLE *phEXE, DWORD dwFlags, LPVOID pvReserved) { ADVInfo info; HRESULT hr; TRACE("(%p, %s, %s, %s, %s, %p, %d, %p)\n", hWnd, debugstr_w(szCmdName), debugstr_w(szInfSection), debugstr_w(szDir), debugstr_w(lpszTitle), phEXE, dwFlags, pvReserved); if (dwFlags & RSC_FLAG_UPDHLPDLLS) FIXME("Unhandled flag: RSC_FLAG_UPDHLPDLLS\n"); if (!szCmdName || !szDir) return E_INVALIDARG; if (!(dwFlags & RSC_FLAG_INF)) return launch_exe(szCmdName, szDir, phEXE); ZeroMemory(&info, sizeof(ADVInfo)); hr = install_init(szCmdName, szInfSection, szDir, dwFlags, &info); if (hr != S_OK) goto done; hr = spapi_install(&info); if (hr != S_OK) goto done; hr = adv_install(&info); done: install_release(&info); return hr; }
static HRESULT run_setup_commands_callback(HINF hinf, PCWSTR field, const void *arg) { const ADVInfo *info = (const ADVInfo *)arg; INFCONTEXT context; HRESULT hr = S_OK; DWORD size; BOOL ok = SetupFindFirstLineW(hinf, field, NULL, &context); for (; ok; ok = SetupFindNextLine(&context, &context)) { WCHAR buffer[MAX_INF_STRING_LENGTH]; if (!SetupGetLineTextW(&context, NULL, NULL, NULL, buffer, MAX_INF_STRING_LENGTH, &size)) continue; if (launch_exe(buffer, info->working_dir, NULL) != S_OK) hr = E_FAIL; } return hr; }