comctl32: A couple fixes for tab icon offsets.
[wine] / dlls / advpack / install.c
1 /*
2  * Advpack install functions
3  *
4  * Copyright 2006 James Hawkins
5  *
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.
10  *
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.
15  *
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
19  */
20
21 #include <stdarg.h>
22 #include <stdlib.h>
23
24 #include "windef.h"
25 #include "winbase.h"
26 #include "winuser.h"
27 #include "winreg.h"
28 #include "winver.h"
29 #include "setupapi.h"
30 #include "advpub.h"
31 #include "wine/debug.h"
32
33 WINE_DEFAULT_DEBUG_CHANNEL(advpack);
34
35 /* this structure very closely resembles parameters of RunSetupCommand() */
36 typedef struct
37 {
38     HWND hwnd;
39     LPCSTR title;
40     LPCSTR inf_name;
41     LPCSTR dir;
42     LPCSTR section_name;
43 } SETUPCOMMAND_PARAMS;
44
45 /***********************************************************************
46  *      DoInfInstall  (ADVPACK.@)
47  *
48  * Install an INF section.
49  *
50  * PARAMS
51  *  setup [I] Structure containing install information.
52  *
53  * RETURNS
54  *   S_OK                                Everything OK
55  *   HRESULT_FROM_WIN32(GetLastError())  Some other error
56  */
57 HRESULT WINAPI DoInfInstall(const SETUPCOMMAND_PARAMS *setup)
58 {
59     BOOL ret;
60     HINF hinf;
61     void *callback_context;
62
63     TRACE("%p %s %s %s %s\n", setup->hwnd, debugstr_a(setup->title),
64           debugstr_a(setup->inf_name), debugstr_a(setup->dir),
65           debugstr_a(setup->section_name));
66
67     hinf = SetupOpenInfFileA(setup->inf_name, NULL, INF_STYLE_WIN4, NULL);
68     if (hinf == INVALID_HANDLE_VALUE) return HRESULT_FROM_WIN32(GetLastError());
69
70     callback_context = SetupInitDefaultQueueCallback(setup->hwnd);
71
72     ret = SetupInstallFromInfSectionA(NULL, hinf, setup->section_name, SPINST_ALL,
73                                       NULL, NULL, 0, SetupDefaultQueueCallbackA,
74                                       callback_context, NULL, NULL);
75     SetupTermDefaultQueueCallback(callback_context);
76     SetupCloseInfFile(hinf);
77
78     return ret ? S_OK : HRESULT_FROM_WIN32(GetLastError());
79 }
80
81 /***********************************************************************
82  *             ExecuteCabA    (ADVPACK.@)
83  * 
84  * Installs the INF file extracted from a specified cabinet file.
85  * 
86  * PARAMS
87  *   hwnd      [I] Handle to the window used for the display.
88  *   pCab      [I] Information about the cabinet file.
89  *   pReserved [I] Reserved.  Must be NULL.
90  * 
91  * RETURNS
92  *   Success: S_OK.
93  *   Failure: E_FAIL.
94  *
95  * BUGS
96  *   Unimplemented
97  */
98 HRESULT WINAPI ExecuteCabA( HWND hwnd, CABINFOA* pCab, LPVOID pReserved )
99 {
100     FIXME("(%p %p %p): stub\n", hwnd, pCab, pReserved);
101     return E_FAIL;
102 }
103
104 /***********************************************************************
105  *      LaunchINFSectionA   (ADVPACK.@)
106  *
107  * Installs an INF section without BACKUP/ROLLBACK capabilities.
108  *
109  * PARAMS
110  *   hWnd    [I] Handle to parent window, NULL for desktop.
111  *   hInst   [I] Instance of the process.
112  *   cmdline [I] Contains parameters in the order INF,section,flags.
113  *   show    [I] Reboot behaviour:
114  *              'A' reboot always
115  *              'I' default, reboot if needed
116  *              'N' no reboot
117  *
118  * RETURNS
119  *  Success: S_OK.
120  *  Failure: S_FALSE
121  *
122  * BUGS
123  *  Unimplemented.
124  */
125 INT WINAPI LaunchINFSectionA( HWND hWnd, HINSTANCE hInst, LPSTR cmdline, INT show )
126 {
127     FIXME("(%p %p %s %d): stub\n", hWnd, hInst, debugstr_a(cmdline), show );
128     return 0;
129 }
130
131 /***********************************************************************
132  *      LaunchINFSectionExA (ADVPACK.@)
133  *
134  * Installs an INF section with BACKUP/ROLLBACK capabilities.
135  *
136  * PARAMS
137  *   hWnd    [I] Handle to parent window, NULL for desktop.
138  *   hInst   [I] Instance of the process.
139  *   cmdline [I] Contains parameters in the order INF,section,CAB,flags.
140  *   show    [I] Reboot behaviour:
141  *              'A' reboot always
142  *              'I' default, reboot if needed
143  *              'N' no reboot
144  *
145  * RETURNS
146  *  Success: S_OK.
147  *  Failure: E_FAIL.
148  *
149  * BUGS
150  *  Unimplemented.
151  */
152 HRESULT WINAPI LaunchINFSectionExA( HWND hWnd, HINSTANCE hInst, LPSTR cmdline, INT show )
153 {
154     FIXME("(%p %p %s %d): stub\n", hWnd, hInst, debugstr_a(cmdline), show );
155     return E_FAIL;
156 }
157
158 /***********************************************************************
159  *      RunSetupCommandA  (ADVPACK.@)
160  *
161  * Executes an install section in an INF file or a program.
162  *
163  * PARAMS
164  *   hWnd          [I] Handle to parent window, NULL for quiet mode
165  *   szCmdName     [I] Inf or EXE filename to execute
166  *   szInfSection  [I] Inf section to install, NULL for DefaultInstall
167  *   szDir         [I] Path to extracted files
168  *   szTitle       [I] Title of all dialogs
169  *   phEXE         [O] Handle of EXE to wait for
170  *   dwFlags       [I] Flags; see include/advpub.h
171  *   pvReserved    [I] Reserved
172  *
173  * RETURNS
174  *   S_OK                                 Everything OK
175  *   S_ASYNCHRONOUS                       OK, required to wait on phEXE
176  *   ERROR_SUCCESS_REBOOT_REQUIRED        Reboot required
177  *   E_INVALIDARG                         Invalid argument given
178  *   HRESULT_FROM_WIN32(ERROR_OLD_WIN_VERSION)
179  *                                        Not supported on this Windows version
180  *   E_UNEXPECTED                         Unexpected error
181  *   HRESULT_FROM_WIN32(GetLastError())   Some other error
182  *
183  * BUGS
184  *   Unimplemented
185  */
186 HRESULT WINAPI RunSetupCommandA(HWND hWnd, LPCSTR szCmdName,
187                                 LPCSTR szInfSection, LPCSTR szDir,
188                                 LPCSTR lpszTitle, HANDLE *phEXE,
189                                 DWORD dwFlags, LPVOID pvReserved )
190 {
191     FIXME("(%p, %s, %s, %s, %s, %p, 0x%08lx, %p): stub\n",
192            hWnd, debugstr_a(szCmdName), debugstr_a(szInfSection),
193            debugstr_a(szDir), debugstr_a(lpszTitle),
194            phEXE, dwFlags, pvReserved);
195     return E_UNEXPECTED;
196 }