x11drv: Add support for another Canadian French keyboard flavour.
[wine/dcerpc.git] / dlls / advpack / advpack.c
blob4fcae962fe16c58b4e4d5462084dae3e3a980036
1 /*
2 * Advpack main
4 * Copyright 2004 Huw D M Davies
5 * Copyright 2005 Sami Aario
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include <stdarg.h>
24 #include "windef.h"
25 #include "winbase.h"
26 #include "winuser.h"
27 #include "winreg.h"
28 #include "winver.h"
29 #include "winnls.h"
30 #include "setupapi.h"
31 #include "advpub.h"
32 #include "wine/unicode.h"
33 #include "wine/debug.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(advpack);
37 typedef HRESULT (WINAPI *DLLREGISTER) (void);
39 /***********************************************************************
40 * CloseINFEngine (ADVPACK.@)
43 * PARAMS
44 * hInf [I]
46 * RETURNS
47 * Success: S_OK.
48 * Failure: E_FAIL.
50 * BUGS
51 * Unimplemented.
53 HRESULT WINAPI CloseINFEngine(HINF hInf)
55 FIXME("(%p) stub\n", hInf);
57 return E_FAIL;
60 /***********************************************************************
61 * DllMain (ADVPACK.@)
63 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
65 TRACE("(%p, %ld, %p)\n",hinstDLL, fdwReason, lpvReserved);
67 if (fdwReason == DLL_PROCESS_ATTACH)
68 DisableThreadLibraryCalls(hinstDLL);
70 return TRUE;
73 /***********************************************************************
74 * RunSetupCommand (ADVPACK.@)
76 * Executes an install section in an INF file or a program.
78 * PARAMS
79 * hWnd [I] Handle to parent window, NULL for quiet mode
80 * szCmdName [I] Inf or EXE filename to execute
81 * szInfSection [I] Inf section to install, NULL for DefaultInstall
82 * szDir [I] Path to extracted files
83 * szTitle [I] Title of all dialogs
84 * phEXE [O] Handle of EXE to wait for
85 * dwFlags [I] Flags; see include/advpub.h
86 * pvReserved [I] Reserved
88 * RETURNS
89 * S_OK Everything OK
90 * S_ASYNCHRONOUS OK, required to wait on phEXE
91 * ERROR_SUCCESS_REBOOT_REQUIRED Reboot required
92 * E_INVALIDARG Invalid argument given
93 * HRESULT_FROM_WIN32(ERROR_OLD_WIN_VERSION)
94 * Not supported on this Windows version
95 * E_UNEXPECTED Unexpected error
96 * HRESULT_FROM_WIN32(GetLastError()) Some other error
98 * BUGS
99 * Unimplemented
101 HRESULT WINAPI RunSetupCommand( HWND hWnd, LPCSTR szCmdName,
102 LPCSTR szInfSection, LPCSTR szDir,
103 LPCSTR lpszTitle, HANDLE *phEXE,
104 DWORD dwFlags, LPVOID pvReserved )
106 FIXME("(%p, %s, %s, %s, %s, %p, 0x%08lx, %p): stub\n",
107 hWnd, debugstr_a(szCmdName), debugstr_a(szInfSection),
108 debugstr_a(szDir), debugstr_a(lpszTitle),
109 phEXE, dwFlags, pvReserved);
110 return E_UNEXPECTED;
113 /***********************************************************************
114 * LaunchINFSection (ADVPACK.@)
116 * Installs an INF section without BACKUP/ROLLBACK capabilities.
118 * PARAMS
119 * hWnd [I] Handle to parent window, NULL for desktop.
120 * hInst [I] Instance of the process.
121 * cmdline [I] Contains parameters in the order INF,section,flags.
122 * show [I] Reboot behaviour:
123 * 'A' reboot always
124 * 'I' default, reboot if needed
125 * 'N' no reboot
127 * RETURNS
128 * Success: S_OK.
129 * Failure: S_FALSE
131 * BUGS
132 * Unimplemented.
134 INT WINAPI LaunchINFSection( HWND hWnd, HINSTANCE hInst, LPSTR cmdline, INT show )
136 FIXME("(%p %p %s %d): stub\n", hWnd, hInst, debugstr_a(cmdline), show );
137 return 0;
140 /***********************************************************************
141 * LaunchINFSectionEx (ADVPACK.@)
143 * Installs an INF section with BACKUP/ROLLBACK capabilities.
145 * PARAMS
146 * hWnd [I] Handle to parent window, NULL for desktop.
147 * hInst [I] Instance of the process.
148 * cmdline [I] Contains parameters in the order INF,section,CAB,flags.
149 * show [I] Reboot behaviour:
150 * 'A' reboot always
151 * 'I' default, reboot if needed
152 * 'N' no reboot
154 * RETURNS
155 * Success: S_OK.
156 * Failure: E_FAIL.
158 * BUGS
159 * Unimplemented.
161 HRESULT WINAPI LaunchINFSectionEx( HWND hWnd, HINSTANCE hInst, LPSTR cmdline, INT show )
163 FIXME("(%p %p %s %d): stub\n", hWnd, hInst, debugstr_a(cmdline), show );
164 return E_FAIL;
167 /* this structure very closely resembles parameters of RunSetupCommand() */
168 typedef struct
170 HWND hwnd;
171 LPCSTR title;
172 LPCSTR inf_name;
173 LPCSTR dir;
174 LPCSTR section_name;
175 } SETUPCOMMAND_PARAMS;
177 /***********************************************************************
178 * DoInfInstall (ADVPACK.@)
180 * Install an INF section.
182 * PARAMS
183 * setup [I] Structure containing install information.
185 * RETURNS
186 * S_OK Everything OK
187 * HRESULT_FROM_WIN32(GetLastError()) Some other error
189 HRESULT WINAPI DoInfInstall(const SETUPCOMMAND_PARAMS *setup)
191 BOOL ret;
192 HINF hinf;
193 void *callback_context;
195 TRACE("%p %s %s %s %s\n", setup->hwnd, debugstr_a(setup->title),
196 debugstr_a(setup->inf_name), debugstr_a(setup->dir),
197 debugstr_a(setup->section_name));
199 hinf = SetupOpenInfFileA(setup->inf_name, NULL, INF_STYLE_WIN4, NULL);
200 if (hinf == INVALID_HANDLE_VALUE) return HRESULT_FROM_WIN32(GetLastError());
202 callback_context = SetupInitDefaultQueueCallback(setup->hwnd);
204 ret = SetupInstallFromInfSectionA(NULL, hinf, setup->section_name, SPINST_ALL,
205 NULL, NULL, 0, SetupDefaultQueueCallbackA,
206 callback_context, NULL, NULL);
207 SetupTermDefaultQueueCallback(callback_context);
208 SetupCloseInfFile(hinf);
210 return ret ? S_OK : HRESULT_FROM_WIN32(GetLastError());
213 /***********************************************************************
214 * IsNTAdmin (ADVPACK.@)
216 * Checks if the user has admin privileges.
218 * PARAMS
219 * reserved [I] Reserved. Must be 0.
220 * pReserved [I] Reserved. Must be NULL.
222 * RETURNS
223 * TRUE if user has admin rights, FALSE otherwise.
225 * BUGS
226 * Unimplemented.
228 BOOL WINAPI IsNTAdmin( DWORD reserved, LPDWORD pReserved )
230 FIXME("(0x%08lx, %p): stub\n", reserved, pReserved);
231 return TRUE;
234 /***********************************************************************
235 * NeedRebootInit (ADVPACK.@)
237 * Sets up conditions for reboot checking.
239 * RETURNS
240 * Value required by NeedReboot.
242 DWORD WINAPI NeedRebootInit(VOID)
244 FIXME("(): stub\n");
245 return 0;
248 /***********************************************************************
249 * NeedReboot (ADVPACK.@)
251 * Determines whether a reboot is required.
253 * PARAMS
254 * dwRebootCheck [I] Value from NeedRebootInit.
256 * RETURNS
257 * TRUE if a reboot is needed, FALSE otherwise.
259 * BUGS
260 * Unimplemented.
262 BOOL WINAPI NeedReboot(DWORD dwRebootCheck)
264 FIXME("(0x%08lx): stub\n", dwRebootCheck);
265 return FALSE;
268 /***********************************************************************
269 * OpenINFEngine (ADVPACK.@)
271 * Opens and returns a handle to an INF file to be used by
272 * TranslateInfStringEx to continuously translate the INF file.
274 * PARAMS
275 * pszInfFilename [I] Filename of the INF to open.
276 * pszInstallSection [I] Name of the Install section in the INF.
277 * dwFlags [I] See advpub.h.
278 * phInf [O] Handle to the loaded INF file.
279 * pvReserved [I] Reserved. Must be NULL.
281 * RETURNS
282 * Success: S_OK.
283 * Failure: E_FAIL.
285 * BUGS
286 * Unimplemented.
288 HRESULT WINAPI OpenINFEngine(PCSTR pszInfFilename, PCSTR pszInstallSection,
289 DWORD dwFlags, HINF *phInf, PVOID pvReserved)
291 FIXME("(%p, %p, %ld, %p, %p) stub\n", pszInfFilename, pszInstallSection,
292 dwFlags, phInf, pvReserved);
294 return E_FAIL;
297 /***********************************************************************
298 * RegisterOCX (ADVPACK.@)
300 void WINAPI RegisterOCX( HWND hWnd, HINSTANCE hInst, LPCSTR cmdline, INT show )
302 WCHAR wszBuff[MAX_PATH];
303 WCHAR* pwcComma;
304 HMODULE hm;
305 DLLREGISTER pfnRegister;
306 HRESULT hr;
308 TRACE("(%s)\n", cmdline);
310 MultiByteToWideChar(CP_ACP, 0, cmdline, strlen(cmdline), wszBuff, MAX_PATH);
311 if ((pwcComma = strchrW( wszBuff, ',' ))) *pwcComma = 0;
313 TRACE("Parsed DLL name (%s)\n", debugstr_w(wszBuff));
315 hm = LoadLibraryExW(wszBuff, 0, LOAD_WITH_ALTERED_SEARCH_PATH);
316 if (!hm)
318 ERR("Couldn't load DLL: %s\n", debugstr_w(wszBuff));
319 return;
322 pfnRegister = (DLLREGISTER)GetProcAddress(hm, "DllRegisterServer");
323 if (pfnRegister == NULL)
325 ERR("DllRegisterServer entry point not found\n");
327 else
329 hr = pfnRegister();
330 if (hr != S_OK)
332 ERR("DllRegisterServer entry point returned %08lx\n", hr);
336 TRACE("Successfully registered OCX\n");
338 FreeLibrary(hm);
341 /***********************************************************************
342 * ExecuteCab (ADVPACK.@)
344 * Installs the INF file extracted from a specified cabinet file.
346 * PARAMS
347 * hwnd [I] Handle to the window used for the display.
348 * pCab [I] Information about the cabinet file.
349 * pReserved [I] Reserved. Must be NULL.
351 * RETURNS
352 * Success: S_OK.
353 * Failure: E_FAIL.
355 * BUGS
356 * Unimplemented
358 HRESULT WINAPI ExecuteCab( HWND hwnd, PCABINFO pCab, LPVOID pReserved )
360 FIXME("(%p %p %p): stub\n", hwnd, pCab, pReserved);
361 return E_FAIL;
364 /***********************************************************************
365 * TranslateInfString (ADVPACK.@)
367 * Translates the value of a specified key in an inf file into the
368 * current locale by expanding string macros.
370 * PARAMS
371 * pszInfFilename [I] Filename of the inf file.
372 * pszInstallSection [I]
373 * pszTranslateSection [I] Inf section where the key exists.
374 * pszTranslateKey [I] Key to translate.
375 * pszBuffer [O] Contains the translated string on exit.
376 * dwBufferSize [I] Size on input of pszBuffer.
377 * pdwRequiredSize [O] Length of the translated key.
378 * pvReserved [I] Reserved, must be NULL.
380 * RETURNS
381 * Success: S_OK.
382 * Failure: An hresult error code.
384 HRESULT WINAPI TranslateInfString(PCSTR pszInfFilename, PCSTR pszInstallSection,
385 PCSTR pszTranslateSection, PCSTR pszTranslateKey, PSTR pszBuffer,
386 DWORD dwBufferSize, PDWORD pdwRequiredSize, PVOID pvReserved)
388 HINF hInf;
390 TRACE("(%s %s %s %s %p %ld %p %p)\n",
391 debugstr_a(pszInfFilename), debugstr_a(pszInstallSection),
392 debugstr_a(pszTranslateSection), debugstr_a(pszTranslateKey),
393 pszBuffer, dwBufferSize,pdwRequiredSize, pvReserved);
395 if (!pszInfFilename || !pszTranslateSection ||
396 !pszTranslateKey || !pdwRequiredSize)
397 return E_INVALIDARG;
399 hInf = SetupOpenInfFileA(pszInfFilename, NULL, INF_STYLE_WIN4, NULL);
400 if (hInf == INVALID_HANDLE_VALUE)
401 return HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND);
403 if (!SetupGetLineTextA(NULL, hInf, pszTranslateSection, pszTranslateKey,
404 pszBuffer, dwBufferSize, pdwRequiredSize))
406 if (dwBufferSize < *pdwRequiredSize)
407 return HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER);
409 return SPAPI_E_LINE_NOT_FOUND;
412 return S_OK;
415 /***********************************************************************
416 * TranslateInfStringEx (ADVPACK.@)
418 * Using a handle to an INF file opened with OpenINFEngine, translates
419 * the value of a specified key in an inf file into the current locale
420 * by expanding string macros.
422 * PARAMS
423 * hInf [I] Handle to the INF file.
424 * pszInfFilename [I] Filename of the INF file.
425 * pszTranslateSection [I] Inf section where the key exists.
426 * pszTranslateKey [I] Key to translate.
427 * pszBuffer [O] Contains the translated string on exit.
428 * dwBufferSize [I] Size on input of pszBuffer.
429 * pdwRequiredSize [O] Length of the translated key.
430 * pvReserved [I] Reserved. Must be NULL.
432 * RETURNS
433 * Success: S_OK.
434 * Failure: E_FAIL.
436 * NOTES
437 * To use TranslateInfStringEx to translate an INF file continuously,
438 * open the INF file with OpenINFEngine, call TranslateInfStringEx as
439 * many times as needed, then release the handle with CloseINFEngine.
440 * When translating more than one keys, this method is more efficient
441 * than calling TranslateInfString, because the INF file is only
442 * opened once.
444 * BUGS
445 * Unimplemented.
447 HRESULT WINAPI TranslateInfStringEx(HINF hInf, PCSTR pszInfFilename,
448 PCSTR pszTranslateSection, PCSTR pszTranslateKey,
449 PSTR pszBuffer, DWORD dwBufferSize,
450 PDWORD pdwRequiredSize, PVOID pvReserved)
452 FIXME("(%p, %p, %p, %p, %p, %ld, %p, %p) stub\n", hInf, pszInfFilename,
453 pszTranslateSection, pszTranslateKey, pszBuffer, dwBufferSize,
454 pdwRequiredSize, pvReserved);
456 return E_FAIL;