Added stubs for NeedRebootInit and NeedReboot.
[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 "winver.h"
28 #include "winnls.h"
29 #include "setupapi.h"
30 #include "advpub.h"
31 #include "wine/debug.h"
32
33 WINE_DEFAULT_DEBUG_CHANNEL(advpack);
34
35
36 /***********************************************************************
37  *           DllMain (ADVPACK.@)
38  */
39 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
40 {
41     TRACE("(%p, %ld, %p)\n",hinstDLL, fdwReason, lpvReserved);
42
43     if (fdwReason == DLL_PROCESS_ATTACH)
44         DisableThreadLibraryCalls(hinstDLL);
45
46     return TRUE;
47 }
48
49 /***********************************************************************
50  *              LaunchINFSection  (ADVPACK.@)
51  */
52 void WINAPI LaunchINFSection( HWND hWnd, HINSTANCE hInst, LPCSTR cmdline, INT show )
53 {
54     FIXME("%p %p %s %d\n", hWnd, hInst, debugstr_a(cmdline), show );
55 }
56
57 /***********************************************************************
58  *              LaunchINFSectionEx  (ADVPACK.@)
59  */
60 void WINAPI LaunchINFSectionEx( HWND hWnd, HINSTANCE hInst, LPCSTR cmdline, INT show )
61 {
62     FIXME("%p %p %s %d\n", hWnd, hInst, debugstr_a(cmdline), show );
63 }
64
65 /* this structure very closely resembles parameters of RunSetupCommand() */
66 typedef struct
67 {
68     HWND hwnd;
69     LPCSTR title;
70     LPCSTR inf_name;
71     LPCSTR dir;
72     LPCSTR section_name;
73 } SETUPCOMMAND_PARAMS;
74
75 /***********************************************************************
76  *              DoInfInstall  (ADVPACK.@)
77  */
78 BOOL WINAPI DoInfInstall(const SETUPCOMMAND_PARAMS *setup)
79 {
80     BOOL ret;
81     HINF hinf;
82     void *callback_context;
83
84     TRACE("%p %s %s %s %s\n", setup->hwnd, debugstr_a(setup->title),
85           debugstr_a(setup->inf_name), debugstr_a(setup->dir),
86           debugstr_a(setup->section_name));
87
88     hinf = SetupOpenInfFileA(setup->inf_name, NULL, INF_STYLE_WIN4, NULL);
89     if (hinf == INVALID_HANDLE_VALUE) return FALSE;
90
91     callback_context = SetupInitDefaultQueueCallback(setup->hwnd);
92
93     ret = SetupInstallFromInfSectionA(NULL, hinf, setup->section_name, SPINST_ALL,
94                                       NULL, NULL, 0, SetupDefaultQueueCallbackA,
95                                       callback_context, NULL, NULL);
96     SetupTermDefaultQueueCallback(callback_context);
97     SetupCloseInfFile(hinf);
98
99     return ret;
100 }
101
102 /***********************************************************************
103  *             NeedRebootInit  (ADVPACK.@)
104  */
105 DWORD WINAPI NeedRebootInit(VOID)
106 {
107     FIXME("() stub!\n");
108     return 0;
109 }
110
111 /***********************************************************************
112  *             NeedReboot      (ADVPACK.@)
113  */
114 BOOL WINAPI NeedReboot(DWORD dwRebootCheck)
115 {
116     FIXME("(0x%08lx) stub!\n", dwRebootCheck);
117     return FALSE;
118 }
119
120 /***********************************************************************
121  *             GetVersionFromFile      (ADVPACK.@)
122  */
123 HRESULT WINAPI GetVersionFromFile( LPSTR Filename, LPDWORD MajorVer,
124                                    LPDWORD MinorVer, BOOL Version )
125 {
126     TRACE("(%s, %p, %p, %d)\n", Filename, MajorVer, MinorVer, Version);
127     return GetVersionFromFileEx(Filename, MajorVer, MinorVer, Version);
128 }
129
130 /***********************************************************************
131  *             GetVersionFromFileEx    (ADVPACK.@)
132  */
133 HRESULT WINAPI GetVersionFromFileEx( LPSTR lpszFilename, LPDWORD pdwMSVer,
134                                      LPDWORD pdwLSVer, BOOL bVersion )
135 {
136     DWORD hdl, retval;
137     LPVOID pVersionInfo;
138     BOOL boolret;
139     VS_FIXEDFILEINFO *pFixedVersionInfo;
140     UINT uiLength;
141     TRACE("(%s, %p, %p, %d)\n", lpszFilename, pdwMSVer, pdwLSVer, bVersion);
142
143     if (bVersion)
144     {
145         retval = GetFileVersionInfoSizeA(lpszFilename, &hdl);
146         if (retval == 0 || hdl != 0)
147             return E_FAIL;
148
149         pVersionInfo = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, retval);
150         if (pVersionInfo == NULL)
151              return E_FAIL;
152         GetFileVersionInfoA( lpszFilename, 0, retval, pVersionInfo);
153
154         boolret = VerQueryValueA(pVersionInfo, "\\",
155                                  (LPVOID) &pFixedVersionInfo, &uiLength);
156
157         HeapFree(GetProcessHeap(), 0, pVersionInfo);
158
159         if (boolret)
160         {
161             *pdwMSVer = pFixedVersionInfo->dwFileVersionMS;
162             *pdwLSVer = pFixedVersionInfo->dwFileVersionLS;
163         }
164         else
165             return E_FAIL;
166     }
167     else
168     {
169         *pdwMSVer = GetUserDefaultUILanguage();
170         *pdwLSVer = GetACP();
171     }
172
173     return S_OK;
174 }