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"
38 #include "wine/unicode.h"
41 WINE_DEFAULT_DEBUG_CHANNEL(msi);
44 * The MSVC headers define the MSIDBOPEN_* macros cast to LPCTSTR,
45 * which is a problem because LPCTSTR isn't defined when compiling wine.
46 * To work around this problem, we need to define LPCTSTR as LPCWSTR here,
47 * and make sure to only use it in W functions.
49 #define LPCTSTR LPCWSTR
52 INSTALLUILEVEL gUILevel = INSTALLUILEVEL_BASIC;
54 INSTALLUI_HANDLERA gUIHandlerA = NULL;
55 INSTALLUI_HANDLERW gUIHandlerW = NULL;
57 LPVOID gUIContext = NULL;
58 WCHAR gszLogFile[MAX_PATH];
59 HINSTANCE msi_hInstance;
61 static const WCHAR installerW[] = {'\\','I','n','s','t','a','l','l','e','r',0};
63 UINT WINAPI MsiOpenProductA(LPCSTR szProduct, MSIHANDLE *phProduct)
66 LPWSTR szwProd = NULL;
68 TRACE("%s %p\n",debugstr_a(szProduct), phProduct);
72 szwProd = strdupAtoW( szProduct );
74 return ERROR_OUTOFMEMORY;
77 r = MsiOpenProductW( szwProd, phProduct );
79 HeapFree( GetProcessHeap(), 0, szwProd );
84 UINT WINAPI MsiOpenProductW(LPCWSTR szProduct, MSIHANDLE *phProduct)
86 static const WCHAR szLocalPackage[] = {
87 'L','o','c','a','l','P','a','c','k','a','g','e', 0
91 HKEY hKeyProduct = NULL;
94 TRACE("%s %p\n",debugstr_w(szProduct), phProduct);
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, szLocalPackage,
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 = HeapAlloc( GetProcessHeap(), 0, count );
118 r = RegQueryValueExW( hKeyProduct, szLocalPackage,
119 NULL, &type, (LPBYTE) path, &count );
120 if( r != ERROR_SUCCESS )
122 r = ERROR_UNKNOWN_PRODUCT;
126 r = MsiOpenPackageW( path, phProduct );
129 HeapFree( GetProcessHeap(), 0, path );
131 RegCloseKey( hKeyProduct );
136 UINT WINAPI MsiAdvertiseProductA(LPCSTR szPackagePath, LPCSTR szScriptfilePath,
137 LPCSTR szTransforms, LANGID lgidLanguage)
139 FIXME("%s %s %s %08x\n",debugstr_a(szPackagePath),
140 debugstr_a(szScriptfilePath), debugstr_a(szTransforms), lgidLanguage);
141 return ERROR_CALL_NOT_IMPLEMENTED;
144 UINT WINAPI MsiAdvertiseProductW(LPCWSTR szPackagePath, LPCWSTR szScriptfilePath,
145 LPCWSTR szTransforms, LANGID lgidLanguage)
147 FIXME("%s %s %s %08x\n",debugstr_w(szPackagePath),
148 debugstr_w(szScriptfilePath), debugstr_w(szTransforms), lgidLanguage);
149 return ERROR_CALL_NOT_IMPLEMENTED;
152 UINT WINAPI MsiAdvertiseProductExA(LPCSTR szPackagePath, LPCSTR szScriptfilePath,
153 LPCSTR szTransforms, LANGID lgidLanguage, DWORD dwPlatform, DWORD dwOptions)
155 FIXME("%s %s %s %08x %08lx %08lx\n", debugstr_a(szPackagePath),
156 debugstr_a(szScriptfilePath), debugstr_a(szTransforms),
157 lgidLanguage, dwPlatform, dwOptions);
158 return ERROR_CALL_NOT_IMPLEMENTED;
161 UINT WINAPI MsiAdvertiseProductExW( LPCWSTR szPackagePath, LPCWSTR szScriptfilePath,
162 LPCWSTR szTransforms, LANGID lgidLanguage, DWORD dwPlatform, DWORD dwOptions)
164 FIXME("%s %s %s %08x %08lx %08lx\n", debugstr_w(szPackagePath),
165 debugstr_w(szScriptfilePath), debugstr_w(szTransforms),
166 lgidLanguage, dwPlatform, dwOptions);
167 return ERROR_CALL_NOT_IMPLEMENTED;
170 UINT WINAPI MsiInstallProductA(LPCSTR szPackagePath, LPCSTR szCommandLine)
172 LPWSTR szwPath = NULL, szwCommand = NULL;
173 UINT r = ERROR_OUTOFMEMORY;
175 TRACE("%s %s\n",debugstr_a(szPackagePath), debugstr_a(szCommandLine));
179 szwPath = strdupAtoW( szPackagePath );
186 szwCommand = strdupAtoW( szCommandLine );
191 r = MsiInstallProductW( szwPath, szwCommand );
194 HeapFree( GetProcessHeap(), 0, szwPath );
195 HeapFree( GetProcessHeap(), 0, szwCommand );
200 UINT WINAPI MsiInstallProductW(LPCWSTR szPackagePath, LPCWSTR szCommandLine)
202 MSIPACKAGE *package = NULL;
206 FIXME("%s %s\n",debugstr_w(szPackagePath), debugstr_w(szCommandLine));
208 r = MsiVerifyPackageW(szPackagePath);
209 if (r != ERROR_SUCCESS)
212 r = MSI_OpenPackageW(szPackagePath,&package);
213 if (r != ERROR_SUCCESS)
216 handle = alloc_msihandle( &package->hdr );
218 r = ACTION_DoTopLevelINSTALL(package, szPackagePath, szCommandLine);
220 MsiCloseHandle(handle);
221 msiobj_release( &package->hdr );
225 UINT WINAPI MsiReinstallProductA(LPCSTR szProduct, DWORD dwReinstallMode)
227 FIXME("%s %08lx\n", debugstr_a(szProduct), dwReinstallMode);
228 return ERROR_CALL_NOT_IMPLEMENTED;
231 UINT WINAPI MsiReinstallProductW(LPCWSTR szProduct, DWORD dwReinstallMode)
233 FIXME("%s %08lx\n", debugstr_w(szProduct), dwReinstallMode);
234 return ERROR_CALL_NOT_IMPLEMENTED;
237 UINT WINAPI MsiApplyPatchA(LPCSTR szPatchPackage, LPCSTR szInstallPackage,
238 INSTALLTYPE eInstallType, LPCSTR szCommandLine)
240 FIXME("%s %s %d %s\n", debugstr_a(szPatchPackage), debugstr_a(szInstallPackage),
241 eInstallType, debugstr_a(szCommandLine));
242 return ERROR_CALL_NOT_IMPLEMENTED;
245 UINT WINAPI MsiApplyPatchW(LPCWSTR szPatchPackage, LPCWSTR szInstallPackage,
246 INSTALLTYPE eInstallType, LPCWSTR szCommandLine)
248 FIXME("%s %s %d %s\n", debugstr_w(szPatchPackage), debugstr_w(szInstallPackage),
249 eInstallType, debugstr_w(szCommandLine));
250 return ERROR_CALL_NOT_IMPLEMENTED;
253 UINT WINAPI MsiConfigureProductExW(LPCWSTR szProduct, int iInstallLevel,
254 INSTALLSTATE eInstallState, LPCWSTR szCommandLine)
256 MSIHANDLE handle = -1;
261 static const WCHAR szSouceList[] = {
262 'S','o','u','r','c','e','L','i','s','t',0};
263 static const WCHAR szLUS[] = {
264 'L','a','s','t','U','s','e','d','S','o','u','r','c','e',0};
265 WCHAR sourcepath[0x200];
266 static const WCHAR szInstalled[] = {
267 ' ','I','n','s','t','a','l','l','e','d','=','1',0};
270 FIXME("%s %d %d %s\n",debugstr_w(szProduct), iInstallLevel, eInstallState,
271 debugstr_w(szCommandLine));
273 if (eInstallState != INSTALLSTATE_LOCAL &&
274 eInstallState != INSTALLSTATE_DEFAULT)
276 FIXME("Not implemented for anything other than local installs\n");
277 return ERROR_CALL_NOT_IMPLEMENTED;
280 rc = MSIREG_OpenUserProductsKey(szProduct,&hkey,FALSE);
281 if (rc != ERROR_SUCCESS)
284 rc = RegOpenKeyW(hkey,szSouceList,&hkey1);
285 if (rc != ERROR_SUCCESS)
288 sz = sizeof(sourcepath);
289 rc = RegQueryValueExW(hkey1, szLUS, NULL, NULL,(LPBYTE)sourcepath, &sz);
290 if (rc != ERROR_SUCCESS)
295 * ok 1, we need to find the msi file for this product.
296 * 2, find the source dir for the files
297 * 3, do the configure/install.
298 * 4, cleanupany runonce entry.
301 rc = MsiOpenProductW(szProduct,&handle);
302 if (rc != ERROR_SUCCESS)
305 package = msihandle2msiinfo(handle, MSIHANDLETYPE_PACKAGE);
308 rc = ERROR_INVALID_HANDLE;
312 sz = lstrlenW(szInstalled);
315 sz += lstrlenW(szCommandLine);
317 commandline = HeapAlloc(GetProcessHeap(),0,sz * sizeof(WCHAR));
320 lstrcpyW(commandline,szCommandLine);
324 if (MsiQueryProductStateW(szProduct) != INSTALLSTATE_UNKNOWN)
325 lstrcatW(commandline,szInstalled);
327 rc = ACTION_DoTopLevelINSTALL(package, sourcepath, commandline);
329 msiobj_release( &package->hdr );
331 HeapFree(GetProcessHeap(),0,commandline);
335 MsiCloseHandle(handle);
340 UINT WINAPI MsiConfigureProductExA(LPCSTR szProduct, int iInstallLevel,
341 INSTALLSTATE eInstallState, LPCSTR szCommandLine)
343 LPWSTR szwProduct = NULL;
344 LPWSTR szwCommandLine = NULL;
345 UINT r = ERROR_OUTOFMEMORY;
349 szwProduct = strdupAtoW( szProduct );
356 szwCommandLine = strdupAtoW( szCommandLine );
361 r = MsiConfigureProductExW( szwProduct, iInstallLevel, eInstallState,
364 HeapFree( GetProcessHeap(), 0, szwProduct );
365 HeapFree( GetProcessHeap(), 0, szwCommandLine);
370 UINT WINAPI MsiConfigureProductA(LPCSTR szProduct, int iInstallLevel,
371 INSTALLSTATE eInstallState)
373 LPWSTR szwProduct = NULL;
376 TRACE("%s %d %d\n",debugstr_a(szProduct), iInstallLevel, eInstallState);
380 szwProduct = strdupAtoW( szProduct );
382 return ERROR_OUTOFMEMORY;
385 r = MsiConfigureProductW( szwProduct, iInstallLevel, eInstallState );
386 HeapFree( GetProcessHeap(), 0, szwProduct );
391 UINT WINAPI MsiConfigureProductW(LPCWSTR szProduct, int iInstallLevel,
392 INSTALLSTATE eInstallState)
394 FIXME("%s %d %d\n", debugstr_w(szProduct), iInstallLevel, eInstallState);
396 return MsiConfigureProductExW(szProduct, iInstallLevel, eInstallState, NULL);
399 UINT WINAPI MsiGetProductCodeA(LPCSTR szComponent, LPSTR szBuffer)
401 LPWSTR szwComponent = NULL;
403 WCHAR szwBuffer[GUID_SIZE];
405 TRACE("%s %s\n",debugstr_a(szComponent), debugstr_a(szBuffer));
409 szwComponent = strdupAtoW( szComponent );
411 return ERROR_OUTOFMEMORY;
414 r = MsiGetProductCodeW( szwComponent, szwBuffer );
416 if( ERROR_SUCCESS == r )
417 WideCharToMultiByte(CP_ACP, 0, szwBuffer, -1, szBuffer, GUID_SIZE, NULL, NULL);
419 HeapFree( GetProcessHeap(), 0, szwComponent );
424 UINT WINAPI MsiGetProductCodeW(LPCWSTR szComponent, LPWSTR szBuffer)
428 WCHAR szSquished[GUID_SIZE];
429 DWORD sz = GUID_SIZE;
430 static const WCHAR szPermKey[] =
431 { '0','0','0','0','0','0','0','0','0','0','0','0',
432 '0','0','0','0','0','0','0', '0','0','0','0','0',
433 '0','0','0','0','0','0','0','0',0};
435 TRACE("%s %p\n",debugstr_w(szComponent), szBuffer);
437 if (NULL == szComponent)
438 return ERROR_INVALID_PARAMETER;
440 rc = MSIREG_OpenComponentsKey( szComponent, &hkey, FALSE);
441 if (rc != ERROR_SUCCESS)
442 return ERROR_UNKNOWN_COMPONENT;
444 rc = RegEnumValueW(hkey, 0, szSquished, &sz, NULL, NULL, NULL, NULL);
445 if (rc == ERROR_SUCCESS && strcmpW(szSquished,szPermKey)==0)
448 rc = RegEnumValueW(hkey, 1, szSquished, &sz, NULL, NULL, NULL, NULL);
453 if (rc != ERROR_SUCCESS)
454 return ERROR_INSTALL_FAILURE;
456 unsquash_guid(szSquished, szBuffer);
457 return ERROR_SUCCESS;
460 UINT WINAPI MsiGetProductInfoA(LPCSTR szProduct, LPCSTR szAttribute,
461 LPSTR szBuffer, DWORD *pcchValueBuf)
463 LPWSTR szwProduct = NULL, szwAttribute = NULL, szwBuffer = NULL;
464 UINT r = ERROR_OUTOFMEMORY;
465 DWORD pcchwValueBuf = 0;
467 TRACE("%s %s %p %p\n", debugstr_a(szProduct), debugstr_a(szAttribute),
468 szBuffer, pcchValueBuf);
472 szwProduct = strdupAtoW( szProduct );
479 szwAttribute = strdupAtoW( szAttribute );
486 szwBuffer = HeapAlloc( GetProcessHeap(), 0, (*pcchValueBuf) * sizeof(WCHAR) );
487 pcchwValueBuf = *pcchValueBuf;
492 r = MsiGetProductInfoW( szwProduct, szwAttribute, szwBuffer,
495 if( ERROR_SUCCESS == r )
496 *pcchValueBuf = WideCharToMultiByte(CP_ACP, 0, szwBuffer, pcchwValueBuf,
497 szBuffer, *pcchValueBuf, NULL, NULL);
500 HeapFree( GetProcessHeap(), 0, szwProduct );
501 HeapFree( GetProcessHeap(), 0, szwAttribute );
502 HeapFree( GetProcessHeap(), 0, szwBuffer );
507 UINT WINAPI MsiGetProductInfoW(LPCWSTR szProduct, LPCWSTR szAttribute,
508 LPWSTR szBuffer, DWORD *pcchValueBuf)
512 static const WCHAR szPackageCode[] =
513 {'P','a','c','k','a','g','e','C','o','d','e',0};
514 static const WCHAR szVersionString[] =
515 {'V','e','r','s','i','o','n','S','t','r','i','n','g',0};
516 static const WCHAR szProductVersion[] =
517 {'P','r','o','d','u','c','t','V','e','r','s','i','o','n',0};
518 static const WCHAR szAssignmentType[] =
519 {'A','s','s','i','g','n','m','e','n','t','T','y','p','e',0};
520 static const WCHAR szLanguage[] =
521 {'L','a','n','g','u','a','g','e',0};
522 static const WCHAR szProductLanguage[] =
523 {'P','r','o','d','u','c','t','L','a','n','g','u','a','g','e',0};
525 FIXME("%s %s %p %p\n",debugstr_w(szProduct), debugstr_w(szAttribute),
526 szBuffer, pcchValueBuf);
528 if (NULL != szBuffer && NULL == pcchValueBuf)
529 return ERROR_INVALID_PARAMETER;
530 if (NULL == szProduct || NULL == szAttribute)
531 return ERROR_INVALID_PARAMETER;
533 /* check for special properties */
534 if (strcmpW(szAttribute, szPackageCode)==0)
537 WCHAR squished[GUID_SIZE];
539 DWORD sz = sizeof(squished);
541 r = MSIREG_OpenUserProductsKey(szProduct, &hkey, FALSE);
542 if (r != ERROR_SUCCESS)
543 return ERROR_UNKNOWN_PRODUCT;
545 r = RegQueryValueExW(hkey, szPackageCode, NULL, NULL,
546 (LPBYTE)squished, &sz);
547 if (r != ERROR_SUCCESS)
550 return ERROR_UNKNOWN_PRODUCT;
553 unsquash_guid(squished, package);
554 *pcchValueBuf = strlenW(package);
555 if (strlenW(package) > *pcchValueBuf)
558 return ERROR_MORE_DATA;
561 strcpyW(szBuffer, package);
566 else if (strcmpW(szAttribute, szVersionString)==0)
568 r = MsiOpenProductW(szProduct, &hProduct);
569 if (ERROR_SUCCESS != r)
572 r = MsiGetPropertyW(hProduct, szProductVersion, szBuffer, pcchValueBuf);
573 MsiCloseHandle(hProduct);
575 else if (strcmpW(szAttribute, szAssignmentType)==0)
577 FIXME("0 (zero) if advertised, 1(one) if per machine.\n");
584 else if (strcmpW(szAttribute, szLanguage)==0)
586 r = MsiOpenProductW(szProduct, &hProduct);
587 if (ERROR_SUCCESS != r)
590 r = MsiGetPropertyW(hProduct, szProductLanguage, szBuffer, pcchValueBuf);
591 MsiCloseHandle(hProduct);
595 r = MsiOpenProductW(szProduct, &hProduct);
596 if (ERROR_SUCCESS != r)
599 r = MsiGetPropertyW(hProduct, szAttribute, szBuffer, pcchValueBuf);
600 MsiCloseHandle(hProduct);
606 UINT WINAPI MsiEnableLogA(DWORD dwLogMode, LPCSTR szLogFile, DWORD attributes)
608 LPWSTR szwLogFile = NULL;
611 TRACE("%08lx %s %08lx\n", dwLogMode, debugstr_a(szLogFile), attributes);
615 szwLogFile = strdupAtoW( szLogFile );
617 return ERROR_OUTOFMEMORY;
619 r = MsiEnableLogW( dwLogMode, szwLogFile, attributes );
620 HeapFree( GetProcessHeap(), 0, szwLogFile );
624 UINT WINAPI MsiEnableLogW(DWORD dwLogMode, LPCWSTR szLogFile, DWORD attributes)
626 HANDLE file = INVALID_HANDLE_VALUE;
628 TRACE("%08lx %s %08lx\n", dwLogMode, debugstr_w(szLogFile), attributes);
630 lstrcpyW(gszLogFile,szLogFile);
631 if (!(attributes & INSTALLLOGATTRIBUTES_APPEND))
632 DeleteFileW(szLogFile);
633 file = CreateFileW(szLogFile, GENERIC_WRITE, 0, NULL, OPEN_ALWAYS,
634 FILE_ATTRIBUTE_NORMAL, NULL);
635 if (file != INVALID_HANDLE_VALUE)
638 ERR("Unable to enable log %s\n",debugstr_w(szLogFile));
640 return ERROR_SUCCESS;
643 INSTALLSTATE WINAPI MsiQueryProductStateA(LPCSTR szProduct)
645 LPWSTR szwProduct = NULL;
650 szwProduct = strdupAtoW( szProduct );
652 return ERROR_OUTOFMEMORY;
654 r = MsiQueryProductStateW( szwProduct );
655 HeapFree( GetProcessHeap(), 0, szwProduct );
659 INSTALLSTATE WINAPI MsiQueryProductStateW(LPCWSTR szProduct)
662 INSTALLSTATE rrc = INSTALLSTATE_UNKNOWN;
664 static const WCHAR szWindowsInstaller[] = {
665 'W','i','n','d','o','w','s','I','n','s','t','a','l','l','e','r',0 };
668 TRACE("%s\n", debugstr_w(szProduct));
670 rc = MSIREG_OpenUserProductsKey(szProduct,&hkey,FALSE);
671 if (rc != ERROR_SUCCESS)
676 rc = MSIREG_OpenUninstallKey(szProduct,&hkey,FALSE);
677 if (rc != ERROR_SUCCESS)
681 rc = RegQueryValueExW(hkey,szWindowsInstaller,NULL,NULL,(LPVOID)&rrc, &sz);
682 if (rc != ERROR_SUCCESS)
689 rrc = INSTALLSTATE_DEFAULT;
692 FIXME("Unknown install state read from registry (%i)\n",rrc);
693 rrc = INSTALLSTATE_UNKNOWN;
701 INSTALLUILEVEL WINAPI MsiSetInternalUI(INSTALLUILEVEL dwUILevel, HWND *phWnd)
703 INSTALLUILEVEL old = gUILevel;
704 HWND oldwnd = gUIhwnd;
706 TRACE("%08x %p\n", dwUILevel, phWnd);
708 gUILevel = dwUILevel;
717 INSTALLUI_HANDLERA WINAPI MsiSetExternalUIA(INSTALLUI_HANDLERA puiHandler,
718 DWORD dwMessageFilter, LPVOID pvContext)
720 INSTALLUI_HANDLERA prev = gUIHandlerA;
722 TRACE("%p %lx %p\n",puiHandler, dwMessageFilter,pvContext);
723 gUIHandlerA = puiHandler;
724 gUIFilter = dwMessageFilter;
725 gUIContext = pvContext;
730 INSTALLUI_HANDLERW WINAPI MsiSetExternalUIW(INSTALLUI_HANDLERW puiHandler,
731 DWORD dwMessageFilter, LPVOID pvContext)
733 INSTALLUI_HANDLERW prev = gUIHandlerW;
735 TRACE("%p %lx %p\n",puiHandler,dwMessageFilter,pvContext);
736 gUIHandlerW = puiHandler;
737 gUIFilter = dwMessageFilter;
738 gUIContext = pvContext;
743 /******************************************************************
744 * MsiLoadStringW [MSI.@]
746 * Loads a string from MSI's string resources.
750 * handle [I] only -1 is handled currently
751 * id [I] id of the string to be loaded
752 * lpBuffer [O] buffer for the string to be written to
753 * nBufferMax [I] maximum size of the buffer in characters
754 * lang [I] the preferred language for the string
758 * If successful, this function returns the language id of the string loaded
759 * If the function fails, the function returns zero.
763 * The type of the first parameter is unknown. LoadString's prototype
764 * suggests that it might be a module handle. I have made it an MSI handle
765 * for starters, as -1 is an invalid MSI handle, but not an invalid module
766 * handle. Maybe strings can be stored in an MSI database somehow.
768 LANGID WINAPI MsiLoadStringW( MSIHANDLE handle, UINT id, LPWSTR lpBuffer,
769 int nBufferMax, LANGID lang )
776 TRACE("%ld %u %p %d %d\n", handle, id, lpBuffer, nBufferMax, lang);
779 FIXME("don't know how to deal with handle = %08lx\n", handle);
782 lang = GetUserDefaultLangID();
784 hres = FindResourceExW( msi_hInstance, (LPCWSTR) RT_STRING,
788 hResData = LoadResource( msi_hInstance, hres );
791 p = LockResource( hResData );
795 for (i = 0; i < (id&0xf); i++)
799 if( nBufferMax <= len )
802 memcpy( lpBuffer, p+1, len * sizeof(WCHAR));
805 TRACE("found -> %s\n", debugstr_w(lpBuffer));
810 LANGID WINAPI MsiLoadStringA( MSIHANDLE handle, UINT id, LPSTR lpBuffer,
811 int nBufferMax, LANGID lang )
817 bufW = HeapAlloc(GetProcessHeap(), 0, nBufferMax*sizeof(WCHAR));
818 r = MsiLoadStringW(handle, id, bufW, nBufferMax, lang);
821 len = WideCharToMultiByte(CP_ACP, 0, bufW, -1, NULL, 0, NULL, NULL );
822 if( len <= nBufferMax )
823 WideCharToMultiByte( CP_ACP, 0, bufW, -1,
824 lpBuffer, nBufferMax, NULL, NULL );
828 HeapFree(GetProcessHeap(), 0, bufW);
832 INSTALLSTATE WINAPI MsiLocateComponentA(LPCSTR szComponent, LPSTR lpPathBuf,
835 FIXME("%s %p %08lx\n", debugstr_a(szComponent), lpPathBuf, *pcchBuf);
836 return INSTALLSTATE_UNKNOWN;
839 INSTALLSTATE WINAPI MsiLocateComponentW(LPCWSTR szComponent, LPWSTR lpPathBuf,
842 FIXME("%s %p %08lx\n", debugstr_w(szComponent), lpPathBuf, *pcchBuf);
843 return INSTALLSTATE_UNKNOWN;
846 UINT WINAPI MsiMessageBoxA(HWND hWnd, LPCSTR lpText, LPCSTR lpCaption, UINT uType,
847 WORD wLanguageId, DWORD f)
849 FIXME("%p %s %s %u %08x %08lx\n",hWnd,debugstr_a(lpText),debugstr_a(lpCaption),
850 uType,wLanguageId,f);
851 return ERROR_CALL_NOT_IMPLEMENTED;
854 UINT WINAPI MsiMessageBoxW(HWND hWnd, LPCWSTR lpText, LPCWSTR lpCaption, UINT uType,
855 WORD wLanguageId, DWORD f)
857 FIXME("%p %s %s %u %08x %08lx\n",hWnd,debugstr_w(lpText),debugstr_w(lpCaption),
858 uType,wLanguageId,f);
859 return ERROR_CALL_NOT_IMPLEMENTED;
862 UINT WINAPI MsiProvideAssemblyA( LPCSTR szAssemblyName, LPCSTR szAppContext,
863 DWORD dwInstallMode, DWORD dwAssemblyInfo, LPSTR lpPathBuf,
866 FIXME("%s %s %08lx %08lx %p %p\n", debugstr_a(szAssemblyName),
867 debugstr_a(szAppContext), dwInstallMode, dwAssemblyInfo, lpPathBuf,
869 return ERROR_CALL_NOT_IMPLEMENTED;
872 UINT WINAPI MsiProvideAssemblyW( LPCWSTR szAssemblyName, LPCWSTR szAppContext,
873 DWORD dwInstallMode, DWORD dwAssemblyInfo, LPWSTR lpPathBuf,
876 FIXME("%s %s %08lx %08lx %p %p\n", debugstr_w(szAssemblyName),
877 debugstr_w(szAppContext), dwInstallMode, dwAssemblyInfo, lpPathBuf,
879 return ERROR_CALL_NOT_IMPLEMENTED;
882 UINT WINAPI MsiProvideComponentFromDescriptorA( LPCSTR szDescriptor,
883 LPSTR szPath, DWORD *pcchPath, DWORD *pcchArgs )
885 FIXME("%s %p %p %p\n", debugstr_a(szDescriptor), szPath, pcchPath, pcchArgs );
886 return ERROR_CALL_NOT_IMPLEMENTED;
889 UINT WINAPI MsiProvideComponentFromDescriptorW( LPCWSTR szDescriptor,
890 LPWSTR szPath, DWORD *pcchPath, DWORD *pcchArgs )
892 FIXME("%s %p %p %p\n", debugstr_w(szDescriptor), szPath, pcchPath, pcchArgs );
893 return ERROR_CALL_NOT_IMPLEMENTED;
896 HRESULT WINAPI MsiGetFileSignatureInformationA( LPCSTR szSignedObjectPath,
897 DWORD dwFlags, PCCERT_CONTEXT* ppcCertContext, BYTE* pbHashData,
900 FIXME("%s %08lx %p %p %p\n", debugstr_a(szSignedObjectPath), dwFlags,
901 ppcCertContext, pbHashData, pcbHashData);
902 return ERROR_CALL_NOT_IMPLEMENTED;
905 HRESULT WINAPI MsiGetFileSignatureInformationW( LPCWSTR szSignedObjectPath,
906 DWORD dwFlags, PCCERT_CONTEXT* ppcCertContext, BYTE* pbHashData,
909 FIXME("%s %08lx %p %p %p\n", debugstr_w(szSignedObjectPath), dwFlags,
910 ppcCertContext, pbHashData, pcbHashData);
911 return ERROR_CALL_NOT_IMPLEMENTED;
914 UINT WINAPI MsiGetProductPropertyA( MSIHANDLE hProduct, LPCSTR szProperty,
915 LPSTR szValue, DWORD *pccbValue )
917 FIXME("%ld %s %p %p\n", hProduct, debugstr_a(szProperty), szValue, pccbValue);
918 return ERROR_CALL_NOT_IMPLEMENTED;
921 UINT WINAPI MsiGetProductPropertyW( MSIHANDLE hProduct, LPCWSTR szProperty,
922 LPWSTR szValue, DWORD *pccbValue )
924 FIXME("%ld %s %p %p\n", hProduct, debugstr_w(szProperty), szValue, pccbValue);
925 return ERROR_CALL_NOT_IMPLEMENTED;
928 UINT WINAPI MsiVerifyPackageA( LPCSTR szPackage )
931 LPWSTR szPack = NULL;
933 TRACE("%s\n", debugstr_a(szPackage) );
937 szPack = strdupAtoW( szPackage );
939 return ERROR_OUTOFMEMORY;
942 r = MsiVerifyPackageW( szPack );
944 HeapFree( GetProcessHeap(), 0, szPack );
949 UINT WINAPI MsiVerifyPackageW( LPCWSTR szPackage )
954 TRACE("%s\n", debugstr_w(szPackage) );
956 r = MsiOpenDatabaseW( szPackage, MSIDBOPEN_READONLY, &handle );
957 MsiCloseHandle( handle );
962 INSTALLSTATE WINAPI MsiGetComponentPathA(LPCSTR szProduct, LPCSTR szComponent,
963 LPSTR lpPathBuf, DWORD* pcchBuf)
965 LPWSTR szwProduct = NULL, szwComponent = NULL, lpwPathBuf= NULL;
971 szwProduct = strdupAtoW( szProduct );
973 return ERROR_OUTOFMEMORY;
978 szwComponent = strdupAtoW( szComponent );
981 HeapFree( GetProcessHeap(), 0, szwProduct);
982 return ERROR_OUTOFMEMORY;
986 if( pcchBuf && *pcchBuf > 0 )
988 lpwPathBuf = HeapAlloc( GetProcessHeap(), 0, *pcchBuf * sizeof(WCHAR));
989 incoming_len = *pcchBuf;
997 rc = MsiGetComponentPathW(szwProduct, szwComponent, lpwPathBuf, pcchBuf);
999 HeapFree( GetProcessHeap(), 0, szwProduct);
1000 HeapFree( GetProcessHeap(), 0, szwComponent);
1003 if (rc != INSTALLSTATE_UNKNOWN)
1004 WideCharToMultiByte(CP_ACP, 0, lpwPathBuf, incoming_len,
1005 lpPathBuf, incoming_len, NULL, NULL);
1006 HeapFree( GetProcessHeap(), 0, lpwPathBuf);
1012 INSTALLSTATE WINAPI MsiGetComponentPathW(LPCWSTR szProduct, LPCWSTR szComponent,
1013 LPWSTR lpPathBuf, DWORD* pcchBuf)
1015 WCHAR squished_pc[GUID_SIZE];
1017 INSTALLSTATE rrc = INSTALLSTATE_UNKNOWN;
1022 TRACE("%s %s %p %p\n", debugstr_w(szProduct),
1023 debugstr_w(szComponent), lpPathBuf, pcchBuf);
1025 if( lpPathBuf && !pcchBuf )
1026 return INSTALLSTATE_INVALIDARG;
1028 squash_guid(szProduct,squished_pc);
1030 rc = MSIREG_OpenProductsKey( szProduct, &hkey, FALSE);
1031 if( rc != ERROR_SUCCESS )
1036 rc = MSIREG_OpenComponentsKey( szComponent, &hkey, FALSE);
1037 if( rc != ERROR_SUCCESS )
1042 rc = RegQueryValueExW( hkey, squished_pc, NULL, &type, NULL, &sz );
1043 if( rc != ERROR_SUCCESS )
1045 if( type != REG_SZ )
1048 sz += sizeof(WCHAR);
1049 path = HeapAlloc( GetProcessHeap(), 0, sz );
1053 rc = RegQueryValueExW( hkey, squished_pc, NULL, NULL, (LPVOID) path, &sz );
1054 if( rc != ERROR_SUCCESS )
1057 TRACE("found path of (%s:%s)(%s)\n", debugstr_w(szComponent),
1058 debugstr_w(szProduct), debugstr_w(path));
1062 FIXME("Registry entry.. check entry\n");
1063 rrc = INSTALLSTATE_LOCAL;
1067 /* PROBABLY a file */
1068 if ( GetFileAttributesW(path) != INVALID_FILE_ATTRIBUTES )
1069 rrc = INSTALLSTATE_LOCAL;
1071 rrc = INSTALLSTATE_ABSENT;
1076 sz = sz / sizeof(WCHAR);
1077 if( *pcchBuf >= sz )
1078 lstrcpyW( lpPathBuf, path );
1083 HeapFree(GetProcessHeap(), 0, path );
1088 /******************************************************************
1089 * MsiQueryFeatureStateA [MSI.@]
1091 INSTALLSTATE WINAPI MsiQueryFeatureStateA(LPCSTR szProduct, LPCSTR szFeature)
1094 LPWSTR szwProduct= NULL;
1095 LPWSTR szwFeature= NULL;
1099 szwProduct = strdupAtoW( szProduct );
1101 return ERROR_OUTOFMEMORY;
1106 szwFeature = strdupAtoW( szFeature );
1109 HeapFree( GetProcessHeap(), 0, szwProduct);
1110 return ERROR_OUTOFMEMORY;
1114 rc = MsiQueryFeatureStateW(szwProduct, szwFeature);
1116 HeapFree( GetProcessHeap(), 0, szwProduct);
1117 HeapFree( GetProcessHeap(), 0, szwFeature);
1122 /******************************************************************
1123 * MsiQueryFeatureStateW [MSI.@]
1125 * This does not verify that the Feature is functional. So i am only going to
1126 * check the existence of the key in the registry. This should tell me if it is
1129 INSTALLSTATE WINAPI MsiQueryFeatureStateW(LPCWSTR szProduct, LPCWSTR szFeature)
1135 TRACE("%s %s\n", debugstr_w(szProduct), debugstr_w(szFeature));
1137 rc = MSIREG_OpenFeaturesKey(szProduct, &hkey, FALSE);
1138 if (rc != ERROR_SUCCESS)
1139 return INSTALLSTATE_UNKNOWN;
1141 rc = RegQueryValueExW( hkey, szFeature, NULL, NULL, NULL, &sz);
1144 if (rc == ERROR_SUCCESS)
1145 return INSTALLSTATE_LOCAL;
1147 return INSTALLSTATE_ABSENT;
1150 /******************************************************************
1151 * MsiGetFileVersionA [MSI.@]
1153 UINT WINAPI MsiGetFileVersionA(LPCSTR szFilePath, LPSTR lpVersionBuf,
1154 DWORD* pcchVersionBuf, LPSTR lpLangBuf, DWORD* pcchLangBuf)
1156 LPWSTR szwFilePath = NULL, lpwVersionBuff = NULL, lpwLangBuff = NULL;
1157 UINT ret = ERROR_OUTOFMEMORY;
1161 szwFilePath = strdupAtoW( szFilePath );
1166 if( lpVersionBuf && pcchVersionBuf && *pcchVersionBuf )
1168 lpwVersionBuff = HeapAlloc(GetProcessHeap(), 0, *pcchVersionBuf*sizeof(WCHAR));
1169 if( !lpwVersionBuff )
1173 if( lpLangBuf && pcchLangBuf && *pcchLangBuf )
1175 lpwLangBuff = HeapAlloc(GetProcessHeap(), 0, *pcchVersionBuf*sizeof(WCHAR));
1180 ret = MsiGetFileVersionW(szwFilePath, lpwVersionBuff, pcchVersionBuf,
1181 lpwLangBuff, pcchLangBuf);
1183 if( lpwVersionBuff )
1184 WideCharToMultiByte(CP_ACP, 0, lpwVersionBuff, -1,
1185 lpVersionBuf, *pcchVersionBuf, NULL, NULL);
1187 WideCharToMultiByte(CP_ACP, 0, lpwLangBuff, -1,
1188 lpLangBuf, *pcchLangBuf, NULL, NULL);
1191 HeapFree(GetProcessHeap(), 0, szwFilePath);
1192 HeapFree(GetProcessHeap(), 0, lpwVersionBuff);
1193 HeapFree(GetProcessHeap(), 0, lpwLangBuff);
1198 /******************************************************************
1199 * MsiGetFileVersionW [MSI.@]
1201 UINT WINAPI MsiGetFileVersionW(LPCWSTR szFilePath, LPWSTR lpVersionBuf,
1202 DWORD* pcchVersionBuf, LPWSTR lpLangBuf, DWORD* pcchLangBuf)
1204 static const WCHAR szVersionResource[] = {'\\',0};
1205 static const WCHAR szVersionFormat[] = {
1206 '%','d','.','%','d','.','%','d','.','%','d',0};
1207 static const WCHAR szLangFormat[] = {'%','d',0};
1210 LPVOID lpVer = NULL;
1211 VS_FIXEDFILEINFO *ffi;
1215 TRACE("%s %p %ld %p %ld\n", debugstr_w(szFilePath),
1216 lpVersionBuf, pcchVersionBuf?*pcchVersionBuf:0,
1217 lpLangBuf, pcchLangBuf?*pcchLangBuf:0);
1219 dwVerLen = GetFileVersionInfoSizeW(szFilePath, NULL);
1221 return GetLastError();
1223 lpVer = HeapAlloc(GetProcessHeap(), 0, dwVerLen);
1226 ret = ERROR_OUTOFMEMORY;
1230 if( !GetFileVersionInfoW(szFilePath, 0, dwVerLen, lpVer) )
1232 ret = GetLastError();
1235 if( lpVersionBuf && pcchVersionBuf && *pcchVersionBuf )
1237 if( VerQueryValueW(lpVer, szVersionResource, (LPVOID*)&ffi, &puLen) &&
1240 wsprintfW(tmp, szVersionFormat,
1241 HIWORD(ffi->dwFileVersionMS), LOWORD(ffi->dwFileVersionMS),
1242 HIWORD(ffi->dwFileVersionLS), LOWORD(ffi->dwFileVersionLS));
1243 lstrcpynW(lpVersionBuf, tmp, *pcchVersionBuf);
1244 *pcchVersionBuf = lstrlenW(lpVersionBuf);
1249 *pcchVersionBuf = 0;
1253 if( lpLangBuf && pcchLangBuf && *pcchLangBuf )
1255 DWORD lang = GetUserDefaultLangID();
1257 FIXME("Retrieve language from file\n");
1258 wsprintfW(tmp, szLangFormat, lang);
1259 lstrcpynW(lpLangBuf, tmp, *pcchLangBuf);
1260 *pcchLangBuf = lstrlenW(lpLangBuf);
1264 HeapFree(GetProcessHeap(), 0, lpVer);
1269 /******************************************************************
1272 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
1276 case DLL_PROCESS_ATTACH:
1277 msi_hInstance = hinstDLL;
1278 DisableThreadLibraryCalls(hinstDLL);
1279 msi_dialog_register_class();
1281 case DLL_PROCESS_DETACH:
1282 msi_dialog_unregister_class();
1283 /* FIXME: Cleanup */
1289 typedef struct tagIClassFactoryImpl
1291 const IClassFactoryVtbl *lpVtbl;
1292 } IClassFactoryImpl;
1294 static HRESULT WINAPI MsiCF_QueryInterface(LPCLASSFACTORY iface,
1295 REFIID riid,LPVOID *ppobj)
1297 IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
1298 FIXME("%p %s %p\n",This,debugstr_guid(riid),ppobj);
1299 return E_NOINTERFACE;
1302 static ULONG WINAPI MsiCF_AddRef(LPCLASSFACTORY iface)
1307 static ULONG WINAPI MsiCF_Release(LPCLASSFACTORY iface)
1312 static HRESULT WINAPI MsiCF_CreateInstance(LPCLASSFACTORY iface,
1313 LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj)
1315 IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
1317 FIXME("%p %p %s %p\n", This, pOuter, debugstr_guid(riid), ppobj);
1321 static HRESULT WINAPI MsiCF_LockServer(LPCLASSFACTORY iface, BOOL dolock)
1323 IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
1325 FIXME("%p %d\n", This, dolock);
1329 static const IClassFactoryVtbl MsiCF_Vtbl =
1331 MsiCF_QueryInterface,
1334 MsiCF_CreateInstance,
1338 static IClassFactoryImpl Msi_CF = { &MsiCF_Vtbl };
1340 /******************************************************************
1341 * DllGetClassObject [MSI.@]
1343 HRESULT WINAPI MSI_DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
1345 TRACE("%s %s %p\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
1347 if( IsEqualCLSID (rclsid, &CLSID_IMsiServer) ||
1348 IsEqualCLSID (rclsid, &CLSID_IMsiServerMessage) ||
1349 IsEqualCLSID (rclsid, &CLSID_IMsiServerX1) ||
1350 IsEqualCLSID (rclsid, &CLSID_IMsiServerX2) ||
1351 IsEqualCLSID (rclsid, &CLSID_IMsiServerX3) )
1353 *ppv = (LPVOID) &Msi_CF;
1356 return CLASS_E_CLASSNOTAVAILABLE;
1359 /******************************************************************
1360 * DllGetVersion [MSI.@]
1362 HRESULT WINAPI MSI_DllGetVersion(DLLVERSIONINFO *pdvi)
1366 if (pdvi->cbSize != sizeof(DLLVERSIONINFO))
1367 return E_INVALIDARG;
1369 pdvi->dwMajorVersion = MSI_MAJORVERSION;
1370 pdvi->dwMinorVersion = MSI_MINORVERSION;
1371 pdvi->dwBuildNumber = MSI_BUILDNUMBER;
1372 pdvi->dwPlatformID = 1;
1377 /******************************************************************
1378 * DllCanUnloadNow [MSI.@]
1380 BOOL WINAPI MSI_DllCanUnloadNow(void)
1385 UINT WINAPI MsiGetFeatureUsageW(LPCWSTR szProduct, LPCWSTR szFeature,
1386 DWORD* pdwUseCount, WORD* pwDateUsed)
1388 FIXME("%s %s %p %p\n",debugstr_w(szProduct), debugstr_w(szFeature),
1389 pdwUseCount, pwDateUsed);
1390 return ERROR_CALL_NOT_IMPLEMENTED;
1393 UINT WINAPI MsiGetFeatureUsageA(LPCSTR szProduct, LPCSTR szFeature,
1394 DWORD* pdwUseCount, WORD* pwDateUsed)
1396 FIXME("%s %s %p %p\n", debugstr_a(szProduct), debugstr_a(szFeature),
1397 pdwUseCount, pwDateUsed);
1398 return ERROR_CALL_NOT_IMPLEMENTED;
1401 INSTALLSTATE WINAPI MsiUseFeatureExW(LPCWSTR szProduct, LPCWSTR szFeature,
1402 DWORD dwInstallMode, DWORD dwReserved)
1404 FIXME("%s %s %li %li\n", debugstr_w(szProduct), debugstr_w(szFeature),
1405 dwInstallMode, dwReserved);
1408 * Polls all the components of the feature to find install state and then
1410 * Software\\Microsoft\\Windows\\CurrentVersion\\
1411 * Installer\\Products\\<squishguid>\\<feature>
1412 * "Usage"=dword:........
1415 return INSTALLSTATE_LOCAL;
1418 /***********************************************************************
1419 * MsiUseFeatureExA [MSI.@]
1421 INSTALLSTATE WINAPI MsiUseFeatureExA(LPCSTR szProduct, LPCSTR szFeature,
1422 DWORD dwInstallMode, DWORD dwReserved)
1424 FIXME("%s %s %li %li\n", debugstr_a(szProduct), debugstr_a(szFeature),
1425 dwInstallMode, dwReserved);
1427 return INSTALLSTATE_LOCAL;
1430 INSTALLSTATE WINAPI MsiUseFeatureW(LPCWSTR szProduct, LPCWSTR szFeature)
1432 FIXME("%s %s\n", debugstr_w(szProduct), debugstr_w(szFeature));
1434 return INSTALLSTATE_LOCAL;
1437 INSTALLSTATE WINAPI MsiUseFeatureA(LPCSTR szProduct, LPCSTR szFeature)
1439 FIXME("%s %s\n", debugstr_a(szProduct), debugstr_a(szFeature));
1441 return INSTALLSTATE_LOCAL;
1444 UINT WINAPI MsiProvideQualifiedComponentExW(LPCWSTR szComponent,
1445 LPCWSTR szQualifier, DWORD dwInstallMode, LPWSTR szProduct,
1446 DWORD Unused1, DWORD Unused2, LPWSTR lpPathBuf,
1453 LPWSTR product = NULL;
1454 LPWSTR component = NULL;
1458 TRACE("%s %s %li %s %li %li %p %p\n", debugstr_w(szComponent),
1459 debugstr_w(szQualifier), dwInstallMode, debugstr_w(szProduct),
1460 Unused1, Unused2, lpPathBuf, pcchPathBuf);
1462 rc = MSIREG_OpenUserComponentsKey(szComponent, &hkey, FALSE);
1463 if (rc != ERROR_SUCCESS)
1464 return ERROR_INDEX_ABSENT;
1467 rc = RegQueryValueExW( hkey, szQualifier, NULL, NULL, NULL, &sz);
1471 return ERROR_INDEX_ABSENT;
1474 info = HeapAlloc(GetProcessHeap(),0,sz);
1475 rc = RegQueryValueExW( hkey, szQualifier, NULL, NULL, (LPBYTE)info, &sz);
1476 if (rc != ERROR_SUCCESS)
1479 HeapFree(GetProcessHeap(),0,info);
1480 return ERROR_INDEX_ABSENT;
1483 /* find the component */
1484 ptr = strchrW(&info[20],'>');
1490 HeapFree(GetProcessHeap(),0,info);
1491 return ERROR_INDEX_ABSENT;
1496 decode_base85_guid(info,&clsid);
1497 StringFromCLSID(&clsid, &product);
1499 decode_base85_guid(ptr,&clsid);
1500 StringFromCLSID(&clsid, &component);
1503 rc = MsiGetComponentPathW(product, component, lpPathBuf, pcchPathBuf);
1505 rc = MsiGetComponentPathW(szProduct, component, lpPathBuf, pcchPathBuf);
1508 HeapFree(GetProcessHeap(),0,info);
1509 HeapFree(GetProcessHeap(),0,product);
1510 HeapFree(GetProcessHeap(),0,component);
1512 if (rc == INSTALLSTATE_LOCAL)
1513 return ERROR_SUCCESS;
1515 return ERROR_FILE_NOT_FOUND;
1518 /***********************************************************************
1519 * MsiProvideQualifiedComponentW [MSI.@]
1521 UINT WINAPI MsiProvideQualifiedComponentW( LPCWSTR szComponent,
1522 LPCWSTR szQualifier, DWORD dwInstallMode, LPWSTR lpPathBuf,
1525 return MsiProvideQualifiedComponentExW(szComponent, szQualifier,
1526 dwInstallMode, NULL, 0, 0, lpPathBuf, pcchPathBuf);
1529 /***********************************************************************
1530 * MsiProvideQualifiedComponentA [MSI.@]
1532 UINT WINAPI MsiProvideQualifiedComponentA( LPCSTR szComponent,
1533 LPCSTR szQualifier, DWORD dwInstallMode, LPSTR lpPathBuf,
1536 LPWSTR szwComponent, szwQualifier, lpwPathBuf;
1540 TRACE("%s %s %li %p %p\n",szComponent, szQualifier,
1541 dwInstallMode, lpPathBuf, pcchPathBuf);
1543 szwComponent= strdupAtoW( szComponent);
1544 szwQualifier= strdupAtoW( szQualifier);
1546 lpwPathBuf = HeapAlloc(GetProcessHeap(),0,*pcchPathBuf * sizeof(WCHAR));
1548 pcchwPathBuf = *pcchPathBuf;
1550 rc = MsiProvideQualifiedComponentW(szwComponent, szwQualifier,
1551 dwInstallMode, lpwPathBuf, &pcchwPathBuf);
1553 HeapFree(GetProcessHeap(),0,szwComponent);
1554 HeapFree(GetProcessHeap(),0,szwQualifier);
1555 *pcchPathBuf = WideCharToMultiByte(CP_ACP, 0, lpwPathBuf, pcchwPathBuf,
1556 lpPathBuf, *pcchPathBuf, NULL, NULL);
1558 HeapFree(GetProcessHeap(),0,lpwPathBuf);
1562 USERINFOSTATE WINAPI MsiGetUserInfoW(LPCWSTR szProduct, LPWSTR lpUserNameBuf,
1563 DWORD* pcchUserNameBuf, LPWSTR lpOrgNameBuf,
1564 DWORD* pcchOrgNameBuf, LPWSTR lpSerialBuf, DWORD* pcchSerialBuf)
1568 UINT rc = ERROR_SUCCESS,rc2 = ERROR_SUCCESS;
1569 static const WCHAR szOwner[] = {'R','e','g','O','w','n','e','r',0};
1570 static const WCHAR szCompany[] = {'R','e','g','C','o','m','p','a','n','y',0};
1571 static const WCHAR szSerial[] = {'P','r','o','d','u','c','t','I','D',0};
1573 TRACE("%s %p %p %p %p %p %p\n",debugstr_w(szProduct), lpUserNameBuf,
1574 pcchUserNameBuf, lpOrgNameBuf, pcchOrgNameBuf, lpSerialBuf,
1577 rc = MSIREG_OpenUninstallKey(szProduct, &hkey, FALSE);
1578 if (rc != ERROR_SUCCESS)
1579 return USERINFOSTATE_UNKNOWN;
1583 sz = *lpUserNameBuf * sizeof(WCHAR);
1584 rc = RegQueryValueExW( hkey, szOwner, NULL, NULL, (LPBYTE)lpUserNameBuf,
1587 if (!lpUserNameBuf && pcchUserNameBuf)
1590 rc = RegQueryValueExW( hkey, szOwner, NULL, NULL, NULL, &sz);
1593 if (pcchUserNameBuf)
1594 *pcchUserNameBuf = sz / sizeof(WCHAR);
1598 sz = *pcchOrgNameBuf * sizeof(WCHAR);
1599 rc2 = RegQueryValueExW( hkey, szCompany, NULL, NULL,
1600 (LPBYTE)lpOrgNameBuf, &sz);
1602 if (!lpOrgNameBuf && pcchOrgNameBuf)
1605 rc2 = RegQueryValueExW( hkey, szCompany, NULL, NULL, NULL, &sz);
1609 *pcchOrgNameBuf = sz / sizeof(WCHAR);
1611 if (rc != ERROR_SUCCESS && rc != ERROR_MORE_DATA &&
1612 rc2 != ERROR_SUCCESS && rc2 != ERROR_MORE_DATA)
1615 return USERINFOSTATE_ABSENT;
1620 sz = *pcchSerialBuf * sizeof(WCHAR);
1621 RegQueryValueExW( hkey, szSerial, NULL, NULL, (LPBYTE)lpSerialBuf,
1624 if (!lpSerialBuf && pcchSerialBuf)
1627 rc = RegQueryValueExW( hkey, szSerial, NULL, NULL, NULL, &sz);
1630 *pcchSerialBuf = sz / sizeof(WCHAR);
1633 return USERINFOSTATE_PRESENT;
1636 USERINFOSTATE WINAPI MsiGetUserInfoA(LPCSTR szProduct, LPSTR lpUserNameBuf,
1637 DWORD* pcchUserNameBuf, LPSTR lpOrgNameBuf,
1638 DWORD* pcchOrgNameBuf, LPSTR lpSerialBuf, DWORD* pcchSerialBuf)
1640 FIXME("%s %p %p %p %p %p %p\n",debugstr_a(szProduct), lpUserNameBuf,
1641 pcchUserNameBuf, lpOrgNameBuf, pcchOrgNameBuf, lpSerialBuf,
1644 return USERINFOSTATE_UNKNOWN;
1647 UINT WINAPI MsiCollectUserInfoW(LPCWSTR szProduct)
1651 MSIPACKAGE *package;
1652 static const WCHAR szFirstRun[] = {'F','i','r','s','t','R','u','n',0};
1654 TRACE("(%s)\n",debugstr_w(szProduct));
1656 rc = MsiOpenProductW(szProduct,&handle);
1657 if (rc != ERROR_SUCCESS)
1658 return ERROR_INVALID_PARAMETER;
1660 package = msihandle2msiinfo(handle, MSIHANDLETYPE_PACKAGE);
1661 rc = ACTION_PerformUIAction(package, szFirstRun);
1662 msiobj_release( &package->hdr );
1664 MsiCloseHandle(handle);
1669 UINT WINAPI MsiCollectUserInfoA(LPCSTR szProduct)
1673 MSIPACKAGE *package;
1674 static const WCHAR szFirstRun[] = {'F','i','r','s','t','R','u','n',0};
1676 TRACE("(%s)\n",debugstr_a(szProduct));
1678 rc = MsiOpenProductA(szProduct,&handle);
1679 if (rc != ERROR_SUCCESS)
1680 return ERROR_INVALID_PARAMETER;
1682 package = msihandle2msiinfo(handle, MSIHANDLETYPE_PACKAGE);
1683 rc = ACTION_PerformUIAction(package, szFirstRun);
1684 msiobj_release( &package->hdr );
1686 MsiCloseHandle(handle);
1691 UINT WINAPI MsiCreateAndVerifyInstallerDirectory(DWORD dwReserved)
1693 WCHAR path[MAX_PATH];
1696 FIXME("Don't know how to handle argument %ld\n", dwReserved);
1697 return ERROR_CALL_NOT_IMPLEMENTED;
1700 if(!GetWindowsDirectoryW(path, MAX_PATH)) {
1701 FIXME("GetWindowsDirectory failed unexpected! Error %ld\n",
1703 return ERROR_CALL_NOT_IMPLEMENTED;
1706 strcatW(path, installerW);
1708 CreateDirectoryW(path, NULL);
1713 UINT WINAPI MsiGetShortcutTargetA( LPCSTR szShortcutTarget,
1714 LPSTR szProductCode, LPSTR szFeatureId,
1715 LPSTR szComponentCode )
1718 return ERROR_CALL_NOT_IMPLEMENTED;
1721 UINT WINAPI MsiGetShortcutTargetW( LPCWSTR szShortcutTarget,
1722 LPWSTR szProductCode, LPWSTR szFeatureId,
1723 LPWSTR szComponentCode )
1726 return ERROR_CALL_NOT_IMPLEMENTED;
1729 UINT WINAPI MsiReinstallFeatureW( LPCWSTR szProduct, LPCWSTR szFeature,
1730 DWORD dwReinstallMode )
1732 FIXME("%s %s %li\n", debugstr_w(szProduct), debugstr_w(szFeature),
1734 return ERROR_SUCCESS;
1737 UINT WINAPI MsiReinstallFeatureA( LPCSTR szProduct, LPCSTR szFeature,
1738 DWORD dwReinstallMode )
1740 FIXME("%s %s %li\n", debugstr_a(szProduct), debugstr_a(szFeature),
1742 return ERROR_SUCCESS;