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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
32 #include "wine/debug.h"
34 WINE_DEFAULT_DEBUG_CHANNEL(advpack);
36 /* this structure very closely resembles parameters of RunSetupCommand() */
44 } SETUPCOMMAND_PARAMS;
46 /***********************************************************************
47 * DoInfInstall (ADVPACK.@)
49 * Install an INF section.
52 * setup [I] Structure containing install information.
56 * HRESULT_FROM_WIN32(GetLastError()) Some other error
58 HRESULT WINAPI DoInfInstall(const SETUPCOMMAND_PARAMS *setup)
62 void *callback_context;
64 TRACE("%p %s %s %s %s\n", setup->hwnd, debugstr_a(setup->title),
65 debugstr_a(setup->inf_name), debugstr_a(setup->dir),
66 debugstr_a(setup->section_name));
68 hinf = SetupOpenInfFileA(setup->inf_name, NULL, INF_STYLE_WIN4, NULL);
69 if (hinf == INVALID_HANDLE_VALUE) return HRESULT_FROM_WIN32(GetLastError());
71 callback_context = SetupInitDefaultQueueCallback(setup->hwnd);
73 ret = SetupInstallFromInfSectionA(NULL, hinf, setup->section_name, SPINST_ALL,
74 NULL, NULL, 0, SetupDefaultQueueCallbackA,
75 callback_context, NULL, NULL);
76 SetupTermDefaultQueueCallback(callback_context);
77 SetupCloseInfFile(hinf);
79 return ret ? S_OK : HRESULT_FROM_WIN32(GetLastError());
82 /***********************************************************************
83 * ExecuteCabA (ADVPACK.@)
85 * Installs the INF file extracted from a specified cabinet file.
88 * hwnd [I] Handle to the window used for the display.
89 * pCab [I] Information about the cabinet file.
90 * pReserved [I] Reserved. Must be NULL.
99 HRESULT WINAPI ExecuteCabA( HWND hwnd, CABINFOA* pCab, LPVOID pReserved )
101 FIXME("(%p %p %p): stub\n", hwnd, pCab, pReserved);
105 /***********************************************************************
106 * LaunchINFSectionA (ADVPACK.@)
108 * Installs an INF section without BACKUP/ROLLBACK capabilities.
111 * hWnd [I] Handle to parent window, NULL for desktop.
112 * hInst [I] Instance of the process.
113 * cmdline [I] Contains parameters in the order INF,section,flags.
114 * show [I] Reboot behaviour:
116 * 'I' default, reboot if needed
126 INT WINAPI LaunchINFSectionA( HWND hWnd, HINSTANCE hInst, LPSTR cmdline, INT show )
128 FIXME("(%p %p %s %d): stub\n", hWnd, hInst, debugstr_a(cmdline), show );
132 /***********************************************************************
133 * LaunchINFSectionExA (ADVPACK.@)
135 * Installs an INF section with BACKUP/ROLLBACK capabilities.
138 * hWnd [I] Handle to parent window, NULL for desktop.
139 * hInst [I] Instance of the process.
140 * cmdline [I] Contains parameters in the order INF,section,CAB,flags.
141 * show [I] Reboot behaviour:
143 * 'I' default, reboot if needed
153 HRESULT WINAPI LaunchINFSectionExA( HWND hWnd, HINSTANCE hInst, LPSTR cmdline, INT show )
155 FIXME("(%p %p %s %d): stub\n", hWnd, hInst, debugstr_a(cmdline), show );
159 /***********************************************************************
160 * RunSetupCommandA (ADVPACK.@)
162 * See RunSetupCommandW.
164 HRESULT WINAPI RunSetupCommandA(HWND hWnd, LPCSTR szCmdName,
165 LPCSTR szInfSection, LPCSTR szDir,
166 LPCSTR lpszTitle, HANDLE *phEXE,
167 DWORD dwFlags, LPVOID pvReserved )
169 UNICODE_STRING cmdname, infsec;
170 UNICODE_STRING dir, title;
173 TRACE("(%p, %s, %s, %s, %s, %p, 0x%08lx, %p)\n",
174 hWnd, debugstr_a(szCmdName), debugstr_a(szInfSection),
175 debugstr_a(szDir), debugstr_a(lpszTitle),
176 phEXE, dwFlags, pvReserved);
178 if (!szCmdName || !szDir)
181 RtlCreateUnicodeStringFromAsciiz(&cmdname, szCmdName);
182 RtlCreateUnicodeStringFromAsciiz(&infsec, szInfSection);
183 RtlCreateUnicodeStringFromAsciiz(&dir, szDir);
184 RtlCreateUnicodeStringFromAsciiz(&title, lpszTitle);
186 hr = RunSetupCommandW(hWnd, cmdname.Buffer, infsec.Buffer, dir.Buffer,
187 title.Buffer, phEXE, dwFlags, pvReserved);
189 RtlFreeUnicodeString(&cmdname);
190 RtlFreeUnicodeString(&infsec);
191 RtlFreeUnicodeString(&dir);
192 RtlFreeUnicodeString(&title);
197 /***********************************************************************
198 * RunSetupCommandW (ADVPACK.@)
200 * Executes an install section in an INF file or a program.
203 * hWnd [I] Handle to parent window, NULL for quiet mode
204 * szCmdName [I] Inf or EXE filename to execute
205 * szInfSection [I] Inf section to install, NULL for DefaultInstall
206 * szDir [I] Path to extracted files
207 * szTitle [I] Title of all dialogs
208 * phEXE [O] Handle of EXE to wait for
209 * dwFlags [I] Flags; see include/advpub.h
210 * pvReserved [I] Reserved
214 * S_ASYNCHRONOUS OK, required to wait on phEXE
215 * ERROR_SUCCESS_REBOOT_REQUIRED Reboot required
216 * E_INVALIDARG Invalid argument given
217 * HRESULT_FROM_WIN32(ERROR_OLD_WIN_VERSION)
218 * Not supported on this Windows version
219 * E_UNEXPECTED Unexpected error
220 * HRESULT_FROM_WIN32(GetLastError()) Some other error
225 HRESULT WINAPI RunSetupCommandW(HWND hWnd, LPCWSTR szCmdName,
226 LPCWSTR szInfSection, LPCWSTR szDir,
227 LPCWSTR lpszTitle, HANDLE *phEXE,
228 DWORD dwFlags, LPVOID pvReserved )
230 FIXME("(%p, %s, %s, %s, %s, %p, 0x%08lx, %p): stub\n",
231 hWnd, debugstr_w(szCmdName), debugstr_w(szInfSection),
232 debugstr_w(szDir), debugstr_w(lpszTitle),
233 phEXE, dwFlags, pvReserved);
235 if (!szCmdName || !szDir)
238 if (!(dwFlags & RSC_FLAG_INF))