2 * Implementation of the Microsoft Installer (msi.dll)
4 * Copyright 2002,2003,2004,2005 Mike McCormack for CodeWeavers
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
24 #define NONAMELESSUNION
31 #include "wine/debug.h"
41 #include "wine/unicode.h"
44 WINE_DEFAULT_DEBUG_CHANNEL(msi);
47 * The MSVC headers define the MSIDBOPEN_* macros cast to LPCTSTR,
48 * which is a problem because LPCTSTR isn't defined when compiling wine.
49 * To work around this problem, we need to define LPCTSTR as LPCWSTR here,
50 * and make sure to only use it in W functions.
52 #define LPCTSTR LPCWSTR
55 INSTALLUILEVEL gUILevel = INSTALLUILEVEL_BASIC;
57 INSTALLUI_HANDLERA gUIHandlerA = NULL;
58 INSTALLUI_HANDLERW gUIHandlerW = NULL;
60 LPVOID gUIContext = NULL;
61 WCHAR gszLogFile[MAX_PATH];
62 HINSTANCE msi_hInstance;
64 static const WCHAR installerW[] = {'\\','I','n','s','t','a','l','l','e','r',0};
66 UINT WINAPI MsiOpenProductA(LPCSTR szProduct, MSIHANDLE *phProduct)
69 LPWSTR szwProd = NULL;
71 TRACE("%s %p\n",debugstr_a(szProduct), phProduct);
75 szwProd = strdupAtoW( szProduct );
77 return ERROR_OUTOFMEMORY;
80 r = MsiOpenProductW( szwProd, phProduct );
87 static UINT MSI_OpenProductW( LPCWSTR szProduct, MSIPACKAGE **ppackage )
91 HKEY hKeyProduct = NULL;
94 TRACE("%s %p\n", debugstr_w(szProduct), ppackage );
96 r = MSIREG_OpenUninstallKey(szProduct,&hKeyProduct,FALSE);
97 if( r != ERROR_SUCCESS )
99 r = ERROR_UNKNOWN_PRODUCT;
103 /* find the size of the path */
105 r = RegQueryValueExW( hKeyProduct, INSTALLPROPERTY_LOCALPACKAGEW,
106 NULL, &type, NULL, &count );
107 if( r != ERROR_SUCCESS )
109 r = ERROR_UNKNOWN_PRODUCT;
113 /* now alloc and fetch the path of the database to open */
114 path = msi_alloc( count );
118 r = RegQueryValueExW( hKeyProduct, INSTALLPROPERTY_LOCALPACKAGEW,
119 NULL, &type, (LPBYTE) path, &count );
120 if( r != ERROR_SUCCESS )
122 r = ERROR_UNKNOWN_PRODUCT;
126 r = MSI_OpenPackageW( path, ppackage );
131 RegCloseKey( hKeyProduct );
136 UINT WINAPI MsiOpenProductW( LPCWSTR szProduct, MSIHANDLE *phProduct )
138 MSIPACKAGE *package = NULL;
141 r = MSI_OpenProductW( szProduct, &package );
142 if( r == ERROR_SUCCESS )
144 *phProduct = alloc_msihandle( &package->hdr );
145 msiobj_release( &package->hdr );
150 UINT WINAPI MsiAdvertiseProductA(LPCSTR szPackagePath, LPCSTR szScriptfilePath,
151 LPCSTR szTransforms, LANGID lgidLanguage)
153 FIXME("%s %s %s %08x\n",debugstr_a(szPackagePath),
154 debugstr_a(szScriptfilePath), debugstr_a(szTransforms), lgidLanguage);
155 return ERROR_CALL_NOT_IMPLEMENTED;
158 UINT WINAPI MsiAdvertiseProductW(LPCWSTR szPackagePath, LPCWSTR szScriptfilePath,
159 LPCWSTR szTransforms, LANGID lgidLanguage)
161 FIXME("%s %s %s %08x\n",debugstr_w(szPackagePath),
162 debugstr_w(szScriptfilePath), debugstr_w(szTransforms), lgidLanguage);
163 return ERROR_CALL_NOT_IMPLEMENTED;
166 UINT WINAPI MsiAdvertiseProductExA(LPCSTR szPackagePath, LPCSTR szScriptfilePath,
167 LPCSTR szTransforms, LANGID lgidLanguage, DWORD dwPlatform, DWORD dwOptions)
169 FIXME("%s %s %s %08x %08lx %08lx\n", debugstr_a(szPackagePath),
170 debugstr_a(szScriptfilePath), debugstr_a(szTransforms),
171 lgidLanguage, dwPlatform, dwOptions);
172 return ERROR_CALL_NOT_IMPLEMENTED;
175 UINT WINAPI MsiAdvertiseProductExW( LPCWSTR szPackagePath, LPCWSTR szScriptfilePath,
176 LPCWSTR szTransforms, LANGID lgidLanguage, DWORD dwPlatform, DWORD dwOptions)
178 FIXME("%s %s %s %08x %08lx %08lx\n", debugstr_w(szPackagePath),
179 debugstr_w(szScriptfilePath), debugstr_w(szTransforms),
180 lgidLanguage, dwPlatform, dwOptions);
181 return ERROR_CALL_NOT_IMPLEMENTED;
184 UINT WINAPI MsiInstallProductA(LPCSTR szPackagePath, LPCSTR szCommandLine)
186 LPWSTR szwPath = NULL, szwCommand = NULL;
187 UINT r = ERROR_OUTOFMEMORY;
189 TRACE("%s %s\n",debugstr_a(szPackagePath), debugstr_a(szCommandLine));
193 szwPath = strdupAtoW( szPackagePath );
200 szwCommand = strdupAtoW( szCommandLine );
205 r = MsiInstallProductW( szwPath, szwCommand );
209 msi_free( szwCommand );
214 UINT WINAPI MsiInstallProductW(LPCWSTR szPackagePath, LPCWSTR szCommandLine)
216 MSIPACKAGE *package = NULL;
219 FIXME("%s %s\n",debugstr_w(szPackagePath), debugstr_w(szCommandLine));
221 r = MSI_OpenPackageW( szPackagePath, &package );
222 if (r == ERROR_SUCCESS)
224 r = MSI_InstallPackage( package, szPackagePath, szCommandLine );
225 msiobj_release( &package->hdr );
231 UINT WINAPI MsiReinstallProductA(LPCSTR szProduct, DWORD dwReinstallMode)
233 FIXME("%s %08lx\n", debugstr_a(szProduct), dwReinstallMode);
234 return ERROR_CALL_NOT_IMPLEMENTED;
237 UINT WINAPI MsiReinstallProductW(LPCWSTR szProduct, DWORD dwReinstallMode)
239 FIXME("%s %08lx\n", debugstr_w(szProduct), dwReinstallMode);
240 return ERROR_CALL_NOT_IMPLEMENTED;
243 UINT WINAPI MsiApplyPatchA(LPCSTR szPatchPackage, LPCSTR szInstallPackage,
244 INSTALLTYPE eInstallType, LPCSTR szCommandLine)
246 FIXME("%s %s %d %s\n", debugstr_a(szPatchPackage), debugstr_a(szInstallPackage),
247 eInstallType, debugstr_a(szCommandLine));
248 return ERROR_CALL_NOT_IMPLEMENTED;
251 UINT WINAPI MsiApplyPatchW(LPCWSTR szPatchPackage, LPCWSTR szInstallPackage,
252 INSTALLTYPE eInstallType, LPCWSTR szCommandLine)
254 FIXME("%s %s %d %s\n", debugstr_w(szPatchPackage), debugstr_w(szInstallPackage),
255 eInstallType, debugstr_w(szCommandLine));
256 return ERROR_CALL_NOT_IMPLEMENTED;
259 UINT WINAPI MsiConfigureProductExW(LPCWSTR szProduct, int iInstallLevel,
260 INSTALLSTATE eInstallState, LPCWSTR szCommandLine)
262 MSIPACKAGE* package = NULL;
265 WCHAR sourcepath[MAX_PATH];
266 WCHAR filename[MAX_PATH];
267 static const WCHAR szInstalled[] = {
268 ' ','I','n','s','t','a','l','l','e','d','=','1',0};
271 FIXME("%s %d %d %s\n",debugstr_w(szProduct), iInstallLevel, eInstallState,
272 debugstr_w(szCommandLine));
274 if (eInstallState != INSTALLSTATE_LOCAL &&
275 eInstallState != INSTALLSTATE_DEFAULT)
277 FIXME("Not implemented for anything other than local installs\n");
278 return ERROR_CALL_NOT_IMPLEMENTED;
281 sz = sizeof(sourcepath);
282 MsiSourceListGetInfoW(szProduct, NULL, MSIINSTALLCONTEXT_USERMANAGED,
283 MSICODE_PRODUCT, INSTALLPROPERTY_LASTUSEDSOURCEW, sourcepath,
286 sz = sizeof(filename);
287 MsiSourceListGetInfoW(szProduct, NULL, MSIINSTALLCONTEXT_USERMANAGED,
288 MSICODE_PRODUCT, INSTALLPROPERTY_PACKAGENAMEW, filename, &sz);
290 lstrcatW(sourcepath,filename);
293 * ok 1, we need to find the msi file for this product.
294 * 2, find the source dir for the files
295 * 3, do the configure/install.
296 * 4, cleanupany runonce entry.
299 r = MSI_OpenProductW( szProduct, &package );
300 if (r != ERROR_SUCCESS)
303 sz = lstrlenW(szInstalled) + 1;
306 sz += lstrlenW(szCommandLine);
308 commandline = msi_alloc(sz * sizeof(WCHAR));
311 r = ERROR_OUTOFMEMORY;
317 lstrcpyW(commandline,szCommandLine);
319 if (MsiQueryProductStateW(szProduct) != INSTALLSTATE_UNKNOWN)
320 lstrcatW(commandline,szInstalled);
322 r = MSI_InstallPackage( package, sourcepath, commandline );
324 msi_free(commandline);
327 msiobj_release( &package->hdr );
332 UINT WINAPI MsiConfigureProductExA(LPCSTR szProduct, int iInstallLevel,
333 INSTALLSTATE eInstallState, LPCSTR szCommandLine)
335 LPWSTR szwProduct = NULL;
336 LPWSTR szwCommandLine = NULL;
337 UINT r = ERROR_OUTOFMEMORY;
341 szwProduct = strdupAtoW( szProduct );
348 szwCommandLine = strdupAtoW( szCommandLine );
353 r = MsiConfigureProductExW( szwProduct, iInstallLevel, eInstallState,
356 msi_free( szwProduct );
357 msi_free( szwCommandLine);
362 UINT WINAPI MsiConfigureProductA(LPCSTR szProduct, int iInstallLevel,
363 INSTALLSTATE eInstallState)
365 LPWSTR szwProduct = NULL;
368 TRACE("%s %d %d\n",debugstr_a(szProduct), iInstallLevel, eInstallState);
372 szwProduct = strdupAtoW( szProduct );
374 return ERROR_OUTOFMEMORY;
377 r = MsiConfigureProductW( szwProduct, iInstallLevel, eInstallState );
378 msi_free( szwProduct );
383 UINT WINAPI MsiConfigureProductW(LPCWSTR szProduct, int iInstallLevel,
384 INSTALLSTATE eInstallState)
386 FIXME("%s %d %d\n", debugstr_w(szProduct), iInstallLevel, eInstallState);
388 return MsiConfigureProductExW(szProduct, iInstallLevel, eInstallState, NULL);
391 UINT WINAPI MsiGetProductCodeA(LPCSTR szComponent, LPSTR szBuffer)
393 LPWSTR szwComponent = NULL;
395 WCHAR szwBuffer[GUID_SIZE];
397 TRACE("%s %s\n",debugstr_a(szComponent), debugstr_a(szBuffer));
401 szwComponent = strdupAtoW( szComponent );
403 return ERROR_OUTOFMEMORY;
406 r = MsiGetProductCodeW( szwComponent, szwBuffer );
408 if( ERROR_SUCCESS == r )
409 WideCharToMultiByte(CP_ACP, 0, szwBuffer, -1, szBuffer, GUID_SIZE, NULL, NULL);
411 msi_free( szwComponent );
416 UINT WINAPI MsiGetProductCodeW(LPCWSTR szComponent, LPWSTR szBuffer)
420 WCHAR szSquished[GUID_SIZE];
421 DWORD sz = GUID_SIZE;
422 static const WCHAR szPermKey[] =
423 { '0','0','0','0','0','0','0','0','0','0','0','0',
424 '0','0','0','0','0','0','0','0','0','0','0','0',
425 '0','0','0','0','0','0','0','0',0};
427 TRACE("%s %p\n",debugstr_w(szComponent), szBuffer);
429 if (NULL == szComponent)
430 return ERROR_INVALID_PARAMETER;
432 rc = MSIREG_OpenComponentsKey( szComponent, &hkey, FALSE);
433 if (rc != ERROR_SUCCESS)
434 return ERROR_UNKNOWN_COMPONENT;
436 rc = RegEnumValueW(hkey, 0, szSquished, &sz, NULL, NULL, NULL, NULL);
437 if (rc == ERROR_SUCCESS && strcmpW(szSquished,szPermKey)==0)
440 rc = RegEnumValueW(hkey, 1, szSquished, &sz, NULL, NULL, NULL, NULL);
445 if (rc != ERROR_SUCCESS)
446 return ERROR_INSTALL_FAILURE;
448 unsquash_guid(szSquished, szBuffer);
449 return ERROR_SUCCESS;
452 UINT WINAPI MsiGetProductInfoA(LPCSTR szProduct, LPCSTR szAttribute,
453 LPSTR szBuffer, DWORD *pcchValueBuf)
455 LPWSTR szwProduct = NULL, szwAttribute = NULL, szwBuffer = NULL;
456 UINT r = ERROR_OUTOFMEMORY;
457 DWORD pcchwValueBuf = 0;
459 TRACE("%s %s %p %p\n", debugstr_a(szProduct), debugstr_a(szAttribute),
460 szBuffer, pcchValueBuf);
464 szwProduct = strdupAtoW( szProduct );
471 szwAttribute = strdupAtoW( szAttribute );
478 szwBuffer = msi_alloc( (*pcchValueBuf) * sizeof(WCHAR) );
479 pcchwValueBuf = *pcchValueBuf;
484 r = MsiGetProductInfoW( szwProduct, szwAttribute, szwBuffer,
487 if( ERROR_SUCCESS == r )
489 INT old_len = *pcchValueBuf;
490 *pcchValueBuf = WideCharToMultiByte(CP_ACP, 0, szwBuffer, pcchwValueBuf,
491 szBuffer, *pcchValueBuf, NULL, NULL);
492 if (old_len > *pcchValueBuf)
493 szBuffer[*pcchValueBuf]=0;
497 msi_free( szwProduct );
498 msi_free( szwAttribute );
499 msi_free( szwBuffer );
504 UINT WINAPI MsiGetProductInfoW(LPCWSTR szProduct, LPCWSTR szAttribute,
505 LPWSTR szBuffer, DWORD *pcchValueBuf)
509 static const WCHAR szProductVersion[] =
510 {'P','r','o','d','u','c','t','V','e','r','s','i','o','n',0};
511 static const WCHAR szProductLanguage[] =
512 {'P','r','o','d','u','c','t','L','a','n','g','u','a','g','e',0};
514 FIXME("%s %s %p %p\n",debugstr_w(szProduct), debugstr_w(szAttribute),
515 szBuffer, pcchValueBuf);
517 if (NULL != szBuffer && NULL == pcchValueBuf)
518 return ERROR_INVALID_PARAMETER;
519 if (NULL == szProduct || NULL == szAttribute)
520 return ERROR_INVALID_PARAMETER;
522 /* check for special properties */
523 if (strcmpW(szAttribute, INSTALLPROPERTY_PACKAGECODEW)==0)
526 WCHAR squished[GUID_SIZE];
528 DWORD sz = sizeof(squished);
530 r = MSIREG_OpenUserProductsKey(szProduct, &hkey, FALSE);
531 if (r != ERROR_SUCCESS)
532 return ERROR_UNKNOWN_PRODUCT;
534 r = RegQueryValueExW(hkey, INSTALLPROPERTY_PACKAGECODEW, NULL, NULL,
535 (LPBYTE)squished, &sz);
536 if (r != ERROR_SUCCESS)
539 return ERROR_UNKNOWN_PRODUCT;
542 unsquash_guid(squished, package);
543 *pcchValueBuf = strlenW(package);
544 if (strlenW(package) > *pcchValueBuf)
547 return ERROR_MORE_DATA;
550 strcpyW(szBuffer, package);
555 else if (strcmpW(szAttribute, INSTALLPROPERTY_VERSIONSTRINGW)==0)
557 r = MsiOpenProductW(szProduct, &hProduct);
558 if (ERROR_SUCCESS != r)
561 r = MsiGetPropertyW(hProduct, szProductVersion, szBuffer, pcchValueBuf);
562 MsiCloseHandle(hProduct);
564 else if (strcmpW(szAttribute, INSTALLPROPERTY_ASSIGNMENTTYPEW)==0)
566 FIXME("0 (zero) if advertised or per user , 1(one) if per machine.\n");
576 else if (strcmpW(szAttribute, INSTALLPROPERTY_LANGUAGEW)==0)
578 r = MsiOpenProductW(szProduct, &hProduct);
579 if (ERROR_SUCCESS != r)
582 r = MsiGetPropertyW(hProduct, szProductLanguage, szBuffer, pcchValueBuf);
583 MsiCloseHandle(hProduct);
587 r = MsiOpenProductW(szProduct, &hProduct);
588 if (ERROR_SUCCESS != r)
591 r = MsiGetPropertyW(hProduct, szAttribute, szBuffer, pcchValueBuf);
592 MsiCloseHandle(hProduct);
598 UINT WINAPI MsiEnableLogA(DWORD dwLogMode, LPCSTR szLogFile, DWORD attributes)
600 LPWSTR szwLogFile = NULL;
603 TRACE("%08lx %s %08lx\n", dwLogMode, debugstr_a(szLogFile), attributes);
607 szwLogFile = strdupAtoW( szLogFile );
609 return ERROR_OUTOFMEMORY;
611 r = MsiEnableLogW( dwLogMode, szwLogFile, attributes );
612 msi_free( szwLogFile );
616 UINT WINAPI MsiEnableLogW(DWORD dwLogMode, LPCWSTR szLogFile, DWORD attributes)
618 HANDLE file = INVALID_HANDLE_VALUE;
620 TRACE("%08lx %s %08lx\n", dwLogMode, debugstr_w(szLogFile), attributes);
622 lstrcpyW(gszLogFile,szLogFile);
623 if (!(attributes & INSTALLLOGATTRIBUTES_APPEND))
624 DeleteFileW(szLogFile);
625 file = CreateFileW(szLogFile, GENERIC_WRITE, 0, NULL, OPEN_ALWAYS,
626 FILE_ATTRIBUTE_NORMAL, NULL);
627 if (file != INVALID_HANDLE_VALUE)
630 ERR("Unable to enable log %s\n",debugstr_w(szLogFile));
632 return ERROR_SUCCESS;
635 INSTALLSTATE WINAPI MsiQueryProductStateA(LPCSTR szProduct)
637 LPWSTR szwProduct = NULL;
642 szwProduct = strdupAtoW( szProduct );
644 return ERROR_OUTOFMEMORY;
646 r = MsiQueryProductStateW( szwProduct );
647 msi_free( szwProduct );
651 INSTALLSTATE WINAPI MsiQueryProductStateW(LPCWSTR szProduct)
654 INSTALLSTATE rrc = INSTALLSTATE_UNKNOWN;
656 static const WCHAR szWindowsInstaller[] = {
657 'W','i','n','d','o','w','s','I','n','s','t','a','l','l','e','r',0 };
660 TRACE("%s\n", debugstr_w(szProduct));
662 rc = MSIREG_OpenUserProductsKey(szProduct,&hkey,FALSE);
663 if (rc != ERROR_SUCCESS)
668 rc = MSIREG_OpenUninstallKey(szProduct,&hkey,FALSE);
669 if (rc != ERROR_SUCCESS)
673 rc = RegQueryValueExW(hkey,szWindowsInstaller,NULL,NULL,(LPVOID)&rrc, &sz);
674 if (rc != ERROR_SUCCESS)
681 rrc = INSTALLSTATE_DEFAULT;
684 FIXME("Unknown install state read from registry (%i)\n",rrc);
685 rrc = INSTALLSTATE_UNKNOWN;
693 INSTALLUILEVEL WINAPI MsiSetInternalUI(INSTALLUILEVEL dwUILevel, HWND *phWnd)
695 INSTALLUILEVEL old = gUILevel;
696 HWND oldwnd = gUIhwnd;
698 TRACE("%08x %p\n", dwUILevel, phWnd);
700 gUILevel = dwUILevel;
709 INSTALLUI_HANDLERA WINAPI MsiSetExternalUIA(INSTALLUI_HANDLERA puiHandler,
710 DWORD dwMessageFilter, LPVOID pvContext)
712 INSTALLUI_HANDLERA prev = gUIHandlerA;
714 TRACE("%p %lx %p\n",puiHandler, dwMessageFilter,pvContext);
715 gUIHandlerA = puiHandler;
716 gUIFilter = dwMessageFilter;
717 gUIContext = pvContext;
722 INSTALLUI_HANDLERW WINAPI MsiSetExternalUIW(INSTALLUI_HANDLERW puiHandler,
723 DWORD dwMessageFilter, LPVOID pvContext)
725 INSTALLUI_HANDLERW prev = gUIHandlerW;
727 TRACE("%p %lx %p\n",puiHandler,dwMessageFilter,pvContext);
728 gUIHandlerW = puiHandler;
729 gUIFilter = dwMessageFilter;
730 gUIContext = pvContext;
735 /******************************************************************
736 * MsiLoadStringW [MSI.@]
738 * Loads a string from MSI's string resources.
742 * handle [I] only -1 is handled currently
743 * id [I] id of the string to be loaded
744 * lpBuffer [O] buffer for the string to be written to
745 * nBufferMax [I] maximum size of the buffer in characters
746 * lang [I] the preferred language for the string
750 * If successful, this function returns the language id of the string loaded
751 * If the function fails, the function returns zero.
755 * The type of the first parameter is unknown. LoadString's prototype
756 * suggests that it might be a module handle. I have made it an MSI handle
757 * for starters, as -1 is an invalid MSI handle, but not an invalid module
758 * handle. Maybe strings can be stored in an MSI database somehow.
760 LANGID WINAPI MsiLoadStringW( MSIHANDLE handle, UINT id, LPWSTR lpBuffer,
761 int nBufferMax, LANGID lang )
768 TRACE("%ld %u %p %d %d\n", handle, id, lpBuffer, nBufferMax, lang);
771 FIXME("don't know how to deal with handle = %08lx\n", handle);
774 lang = GetUserDefaultLangID();
776 hres = FindResourceExW( msi_hInstance, (LPCWSTR) RT_STRING,
780 hResData = LoadResource( msi_hInstance, hres );
783 p = LockResource( hResData );
787 for (i = 0; i < (id&0xf); i++)
791 if( nBufferMax <= len )
794 memcpy( lpBuffer, p+1, len * sizeof(WCHAR));
797 TRACE("found -> %s\n", debugstr_w(lpBuffer));
802 LANGID WINAPI MsiLoadStringA( MSIHANDLE handle, UINT id, LPSTR lpBuffer,
803 int nBufferMax, LANGID lang )
809 bufW = msi_alloc(nBufferMax*sizeof(WCHAR));
810 r = MsiLoadStringW(handle, id, bufW, nBufferMax, lang);
813 len = WideCharToMultiByte(CP_ACP, 0, bufW, -1, NULL, 0, NULL, NULL );
814 if( len <= nBufferMax )
815 WideCharToMultiByte( CP_ACP, 0, bufW, -1,
816 lpBuffer, nBufferMax, NULL, NULL );
824 INSTALLSTATE WINAPI MsiLocateComponentA(LPCSTR szComponent, LPSTR lpPathBuf,
827 FIXME("%s %p %p\n", debugstr_a(szComponent), lpPathBuf, pcchBuf);
828 return INSTALLSTATE_UNKNOWN;
831 INSTALLSTATE WINAPI MsiLocateComponentW(LPCWSTR szComponent, LPWSTR lpPathBuf,
834 FIXME("%s %p %p\n", debugstr_w(szComponent), lpPathBuf, pcchBuf);
835 return INSTALLSTATE_UNKNOWN;
838 UINT WINAPI MsiMessageBoxA(HWND hWnd, LPCSTR lpText, LPCSTR lpCaption, UINT uType,
839 WORD wLanguageId, DWORD f)
841 FIXME("%p %s %s %u %08x %08lx\n",hWnd,debugstr_a(lpText),debugstr_a(lpCaption),
842 uType,wLanguageId,f);
843 return ERROR_CALL_NOT_IMPLEMENTED;
846 UINT WINAPI MsiMessageBoxW(HWND hWnd, LPCWSTR lpText, LPCWSTR lpCaption, UINT uType,
847 WORD wLanguageId, DWORD f)
849 FIXME("%p %s %s %u %08x %08lx\n",hWnd,debugstr_w(lpText),debugstr_w(lpCaption),
850 uType,wLanguageId,f);
851 return ERROR_CALL_NOT_IMPLEMENTED;
854 UINT WINAPI MsiProvideAssemblyA( LPCSTR szAssemblyName, LPCSTR szAppContext,
855 DWORD dwInstallMode, DWORD dwAssemblyInfo, LPSTR lpPathBuf,
858 FIXME("%s %s %08lx %08lx %p %p\n", debugstr_a(szAssemblyName),
859 debugstr_a(szAppContext), dwInstallMode, dwAssemblyInfo, lpPathBuf,
861 return ERROR_CALL_NOT_IMPLEMENTED;
864 UINT WINAPI MsiProvideAssemblyW( LPCWSTR szAssemblyName, LPCWSTR szAppContext,
865 DWORD dwInstallMode, DWORD dwAssemblyInfo, LPWSTR lpPathBuf,
868 FIXME("%s %s %08lx %08lx %p %p\n", debugstr_w(szAssemblyName),
869 debugstr_w(szAppContext), dwInstallMode, dwAssemblyInfo, lpPathBuf,
871 return ERROR_CALL_NOT_IMPLEMENTED;
874 UINT WINAPI MsiProvideComponentFromDescriptorA( LPCSTR szDescriptor,
875 LPSTR szPath, DWORD *pcchPath, DWORD *pcchArgs )
877 FIXME("%s %p %p %p\n", debugstr_a(szDescriptor), szPath, pcchPath, pcchArgs );
878 return ERROR_CALL_NOT_IMPLEMENTED;
881 UINT WINAPI MsiProvideComponentFromDescriptorW( LPCWSTR szDescriptor,
882 LPWSTR szPath, DWORD *pcchPath, DWORD *pcchArgs )
884 FIXME("%s %p %p %p\n", debugstr_w(szDescriptor), szPath, pcchPath, pcchArgs );
885 return ERROR_CALL_NOT_IMPLEMENTED;
888 HRESULT WINAPI MsiGetFileSignatureInformationA( LPCSTR szSignedObjectPath,
889 DWORD dwFlags, PCCERT_CONTEXT* ppcCertContext, BYTE* pbHashData,
892 FIXME("%s %08lx %p %p %p\n", debugstr_a(szSignedObjectPath), dwFlags,
893 ppcCertContext, pbHashData, pcbHashData);
894 return ERROR_CALL_NOT_IMPLEMENTED;
897 HRESULT WINAPI MsiGetFileSignatureInformationW( LPCWSTR szSignedObjectPath,
898 DWORD dwFlags, PCCERT_CONTEXT* ppcCertContext, BYTE* pbHashData,
901 FIXME("%s %08lx %p %p %p\n", debugstr_w(szSignedObjectPath), dwFlags,
902 ppcCertContext, pbHashData, pcbHashData);
903 return ERROR_CALL_NOT_IMPLEMENTED;
906 UINT WINAPI MsiGetProductPropertyA( MSIHANDLE hProduct, LPCSTR szProperty,
907 LPSTR szValue, DWORD *pccbValue )
909 FIXME("%ld %s %p %p\n", hProduct, debugstr_a(szProperty), szValue, pccbValue);
910 return ERROR_CALL_NOT_IMPLEMENTED;
913 UINT WINAPI MsiGetProductPropertyW( MSIHANDLE hProduct, LPCWSTR szProperty,
914 LPWSTR szValue, DWORD *pccbValue )
916 FIXME("%ld %s %p %p\n", hProduct, debugstr_w(szProperty), szValue, pccbValue);
917 return ERROR_CALL_NOT_IMPLEMENTED;
920 UINT WINAPI MsiVerifyPackageA( LPCSTR szPackage )
923 LPWSTR szPack = NULL;
925 TRACE("%s\n", debugstr_a(szPackage) );
929 szPack = strdupAtoW( szPackage );
931 return ERROR_OUTOFMEMORY;
934 r = MsiVerifyPackageW( szPack );
941 UINT WINAPI MsiVerifyPackageW( LPCWSTR szPackage )
946 TRACE("%s\n", debugstr_w(szPackage) );
948 r = MsiOpenDatabaseW( szPackage, MSIDBOPEN_READONLY, &handle );
949 MsiCloseHandle( handle );
954 INSTALLSTATE WINAPI MsiGetComponentPathA(LPCSTR szProduct, LPCSTR szComponent,
955 LPSTR lpPathBuf, DWORD* pcchBuf)
957 LPWSTR szwProduct = NULL, szwComponent = NULL, lpwPathBuf= NULL;
963 szwProduct = strdupAtoW( szProduct );
965 return ERROR_OUTOFMEMORY;
970 szwComponent = strdupAtoW( szComponent );
973 msi_free( szwProduct);
974 return ERROR_OUTOFMEMORY;
978 if( pcchBuf && *pcchBuf > 0 )
980 lpwPathBuf = msi_alloc( *pcchBuf * sizeof(WCHAR));
981 incoming_len = *pcchBuf;
989 rc = MsiGetComponentPathW(szwProduct, szwComponent, lpwPathBuf, pcchBuf);
991 msi_free( szwProduct);
992 msi_free( szwComponent);
995 if (rc != INSTALLSTATE_UNKNOWN)
996 WideCharToMultiByte(CP_ACP, 0, lpwPathBuf, incoming_len,
997 lpPathBuf, incoming_len, NULL, NULL);
998 msi_free( lpwPathBuf);
1004 INSTALLSTATE WINAPI MsiGetComponentPathW(LPCWSTR szProduct, LPCWSTR szComponent,
1005 LPWSTR lpPathBuf, DWORD* pcchBuf)
1007 WCHAR squished_pc[GUID_SIZE];
1009 INSTALLSTATE rrc = INSTALLSTATE_UNKNOWN;
1014 TRACE("%s %s %p %p\n", debugstr_w(szProduct),
1015 debugstr_w(szComponent), lpPathBuf, pcchBuf);
1018 return INSTALLSTATE_INVALIDARG;
1019 if( lpPathBuf && !pcchBuf )
1020 return INSTALLSTATE_INVALIDARG;
1022 squash_guid(szProduct,squished_pc);
1024 rc = MSIREG_OpenProductsKey( szProduct, &hkey, FALSE);
1025 if( rc != ERROR_SUCCESS )
1030 rc = MSIREG_OpenComponentsKey( szComponent, &hkey, FALSE);
1031 if( rc != ERROR_SUCCESS )
1036 rc = RegQueryValueExW( hkey, squished_pc, NULL, &type, NULL, &sz );
1037 if( rc != ERROR_SUCCESS )
1039 if( type != REG_SZ )
1042 sz += sizeof(WCHAR);
1043 path = msi_alloc( sz );
1047 rc = RegQueryValueExW( hkey, squished_pc, NULL, NULL, (LPVOID) path, &sz );
1048 if( rc != ERROR_SUCCESS )
1051 TRACE("found path of (%s:%s)(%s)\n", debugstr_w(szComponent),
1052 debugstr_w(szProduct), debugstr_w(path));
1056 FIXME("Registry entry.. check entry\n");
1057 rrc = INSTALLSTATE_LOCAL;
1061 /* PROBABLY a file */
1062 if ( GetFileAttributesW(path) != INVALID_FILE_ATTRIBUTES )
1063 rrc = INSTALLSTATE_LOCAL;
1065 rrc = INSTALLSTATE_ABSENT;
1070 sz = sz / sizeof(WCHAR);
1071 if( *pcchBuf >= sz )
1072 lstrcpyW( lpPathBuf, path );
1082 /******************************************************************
1083 * MsiQueryFeatureStateA [MSI.@]
1085 INSTALLSTATE WINAPI MsiQueryFeatureStateA(LPCSTR szProduct, LPCSTR szFeature)
1088 LPWSTR szwProduct= NULL;
1089 LPWSTR szwFeature= NULL;
1093 szwProduct = strdupAtoW( szProduct );
1095 return ERROR_OUTOFMEMORY;
1100 szwFeature = strdupAtoW( szFeature );
1103 msi_free( szwProduct);
1104 return ERROR_OUTOFMEMORY;
1108 rc = MsiQueryFeatureStateW(szwProduct, szwFeature);
1110 msi_free( szwProduct);
1111 msi_free( szwFeature);
1116 /******************************************************************
1117 * MsiQueryFeatureStateW [MSI.@]
1119 * This does not verify that the Feature is functional. So i am only going to
1120 * check the existence of the key in the registry. This should tell me if it is
1123 INSTALLSTATE WINAPI MsiQueryFeatureStateW(LPCWSTR szProduct, LPCWSTR szFeature)
1129 TRACE("%s %s\n", debugstr_w(szProduct), debugstr_w(szFeature));
1131 rc = MSIREG_OpenFeaturesKey(szProduct, &hkey, FALSE);
1132 if (rc != ERROR_SUCCESS)
1133 return INSTALLSTATE_UNKNOWN;
1135 rc = RegQueryValueExW( hkey, szFeature, NULL, NULL, NULL, &sz);
1138 if (rc == ERROR_SUCCESS)
1139 return INSTALLSTATE_LOCAL;
1141 return INSTALLSTATE_ABSENT;
1144 /******************************************************************
1145 * MsiGetFileVersionA [MSI.@]
1147 UINT WINAPI MsiGetFileVersionA(LPCSTR szFilePath, LPSTR lpVersionBuf,
1148 DWORD* pcchVersionBuf, LPSTR lpLangBuf, DWORD* pcchLangBuf)
1150 LPWSTR szwFilePath = NULL, lpwVersionBuff = NULL, lpwLangBuff = NULL;
1151 UINT ret = ERROR_OUTOFMEMORY;
1155 szwFilePath = strdupAtoW( szFilePath );
1160 if( lpVersionBuf && pcchVersionBuf && *pcchVersionBuf )
1162 lpwVersionBuff = msi_alloc(*pcchVersionBuf*sizeof(WCHAR));
1163 if( !lpwVersionBuff )
1167 if( lpLangBuf && pcchLangBuf && *pcchLangBuf )
1169 lpwLangBuff = msi_alloc(*pcchVersionBuf*sizeof(WCHAR));
1174 ret = MsiGetFileVersionW(szwFilePath, lpwVersionBuff, pcchVersionBuf,
1175 lpwLangBuff, pcchLangBuf);
1177 if( lpwVersionBuff )
1178 WideCharToMultiByte(CP_ACP, 0, lpwVersionBuff, -1,
1179 lpVersionBuf, *pcchVersionBuf, NULL, NULL);
1181 WideCharToMultiByte(CP_ACP, 0, lpwLangBuff, -1,
1182 lpLangBuf, *pcchLangBuf, NULL, NULL);
1185 msi_free(szwFilePath);
1186 msi_free(lpwVersionBuff);
1187 msi_free(lpwLangBuff);
1192 /******************************************************************
1193 * MsiGetFileVersionW [MSI.@]
1195 UINT WINAPI MsiGetFileVersionW(LPCWSTR szFilePath, LPWSTR lpVersionBuf,
1196 DWORD* pcchVersionBuf, LPWSTR lpLangBuf, DWORD* pcchLangBuf)
1198 static const WCHAR szVersionResource[] = {'\\',0};
1199 static const WCHAR szVersionFormat[] = {
1200 '%','d','.','%','d','.','%','d','.','%','d',0};
1201 static const WCHAR szLangFormat[] = {'%','d',0};
1204 LPVOID lpVer = NULL;
1205 VS_FIXEDFILEINFO *ffi;
1209 TRACE("%s %p %ld %p %ld\n", debugstr_w(szFilePath),
1210 lpVersionBuf, pcchVersionBuf?*pcchVersionBuf:0,
1211 lpLangBuf, pcchLangBuf?*pcchLangBuf:0);
1213 dwVerLen = GetFileVersionInfoSizeW(szFilePath, NULL);
1215 return GetLastError();
1217 lpVer = msi_alloc(dwVerLen);
1220 ret = ERROR_OUTOFMEMORY;
1224 if( !GetFileVersionInfoW(szFilePath, 0, dwVerLen, lpVer) )
1226 ret = GetLastError();
1229 if( lpVersionBuf && pcchVersionBuf && *pcchVersionBuf )
1231 if( VerQueryValueW(lpVer, szVersionResource, (LPVOID*)&ffi, &puLen) &&
1234 wsprintfW(tmp, szVersionFormat,
1235 HIWORD(ffi->dwFileVersionMS), LOWORD(ffi->dwFileVersionMS),
1236 HIWORD(ffi->dwFileVersionLS), LOWORD(ffi->dwFileVersionLS));
1237 lstrcpynW(lpVersionBuf, tmp, *pcchVersionBuf);
1238 *pcchVersionBuf = lstrlenW(lpVersionBuf);
1243 *pcchVersionBuf = 0;
1247 if( lpLangBuf && pcchLangBuf && *pcchLangBuf )
1249 DWORD lang = GetUserDefaultLangID();
1251 FIXME("Retrieve language from file\n");
1252 wsprintfW(tmp, szLangFormat, lang);
1253 lstrcpynW(lpLangBuf, tmp, *pcchLangBuf);
1254 *pcchLangBuf = lstrlenW(lpLangBuf);
1263 /******************************************************************
1266 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
1270 case DLL_PROCESS_ATTACH:
1271 msi_hInstance = hinstDLL;
1272 DisableThreadLibraryCalls(hinstDLL);
1273 msi_dialog_register_class();
1275 case DLL_PROCESS_DETACH:
1276 msi_dialog_unregister_class();
1277 /* FIXME: Cleanup */
1283 typedef struct tagIClassFactoryImpl
1285 const IClassFactoryVtbl *lpVtbl;
1286 } IClassFactoryImpl;
1288 static HRESULT WINAPI MsiCF_QueryInterface(LPCLASSFACTORY iface,
1289 REFIID riid,LPVOID *ppobj)
1291 IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
1292 FIXME("%p %s %p\n",This,debugstr_guid(riid),ppobj);
1293 return E_NOINTERFACE;
1296 static ULONG WINAPI MsiCF_AddRef(LPCLASSFACTORY iface)
1301 static ULONG WINAPI MsiCF_Release(LPCLASSFACTORY iface)
1306 static HRESULT WINAPI MsiCF_CreateInstance(LPCLASSFACTORY iface,
1307 LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj)
1309 IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
1311 FIXME("%p %p %s %p\n", This, pOuter, debugstr_guid(riid), ppobj);
1315 static HRESULT WINAPI MsiCF_LockServer(LPCLASSFACTORY iface, BOOL dolock)
1317 IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
1319 FIXME("%p %d\n", This, dolock);
1323 static const IClassFactoryVtbl MsiCF_Vtbl =
1325 MsiCF_QueryInterface,
1328 MsiCF_CreateInstance,
1332 static IClassFactoryImpl Msi_CF = { &MsiCF_Vtbl };
1334 /******************************************************************
1335 * DllGetClassObject [MSI.@]
1337 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
1339 TRACE("%s %s %p\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
1341 if( IsEqualCLSID (rclsid, &CLSID_IMsiServer) ||
1342 IsEqualCLSID (rclsid, &CLSID_IMsiServerMessage) ||
1343 IsEqualCLSID (rclsid, &CLSID_IMsiServerX1) ||
1344 IsEqualCLSID (rclsid, &CLSID_IMsiServerX2) ||
1345 IsEqualCLSID (rclsid, &CLSID_IMsiServerX3) )
1347 *ppv = (LPVOID) &Msi_CF;
1350 return CLASS_E_CLASSNOTAVAILABLE;
1353 /******************************************************************
1354 * DllGetVersion [MSI.@]
1356 HRESULT WINAPI DllGetVersion(DLLVERSIONINFO *pdvi)
1360 if (pdvi->cbSize != sizeof(DLLVERSIONINFO))
1361 return E_INVALIDARG;
1363 pdvi->dwMajorVersion = MSI_MAJORVERSION;
1364 pdvi->dwMinorVersion = MSI_MINORVERSION;
1365 pdvi->dwBuildNumber = MSI_BUILDNUMBER;
1366 pdvi->dwPlatformID = 1;
1371 /******************************************************************
1372 * DllCanUnloadNow [MSI.@]
1374 HRESULT WINAPI DllCanUnloadNow(void)
1379 /***********************************************************************
1380 * MsiGetFeatureUsageW [MSI.@]
1382 UINT WINAPI MsiGetFeatureUsageW( LPCWSTR szProduct, LPCWSTR szFeature,
1383 DWORD* pdwUseCount, WORD* pwDateUsed )
1385 FIXME("%s %s %p %p\n",debugstr_w(szProduct), debugstr_w(szFeature),
1386 pdwUseCount, pwDateUsed);
1387 return ERROR_CALL_NOT_IMPLEMENTED;
1390 /***********************************************************************
1391 * MsiGetFeatureUsageA [MSI.@]
1393 UINT WINAPI MsiGetFeatureUsageA( LPCSTR szProduct, LPCSTR szFeature,
1394 DWORD* pdwUseCount, WORD* pwDateUsed )
1396 LPWSTR prod = NULL, feat = NULL;
1397 UINT ret = ERROR_OUTOFMEMORY;
1399 TRACE("%s %s %p %p\n", debugstr_a(szProduct), debugstr_a(szFeature),
1400 pdwUseCount, pwDateUsed);
1402 prod = strdupAtoW( szProduct );
1403 if (szProduct && !prod)
1406 feat = strdupAtoW( szFeature );
1407 if (szFeature && !feat)
1410 ret = MsiGetFeatureUsageW( prod, feat, pdwUseCount, pwDateUsed );
1419 /***********************************************************************
1420 * MsiUseFeatureExW [MSI.@]
1422 INSTALLSTATE WINAPI MsiUseFeatureExW( LPCWSTR szProduct, LPCWSTR szFeature,
1423 DWORD dwInstallMode, DWORD dwReserved )
1425 FIXME("%s %s %li %li\n", debugstr_w(szProduct), debugstr_w(szFeature),
1426 dwInstallMode, dwReserved);
1429 * Polls all the components of the feature to find install state and then
1431 * Software\\Microsoft\\Windows\\CurrentVersion\\
1432 * Installer\\Products\\<squishguid>\\<feature>
1433 * "Usage"=dword:........
1436 return INSTALLSTATE_LOCAL;
1439 /***********************************************************************
1440 * MsiUseFeatureExA [MSI.@]
1442 INSTALLSTATE WINAPI MsiUseFeatureExA( LPCSTR szProduct, LPCSTR szFeature,
1443 DWORD dwInstallMode, DWORD dwReserved )
1445 INSTALLSTATE ret = INSTALLSTATE_UNKNOWN;
1446 LPWSTR prod = NULL, feat = NULL;
1448 TRACE("%s %s %li %li\n", debugstr_a(szProduct), debugstr_a(szFeature),
1449 dwInstallMode, dwReserved);
1451 prod = strdupAtoW( szProduct );
1452 if (szProduct && !prod)
1455 feat = strdupAtoW( szFeature );
1456 if (szFeature && !feat)
1459 ret = MsiUseFeatureExW( prod, feat, dwInstallMode, dwReserved );
1468 INSTALLSTATE WINAPI MsiUseFeatureW( LPCWSTR szProduct, LPCWSTR szFeature )
1470 FIXME("%s %s\n", debugstr_w(szProduct), debugstr_w(szFeature));
1472 return INSTALLSTATE_LOCAL;
1475 INSTALLSTATE WINAPI MsiUseFeatureA( LPCSTR szProduct, LPCSTR szFeature )
1477 INSTALLSTATE ret = INSTALLSTATE_UNKNOWN;
1478 LPWSTR prod = NULL, feat = NULL;
1480 TRACE("%s %s\n", debugstr_a(szProduct), debugstr_a(szFeature) );
1482 prod = strdupAtoW( szProduct );
1483 if (szProduct && !prod)
1486 feat = strdupAtoW( szFeature );
1487 if (szFeature && !feat)
1490 ret = MsiUseFeatureW( prod, feat );
1499 UINT WINAPI MsiProvideQualifiedComponentExW(LPCWSTR szComponent,
1500 LPCWSTR szQualifier, DWORD dwInstallMode, LPWSTR szProduct,
1501 DWORD Unused1, DWORD Unused2, LPWSTR lpPathBuf,
1508 LPWSTR product = NULL;
1509 LPWSTR component = NULL;
1513 TRACE("%s %s %li %s %li %li %p %p\n", debugstr_w(szComponent),
1514 debugstr_w(szQualifier), dwInstallMode, debugstr_w(szProduct),
1515 Unused1, Unused2, lpPathBuf, pcchPathBuf);
1517 rc = MSIREG_OpenUserComponentsKey(szComponent, &hkey, FALSE);
1518 if (rc != ERROR_SUCCESS)
1519 return ERROR_INDEX_ABSENT;
1522 rc = RegQueryValueExW( hkey, szQualifier, NULL, NULL, NULL, &sz);
1526 return ERROR_INDEX_ABSENT;
1529 info = msi_alloc(sz);
1530 rc = RegQueryValueExW( hkey, szQualifier, NULL, NULL, (LPBYTE)info, &sz);
1531 if (rc != ERROR_SUCCESS)
1535 return ERROR_INDEX_ABSENT;
1538 /* find the component */
1539 ptr = strchrW(&info[20],'>');
1546 return ERROR_INDEX_ABSENT;
1551 decode_base85_guid(info,&clsid);
1552 StringFromCLSID(&clsid, &product);
1554 decode_base85_guid(ptr,&clsid);
1555 StringFromCLSID(&clsid, &component);
1558 rc = MsiGetComponentPathW(product, component, lpPathBuf, pcchPathBuf);
1560 rc = MsiGetComponentPathW(szProduct, component, lpPathBuf, pcchPathBuf);
1565 msi_free(component);
1567 if (rc == INSTALLSTATE_LOCAL)
1568 return ERROR_SUCCESS;
1570 return ERROR_FILE_NOT_FOUND;
1573 /***********************************************************************
1574 * MsiProvideQualifiedComponentW [MSI.@]
1576 UINT WINAPI MsiProvideQualifiedComponentW( LPCWSTR szComponent,
1577 LPCWSTR szQualifier, DWORD dwInstallMode, LPWSTR lpPathBuf,
1580 return MsiProvideQualifiedComponentExW(szComponent, szQualifier,
1581 dwInstallMode, NULL, 0, 0, lpPathBuf, pcchPathBuf);
1584 /***********************************************************************
1585 * MsiProvideQualifiedComponentA [MSI.@]
1587 UINT WINAPI MsiProvideQualifiedComponentA( LPCSTR szComponent,
1588 LPCSTR szQualifier, DWORD dwInstallMode, LPSTR lpPathBuf,
1591 LPWSTR szwComponent, szwQualifier, lpwPathBuf;
1595 TRACE("%s %s %li %p %p\n",szComponent, szQualifier,
1596 dwInstallMode, lpPathBuf, pcchPathBuf);
1598 szwComponent= strdupAtoW( szComponent);
1599 szwQualifier= strdupAtoW( szQualifier);
1601 lpwPathBuf = msi_alloc(*pcchPathBuf * sizeof(WCHAR));
1603 pcchwPathBuf = *pcchPathBuf;
1605 rc = MsiProvideQualifiedComponentW(szwComponent, szwQualifier,
1606 dwInstallMode, lpwPathBuf, &pcchwPathBuf);
1608 msi_free(szwComponent);
1609 msi_free(szwQualifier);
1610 *pcchPathBuf = WideCharToMultiByte(CP_ACP, 0, lpwPathBuf, pcchwPathBuf,
1611 lpPathBuf, *pcchPathBuf, NULL, NULL);
1613 msi_free(lpwPathBuf);
1617 USERINFOSTATE WINAPI MsiGetUserInfoW(LPCWSTR szProduct, LPWSTR lpUserNameBuf,
1618 DWORD* pcchUserNameBuf, LPWSTR lpOrgNameBuf,
1619 DWORD* pcchOrgNameBuf, LPWSTR lpSerialBuf, DWORD* pcchSerialBuf)
1623 UINT rc = ERROR_SUCCESS,rc2 = ERROR_SUCCESS;
1625 TRACE("%s %p %p %p %p %p %p\n",debugstr_w(szProduct), lpUserNameBuf,
1626 pcchUserNameBuf, lpOrgNameBuf, pcchOrgNameBuf, lpSerialBuf,
1629 rc = MSIREG_OpenUninstallKey(szProduct, &hkey, FALSE);
1630 if (rc != ERROR_SUCCESS)
1631 return USERINFOSTATE_UNKNOWN;
1635 sz = *lpUserNameBuf * sizeof(WCHAR);
1636 rc = RegQueryValueExW( hkey, INSTALLPROPERTY_REGOWNERW, NULL,
1637 NULL, (LPBYTE)lpUserNameBuf,
1640 if (!lpUserNameBuf && pcchUserNameBuf)
1643 rc = RegQueryValueExW( hkey, INSTALLPROPERTY_REGOWNERW, NULL,
1647 if (pcchUserNameBuf)
1648 *pcchUserNameBuf = sz / sizeof(WCHAR);
1652 sz = *pcchOrgNameBuf * sizeof(WCHAR);
1653 rc2 = RegQueryValueExW( hkey, INSTALLPROPERTY_REGCOMPANYW, NULL,
1654 NULL, (LPBYTE)lpOrgNameBuf, &sz);
1656 if (!lpOrgNameBuf && pcchOrgNameBuf)
1659 rc2 = RegQueryValueExW( hkey, INSTALLPROPERTY_REGCOMPANYW, NULL,
1664 *pcchOrgNameBuf = sz / sizeof(WCHAR);
1666 if (rc != ERROR_SUCCESS && rc != ERROR_MORE_DATA &&
1667 rc2 != ERROR_SUCCESS && rc2 != ERROR_MORE_DATA)
1670 return USERINFOSTATE_ABSENT;
1675 sz = *pcchSerialBuf * sizeof(WCHAR);
1676 RegQueryValueExW( hkey, INSTALLPROPERTY_PRODUCTIDW, NULL, NULL,
1677 (LPBYTE)lpSerialBuf, &sz);
1679 if (!lpSerialBuf && pcchSerialBuf)
1682 rc = RegQueryValueExW( hkey, INSTALLPROPERTY_PRODUCTIDW, NULL,
1686 *pcchSerialBuf = sz / sizeof(WCHAR);
1689 return USERINFOSTATE_PRESENT;
1692 USERINFOSTATE WINAPI MsiGetUserInfoA(LPCSTR szProduct, LPSTR lpUserNameBuf,
1693 DWORD* pcchUserNameBuf, LPSTR lpOrgNameBuf,
1694 DWORD* pcchOrgNameBuf, LPSTR lpSerialBuf, DWORD* pcchSerialBuf)
1696 FIXME("%s %p %p %p %p %p %p\n",debugstr_a(szProduct), lpUserNameBuf,
1697 pcchUserNameBuf, lpOrgNameBuf, pcchOrgNameBuf, lpSerialBuf,
1700 return USERINFOSTATE_UNKNOWN;
1703 UINT WINAPI MsiCollectUserInfoW(LPCWSTR szProduct)
1707 MSIPACKAGE *package;
1708 static const WCHAR szFirstRun[] = {'F','i','r','s','t','R','u','n',0};
1710 TRACE("(%s)\n",debugstr_w(szProduct));
1712 rc = MsiOpenProductW(szProduct,&handle);
1713 if (rc != ERROR_SUCCESS)
1714 return ERROR_INVALID_PARAMETER;
1716 package = msihandle2msiinfo(handle, MSIHANDLETYPE_PACKAGE);
1717 rc = ACTION_PerformUIAction(package, szFirstRun);
1718 msiobj_release( &package->hdr );
1720 MsiCloseHandle(handle);
1725 UINT WINAPI MsiCollectUserInfoA(LPCSTR szProduct)
1729 MSIPACKAGE *package;
1730 static const WCHAR szFirstRun[] = {'F','i','r','s','t','R','u','n',0};
1732 TRACE("(%s)\n",debugstr_a(szProduct));
1734 rc = MsiOpenProductA(szProduct,&handle);
1735 if (rc != ERROR_SUCCESS)
1736 return ERROR_INVALID_PARAMETER;
1738 package = msihandle2msiinfo(handle, MSIHANDLETYPE_PACKAGE);
1739 rc = ACTION_PerformUIAction(package, szFirstRun);
1740 msiobj_release( &package->hdr );
1742 MsiCloseHandle(handle);
1747 /***********************************************************************
1748 * MsiConfigureFeatureA [MSI.@]
1750 UINT WINAPI MsiConfigureFeatureA(LPCSTR szProduct, LPCSTR szFeature, INSTALLSTATE eInstallState)
1752 FIXME("%s %s %i\n", debugstr_a(szProduct), debugstr_a(szFeature), eInstallState);
1753 return ERROR_SUCCESS;
1756 /***********************************************************************
1757 * MsiConfigureFeatureW [MSI.@]
1759 UINT WINAPI MsiConfigureFeatureW(LPCWSTR szProduct, LPCWSTR szFeature, INSTALLSTATE eInstallState)
1761 FIXME("%s %s %i\n", debugstr_w(szProduct), debugstr_w(szFeature), eInstallState);
1762 return ERROR_SUCCESS;
1765 UINT WINAPI MsiCreateAndVerifyInstallerDirectory(DWORD dwReserved)
1767 WCHAR path[MAX_PATH];
1770 FIXME("Don't know how to handle argument %ld\n", dwReserved);
1771 return ERROR_CALL_NOT_IMPLEMENTED;
1774 if(!GetWindowsDirectoryW(path, MAX_PATH)) {
1775 FIXME("GetWindowsDirectory failed unexpected! Error %ld\n",
1777 return ERROR_CALL_NOT_IMPLEMENTED;
1780 strcatW(path, installerW);
1782 CreateDirectoryW(path, NULL);
1787 /***********************************************************************
1788 * MsiGetShortcutTargetA [MSI.@]
1790 UINT WINAPI MsiGetShortcutTargetA( LPCSTR szShortcutTarget,
1791 LPSTR szProductCode, LPSTR szFeatureId,
1792 LPSTR szComponentCode )
1795 const int len = MAX_FEATURE_CHARS+1;
1796 WCHAR product[MAX_FEATURE_CHARS+1], feature[MAX_FEATURE_CHARS+1], component[MAX_FEATURE_CHARS+1];
1799 target = strdupAtoW( szShortcutTarget );
1800 if (szShortcutTarget && !target )
1801 return ERROR_OUTOFMEMORY;
1805 r = MsiGetShortcutTargetW( target, product, feature, component );
1807 if (r == ERROR_SUCCESS)
1809 WideCharToMultiByte( CP_ACP, 0, product, -1, szProductCode, len, NULL, NULL );
1810 WideCharToMultiByte( CP_ACP, 0, feature, -1, szFeatureId, len, NULL, NULL );
1811 WideCharToMultiByte( CP_ACP, 0, component, -1, szComponentCode, len, NULL, NULL );
1816 /***********************************************************************
1817 * MsiGetShortcutTargetW [MSI.@]
1819 UINT WINAPI MsiGetShortcutTargetW( LPCWSTR szShortcutTarget,
1820 LPWSTR szProductCode, LPWSTR szFeatureId,
1821 LPWSTR szComponentCode )
1823 IShellLinkDataList *dl = NULL;
1824 IPersistFile *pf = NULL;
1825 LPEXP_DARWIN_LINK darwin = NULL;
1828 TRACE("%s %p %p %p\n", debugstr_w(szShortcutTarget),
1829 szProductCode, szFeatureId, szComponentCode );
1831 r = CoInitialize(NULL);
1833 return ERROR_FUNCTION_FAILED;
1835 r = CoCreateInstance( &CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
1836 &IID_IPersistFile, (LPVOID*) &pf );
1837 if( SUCCEEDED( r ) )
1839 r = IPersistFile_Load( pf, szShortcutTarget,
1840 STGM_READ | STGM_SHARE_DENY_WRITE );
1841 if( SUCCEEDED( r ) )
1843 r = IPersistFile_QueryInterface( pf, &IID_IShellLinkDataList,
1845 if( SUCCEEDED( r ) )
1847 IShellLinkDataList_CopyDataBlock( dl, EXP_DARWIN_ID_SIG,
1849 IShellLinkDataList_Release( dl );
1852 IPersistFile_Release( pf );
1857 TRACE("darwin = %p\n", darwin);
1864 ret = MsiDecomposeDescriptorW( darwin->szwDarwinID,
1865 szProductCode, szFeatureId, szComponentCode, &sz );
1866 LocalFree( darwin );
1870 return ERROR_FUNCTION_FAILED;
1873 UINT WINAPI MsiReinstallFeatureW( LPCWSTR szProduct, LPCWSTR szFeature,
1874 DWORD dwReinstallMode )
1876 MSIPACKAGE* package = NULL;
1879 WCHAR sourcepath[MAX_PATH];
1880 WCHAR filename[MAX_PATH];
1881 static const WCHAR szInstalled[] = {
1882 ' ','L','O','G','V','E','R','B','O','S','E','=','1',' ','I','n','s','t','a','l','l','e','d','=','1',0};
1883 static const WCHAR fmt[] = {'R','E','I','N','S','T','A','L','L','=','%','s',0};
1884 static const WCHAR REINSTALLMODE[] = {'R','E','I','N','S','T','A','L','L','M','O','D','E',0};
1885 WCHAR reinstallmode[11];
1889 FIXME("%s %s %li\n", debugstr_w(szProduct), debugstr_w(szFeature),
1892 memset(reinstallmode,0,sizeof(reinstallmode));
1893 ptr = reinstallmode;
1895 if (dwReinstallMode & REINSTALLMODE_FILEMISSING)
1896 { *ptr = 'p'; ptr++; }
1897 if (dwReinstallMode & REINSTALLMODE_FILEOLDERVERSION)
1898 { *ptr = 'o'; ptr++; }
1899 if (dwReinstallMode & REINSTALLMODE_FILEEQUALVERSION)
1900 { *ptr = 'w'; ptr++; }
1901 if (dwReinstallMode & REINSTALLMODE_FILEEXACT)
1902 { *ptr = 'd'; ptr++; }
1903 if (dwReinstallMode & REINSTALLMODE_FILEVERIFY)
1904 { *ptr = 'c'; ptr++; }
1905 if (dwReinstallMode & REINSTALLMODE_FILEREPLACE)
1906 { *ptr = 'a'; ptr++; }
1907 if (dwReinstallMode & REINSTALLMODE_USERDATA)
1908 { *ptr = 'u'; ptr++; }
1909 if (dwReinstallMode & REINSTALLMODE_MACHINEDATA)
1910 { *ptr = 'm'; ptr++; }
1911 if (dwReinstallMode & REINSTALLMODE_SHORTCUT)
1912 { *ptr = 's'; ptr++; }
1913 if (dwReinstallMode & REINSTALLMODE_PACKAGE)
1914 { *ptr = 'v'; ptr++; }
1916 sz = sizeof(sourcepath);
1917 MsiSourceListGetInfoW(szProduct, NULL, MSIINSTALLCONTEXT_USERMANAGED,
1918 MSICODE_PRODUCT, INSTALLPROPERTY_LASTUSEDSOURCEW, sourcepath,
1921 sz = sizeof(filename);
1922 MsiSourceListGetInfoW(szProduct, NULL, MSIINSTALLCONTEXT_USERMANAGED,
1923 MSICODE_PRODUCT, INSTALLPROPERTY_PACKAGENAMEW, filename, &sz);
1925 strcatW(sourcepath,filename);
1927 if (dwReinstallMode & REINSTALLMODE_PACKAGE)
1928 r = MSI_OpenPackageW( sourcepath, &package );
1930 r = MSI_OpenProductW( szProduct, &package );
1932 if (r != ERROR_SUCCESS)
1935 MSI_SetPropertyW(package,REINSTALLMODE,reinstallmode);
1937 sz = lstrlenW(szInstalled);
1938 sz += lstrlenW(fmt);
1939 sz += lstrlenW(szFeature);
1941 commandline = msi_alloc(sz * sizeof(WCHAR));
1943 sprintfW(commandline,fmt,szFeature);
1944 lstrcatW(commandline,szInstalled);
1946 r = MSI_InstallPackage( package, sourcepath, commandline );
1948 msiobj_release( &package->hdr );
1950 msi_free(commandline);
1955 UINT WINAPI MsiReinstallFeatureA( LPCSTR szProduct, LPCSTR szFeature,
1956 DWORD dwReinstallMode )
1962 TRACE("%s %s %li\n", debugstr_a(szProduct), debugstr_a(szFeature),
1965 wszProduct = strdupAtoW(szProduct);
1966 wszFeature = strdupAtoW(szFeature);
1968 rc = MsiReinstallFeatureW(wszProduct, wszFeature, dwReinstallMode);
1970 msi_free(wszProduct);
1971 msi_free(wszFeature);
1975 /***********************************************************************
1976 * MsiEnumPatchesA [MSI.@]
1978 UINT WINAPI MsiEnumPatchesA( LPCSTR szProduct, DWORD iPatchIndex,
1979 LPSTR lpPatchBuf, LPSTR lpTransformsBuf, DWORD* pcchTransformsBuf)
1981 FIXME("%s %ld %p %p %p\n", debugstr_a(szProduct),
1982 iPatchIndex, lpPatchBuf, lpTransformsBuf, pcchTransformsBuf);
1983 return ERROR_NO_MORE_ITEMS;
1986 /***********************************************************************
1987 * MsiEnumPatchesW [MSI.@]
1989 UINT WINAPI MsiEnumPatchesW( LPCWSTR szProduct, DWORD iPatchIndex,
1990 LPWSTR lpPatchBuf, LPWSTR lpTransformsBuf, DWORD* pcchTransformsBuf)
1992 FIXME("%s %ld %p %p %p\n", debugstr_w(szProduct),
1993 iPatchIndex, lpPatchBuf, lpTransformsBuf, pcchTransformsBuf);
1994 return ERROR_NO_MORE_ITEMS;