Authors: Mike McCormack <mike@codeweavers.com>, Aric Stewart <aric@codeweavers.com...
[wine] / dlls / advpack / advpack.c
1 /*
2  * Advpack main
3  *
4  * Copyright 2004 Huw D M Davies
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
23 #include "windef.h"
24 #include "winbase.h"
25 #include "winuser.h"
26 #include "winreg.h"
27 #include "setupapi.h"
28 #include "advpub.h"
29 #include "wine/debug.h"
30
31 WINE_DEFAULT_DEBUG_CHANNEL(advpack);
32
33
34 /***********************************************************************
35  *           DllMain (ADVPACK.@)
36  */
37 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
38 {
39     TRACE("(%p, %ld, %p)\n",hinstDLL, fdwReason, lpvReserved);
40
41     if (fdwReason == DLL_PROCESS_ATTACH)
42         DisableThreadLibraryCalls(hinstDLL);
43
44     return TRUE;
45 }
46
47 /***********************************************************************
48  *              LaunchINFSection  (ADVPACK.@)
49  */
50 void WINAPI LaunchINFSection( HWND hWnd, HINSTANCE hInst, LPCSTR cmdline, INT show )
51 {
52     FIXME("%p %p %s %d\n", hWnd, hInst, debugstr_a(cmdline), show );
53 }
54
55 /***********************************************************************
56  *              LaunchINFSectionEx  (ADVPACK.@)
57  */
58 void WINAPI LaunchINFSectionEx( HWND hWnd, HINSTANCE hInst, LPCSTR cmdline, INT show )
59 {
60     FIXME("%p %p %s %d\n", hWnd, hInst, debugstr_a(cmdline), show );
61 }
62
63 /* this structure very closely resembles parameters of RunSetupCommand() */
64 typedef struct
65 {
66     HWND hwnd;
67     LPCSTR title;
68     LPCSTR inf_name;
69     LPCSTR dir;
70     LPCSTR section_name;
71 } SETUPCOMMAND_PARAMS;
72
73 /***********************************************************************
74  *              DoInfInstall  (ADVPACK.@)
75  */
76 BOOL WINAPI DoInfInstall(const SETUPCOMMAND_PARAMS *setup)
77 {
78     BOOL ret;
79     HINF hinf;
80     void *callback_context;
81
82     TRACE("%p %s %s %s %s\n", setup->hwnd, debugstr_a(setup->title),
83           debugstr_a(setup->inf_name), debugstr_a(setup->dir),
84           debugstr_a(setup->section_name));
85
86     hinf = SetupOpenInfFileA(setup->inf_name, NULL, INF_STYLE_WIN4, NULL);
87     if (hinf == INVALID_HANDLE_VALUE) return FALSE;
88
89     callback_context = SetupInitDefaultQueueCallback(setup->hwnd);
90
91     ret = SetupInstallFromInfSectionA(NULL, hinf, setup->section_name, SPINST_ALL,
92                                       NULL, NULL, 0, SetupDefaultQueueCallbackA,
93                                       callback_context, NULL, NULL);
94     SetupTermDefaultQueueCallback(callback_context);
95     SetupCloseInfFile(hinf);
96
97     return ret;
98 }