advpack: Add initial tests for RunSetupCommand.
[wine/multimedia.git] / dlls / advpack / install.c
blob55c7703cd176f5aebba44f6ed00e8e6064f09208
1 /*
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
21 #include <stdarg.h>
22 #include <stdlib.h>
24 #include "windef.h"
25 #include "winbase.h"
26 #include "winuser.h"
27 #include "winreg.h"
28 #include "winver.h"
29 #include "winternl.h"
30 #include "setupapi.h"
31 #include "advpub.h"
32 #include "wine/debug.h"
34 WINE_DEFAULT_DEBUG_CHANNEL(advpack);
36 /* this structure very closely resembles parameters of RunSetupCommand() */
37 typedef struct
39 HWND hwnd;
40 LPCSTR title;
41 LPCSTR inf_name;
42 LPCSTR dir;
43 LPCSTR section_name;
44 } SETUPCOMMAND_PARAMS;
46 /***********************************************************************
47 * DoInfInstall (ADVPACK.@)
49 * Install an INF section.
51 * PARAMS
52 * setup [I] Structure containing install information.
54 * RETURNS
55 * S_OK Everything OK
56 * HRESULT_FROM_WIN32(GetLastError()) Some other error
58 HRESULT WINAPI DoInfInstall(const SETUPCOMMAND_PARAMS *setup)
60 BOOL ret;
61 HINF hinf;
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.
87 * PARAMS
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.
92 * RETURNS
93 * Success: S_OK.
94 * Failure: E_FAIL.
96 * BUGS
97 * Unimplemented
99 HRESULT WINAPI ExecuteCabA( HWND hwnd, CABINFOA* pCab, LPVOID pReserved )
101 FIXME("(%p %p %p): stub\n", hwnd, pCab, pReserved);
102 return E_FAIL;
105 /***********************************************************************
106 * LaunchINFSectionA (ADVPACK.@)
108 * Installs an INF section without BACKUP/ROLLBACK capabilities.
110 * PARAMS
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:
115 * 'A' reboot always
116 * 'I' default, reboot if needed
117 * 'N' no reboot
119 * RETURNS
120 * Success: S_OK.
121 * Failure: S_FALSE
123 * BUGS
124 * Unimplemented.
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 );
129 return 0;
132 /***********************************************************************
133 * LaunchINFSectionExA (ADVPACK.@)
135 * Installs an INF section with BACKUP/ROLLBACK capabilities.
137 * PARAMS
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:
142 * 'A' reboot always
143 * 'I' default, reboot if needed
144 * 'N' no reboot
146 * RETURNS
147 * Success: S_OK.
148 * Failure: E_FAIL.
150 * BUGS
151 * Unimplemented.
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 );
156 return E_FAIL;
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;
171 HRESULT hr;
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)
179 return E_INVALIDARG;
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);
194 return hr;
197 /***********************************************************************
198 * RunSetupCommandW (ADVPACK.@)
200 * Executes an install section in an INF file or a program.
202 * PARAMS
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
212 * RETURNS
213 * S_OK Everything OK
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
222 * BUGS
223 * Unimplemented
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);
234 return E_UNEXPECTED;