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};
521 FIXME("%s %s %p %p\n",debugstr_w(szProduct), debugstr_w(szAttribute),
522 szBuffer, pcchValueBuf);
524 if (NULL != szBuffer && NULL == pcchValueBuf)
525 return ERROR_INVALID_PARAMETER;
526 if (NULL == szProduct || NULL == szAttribute)
527 return ERROR_INVALID_PARAMETER;
529 /* check for special properties */
530 if (strcmpW(szAttribute, szPackageCode)==0)
533 WCHAR squished[GUID_SIZE];
535 DWORD sz = sizeof(squished);
537 r = MSIREG_OpenUserProductsKey(szProduct, &hkey, FALSE);
538 if (r != ERROR_SUCCESS)
539 return ERROR_UNKNOWN_PRODUCT;
541 r = RegQueryValueExW(hkey, szPackageCode, NULL, NULL,
542 (LPBYTE)squished, &sz);
543 if (r != ERROR_SUCCESS)
546 return ERROR_UNKNOWN_PRODUCT;
549 unsquash_guid(squished, package);
550 *pcchValueBuf = strlenW(package);
551 if (strlenW(package) > *pcchValueBuf)
554 return ERROR_MORE_DATA;
557 strcpyW(szBuffer, package);
562 else if (strcmpW(szAttribute, szVersionString)==0)
564 r = MsiOpenProductW(szProduct, &hProduct);
565 if (ERROR_SUCCESS != r)
568 r = MsiGetPropertyW(hProduct, szProductVersion, szBuffer, pcchValueBuf);
569 MsiCloseHandle(hProduct);
571 else if (strcmpW(szAttribute, szAssignmentType)==0)
573 FIXME("0 (zero) if advertised, 1(one) if per machine.\n");
582 r = MsiOpenProductW(szProduct, &hProduct);
583 if (ERROR_SUCCESS != r)
586 r = MsiGetPropertyW(hProduct, szAttribute, szBuffer, pcchValueBuf);
587 MsiCloseHandle(hProduct);
593 UINT WINAPI MsiEnableLogA(DWORD dwLogMode, LPCSTR szLogFile, DWORD attributes)
595 LPWSTR szwLogFile = NULL;
598 TRACE("%08lx %s %08lx\n", dwLogMode, debugstr_a(szLogFile), attributes);
602 szwLogFile = strdupAtoW( szLogFile );
604 return ERROR_OUTOFMEMORY;
606 r = MsiEnableLogW( dwLogMode, szwLogFile, attributes );
607 HeapFree( GetProcessHeap(), 0, szwLogFile );
611 UINT WINAPI MsiEnableLogW(DWORD dwLogMode, LPCWSTR szLogFile, DWORD attributes)
613 HANDLE file = INVALID_HANDLE_VALUE;
615 TRACE("%08lx %s %08lx\n", dwLogMode, debugstr_w(szLogFile), attributes);
617 lstrcpyW(gszLogFile,szLogFile);
618 if (!(attributes & INSTALLLOGATTRIBUTES_APPEND))
619 DeleteFileW(szLogFile);
620 file = CreateFileW(szLogFile, GENERIC_WRITE, 0, NULL, OPEN_ALWAYS,
621 FILE_ATTRIBUTE_NORMAL, NULL);
622 if (file != INVALID_HANDLE_VALUE)
625 ERR("Unable to enable log %s\n",debugstr_w(szLogFile));
627 return ERROR_SUCCESS;
630 INSTALLSTATE WINAPI MsiQueryProductStateA(LPCSTR szProduct)
632 LPWSTR szwProduct = NULL;
637 szwProduct = strdupAtoW( szProduct );
639 return ERROR_OUTOFMEMORY;
641 r = MsiQueryProductStateW( szwProduct );
642 HeapFree( GetProcessHeap(), 0, szwProduct );
646 INSTALLSTATE WINAPI MsiQueryProductStateW(LPCWSTR szProduct)
649 INSTALLSTATE rrc = INSTALLSTATE_UNKNOWN;
651 static const WCHAR szWindowsInstaller[] = {
652 'W','i','n','d','o','w','s','I','n','s','t','a','l','l','e','r',0 };
655 TRACE("%s\n", debugstr_w(szProduct));
657 rc = MSIREG_OpenUserProductsKey(szProduct,&hkey,FALSE);
658 if (rc != ERROR_SUCCESS)
663 rc = MSIREG_OpenUninstallKey(szProduct,&hkey,FALSE);
664 if (rc != ERROR_SUCCESS)
668 rc = RegQueryValueExW(hkey,szWindowsInstaller,NULL,NULL,(LPVOID)&rrc, &sz);
669 if (rc != ERROR_SUCCESS)
676 rrc = INSTALLSTATE_DEFAULT;
679 FIXME("Unknown install state read from registry (%i)\n",rrc);
680 rrc = INSTALLSTATE_UNKNOWN;
688 INSTALLUILEVEL WINAPI MsiSetInternalUI(INSTALLUILEVEL dwUILevel, HWND *phWnd)
690 INSTALLUILEVEL old = gUILevel;
691 HWND oldwnd = gUIhwnd;
693 TRACE("%08x %p\n", dwUILevel, phWnd);
695 gUILevel = dwUILevel;
704 INSTALLUI_HANDLERA WINAPI MsiSetExternalUIA(INSTALLUI_HANDLERA puiHandler,
705 DWORD dwMessageFilter, LPVOID pvContext)
707 INSTALLUI_HANDLERA prev = gUIHandlerA;
709 TRACE("%p %lx %p\n",puiHandler, dwMessageFilter,pvContext);
710 gUIHandlerA = puiHandler;
711 gUIFilter = dwMessageFilter;
712 gUIContext = pvContext;
717 INSTALLUI_HANDLERW WINAPI MsiSetExternalUIW(INSTALLUI_HANDLERW puiHandler,
718 DWORD dwMessageFilter, LPVOID pvContext)
720 INSTALLUI_HANDLERW prev = gUIHandlerW;
722 TRACE("%p %lx %p\n",puiHandler,dwMessageFilter,pvContext);
723 gUIHandlerW = puiHandler;
724 gUIFilter = dwMessageFilter;
725 gUIContext = pvContext;
730 /******************************************************************
731 * MsiLoadStringW [MSI.@]
733 * Loads a string from MSI's string resources.
737 * handle [I] only -1 is handled currently
738 * id [I] id of the string to be loaded
739 * lpBuffer [O] buffer for the string to be written to
740 * nBufferMax [I] maximum size of the buffer in characters
741 * lang [I] the preferred language for the string
745 * If successful, this function returns the language id of the string loaded
746 * If the function fails, the function returns zero.
750 * The type of the first parameter is unknown. LoadString's prototype
751 * suggests that it might be a module handle. I have made it an MSI handle
752 * for starters, as -1 is an invalid MSI handle, but not an invalid module
753 * handle. Maybe strings can be stored in an MSI database somehow.
755 LANGID WINAPI MsiLoadStringW( MSIHANDLE handle, UINT id, LPWSTR lpBuffer,
756 int nBufferMax, LANGID lang )
763 TRACE("%ld %u %p %d %d\n", handle, id, lpBuffer, nBufferMax, lang);
766 FIXME("don't know how to deal with handle = %08lx\n", handle);
769 lang = GetUserDefaultLangID();
771 hres = FindResourceExW( msi_hInstance, (LPCWSTR) RT_STRING,
775 hResData = LoadResource( msi_hInstance, hres );
778 p = LockResource( hResData );
782 for (i = 0; i < (id&0xf); i++)
786 if( nBufferMax <= len )
789 memcpy( lpBuffer, p+1, len * sizeof(WCHAR));
792 TRACE("found -> %s\n", debugstr_w(lpBuffer));
797 LANGID WINAPI MsiLoadStringA( MSIHANDLE handle, UINT id, LPSTR lpBuffer,
798 int nBufferMax, LANGID lang )
804 bufW = HeapAlloc(GetProcessHeap(), 0, nBufferMax*sizeof(WCHAR));
805 r = MsiLoadStringW(handle, id, bufW, nBufferMax, lang);
808 len = WideCharToMultiByte(CP_ACP, 0, bufW, -1, NULL, 0, NULL, NULL );
809 if( len <= nBufferMax )
810 WideCharToMultiByte( CP_ACP, 0, bufW, -1,
811 lpBuffer, nBufferMax, NULL, NULL );
815 HeapFree(GetProcessHeap(), 0, bufW);
819 INSTALLSTATE WINAPI MsiLocateComponentA(LPCSTR szComponent, LPSTR lpPathBuf,
822 FIXME("%s %p %08lx\n", debugstr_a(szComponent), lpPathBuf, *pcchBuf);
823 return INSTALLSTATE_UNKNOWN;
826 INSTALLSTATE WINAPI MsiLocateComponentW(LPCWSTR szComponent, LPWSTR lpPathBuf,
829 FIXME("%s %p %08lx\n", debugstr_w(szComponent), lpPathBuf, *pcchBuf);
830 return INSTALLSTATE_UNKNOWN;
833 UINT WINAPI MsiMessageBoxA(HWND hWnd, LPCSTR lpText, LPCSTR lpCaption, UINT uType,
834 WORD wLanguageId, DWORD f)
836 FIXME("%p %s %s %u %08x %08lx\n",hWnd,debugstr_a(lpText),debugstr_a(lpCaption),
837 uType,wLanguageId,f);
838 return ERROR_CALL_NOT_IMPLEMENTED;
841 UINT WINAPI MsiMessageBoxW(HWND hWnd, LPCWSTR lpText, LPCWSTR lpCaption, UINT uType,
842 WORD wLanguageId, DWORD f)
844 FIXME("%p %s %s %u %08x %08lx\n",hWnd,debugstr_w(lpText),debugstr_w(lpCaption),
845 uType,wLanguageId,f);
846 return ERROR_CALL_NOT_IMPLEMENTED;
849 UINT WINAPI MsiProvideAssemblyA( LPCSTR szAssemblyName, LPCSTR szAppContext,
850 DWORD dwInstallMode, DWORD dwAssemblyInfo, LPSTR lpPathBuf,
853 FIXME("%s %s %08lx %08lx %p %p\n", debugstr_a(szAssemblyName),
854 debugstr_a(szAppContext), dwInstallMode, dwAssemblyInfo, lpPathBuf,
856 return ERROR_CALL_NOT_IMPLEMENTED;
859 UINT WINAPI MsiProvideAssemblyW( LPCWSTR szAssemblyName, LPCWSTR szAppContext,
860 DWORD dwInstallMode, DWORD dwAssemblyInfo, LPWSTR lpPathBuf,
863 FIXME("%s %s %08lx %08lx %p %p\n", debugstr_w(szAssemblyName),
864 debugstr_w(szAppContext), dwInstallMode, dwAssemblyInfo, lpPathBuf,
866 return ERROR_CALL_NOT_IMPLEMENTED;
869 UINT WINAPI MsiProvideComponentFromDescriptorA( LPCSTR szDescriptor,
870 LPSTR szPath, DWORD *pcchPath, DWORD *pcchArgs )
872 FIXME("%s %p %p %p\n", debugstr_a(szDescriptor), szPath, pcchPath, pcchArgs );
873 return ERROR_CALL_NOT_IMPLEMENTED;
876 UINT WINAPI MsiProvideComponentFromDescriptorW( LPCWSTR szDescriptor,
877 LPWSTR szPath, DWORD *pcchPath, DWORD *pcchArgs )
879 FIXME("%s %p %p %p\n", debugstr_w(szDescriptor), szPath, pcchPath, pcchArgs );
880 return ERROR_CALL_NOT_IMPLEMENTED;
883 HRESULT WINAPI MsiGetFileSignatureInformationA( LPCSTR szSignedObjectPath,
884 DWORD dwFlags, PCCERT_CONTEXT* ppcCertContext, BYTE* pbHashData,
887 FIXME("%s %08lx %p %p %p\n", debugstr_a(szSignedObjectPath), dwFlags,
888 ppcCertContext, pbHashData, pcbHashData);
889 return ERROR_CALL_NOT_IMPLEMENTED;
892 HRESULT WINAPI MsiGetFileSignatureInformationW( LPCWSTR szSignedObjectPath,
893 DWORD dwFlags, PCCERT_CONTEXT* ppcCertContext, BYTE* pbHashData,
896 FIXME("%s %08lx %p %p %p\n", debugstr_w(szSignedObjectPath), dwFlags,
897 ppcCertContext, pbHashData, pcbHashData);
898 return ERROR_CALL_NOT_IMPLEMENTED;
901 UINT WINAPI MsiGetProductPropertyA( MSIHANDLE hProduct, LPCSTR szProperty,
902 LPSTR szValue, DWORD *pccbValue )
904 FIXME("%ld %s %p %p\n", hProduct, debugstr_a(szProperty), szValue, pccbValue);
905 return ERROR_CALL_NOT_IMPLEMENTED;
908 UINT WINAPI MsiGetProductPropertyW( MSIHANDLE hProduct, LPCWSTR szProperty,
909 LPWSTR szValue, DWORD *pccbValue )
911 FIXME("%ld %s %p %p\n", hProduct, debugstr_w(szProperty), szValue, pccbValue);
912 return ERROR_CALL_NOT_IMPLEMENTED;
915 UINT WINAPI MsiVerifyPackageA( LPCSTR szPackage )
918 LPWSTR szPack = NULL;
920 TRACE("%s\n", debugstr_a(szPackage) );
924 szPack = strdupAtoW( szPackage );
926 return ERROR_OUTOFMEMORY;
929 r = MsiVerifyPackageW( szPack );
931 HeapFree( GetProcessHeap(), 0, szPack );
936 UINT WINAPI MsiVerifyPackageW( LPCWSTR szPackage )
941 TRACE("%s\n", debugstr_w(szPackage) );
943 r = MsiOpenDatabaseW( szPackage, MSIDBOPEN_READONLY, &handle );
944 MsiCloseHandle( handle );
949 INSTALLSTATE WINAPI MsiGetComponentPathA(LPCSTR szProduct, LPCSTR szComponent,
950 LPSTR lpPathBuf, DWORD* pcchBuf)
952 LPWSTR szwProduct = NULL, szwComponent = NULL, lpwPathBuf= NULL;
958 szwProduct = strdupAtoW( szProduct );
960 return ERROR_OUTOFMEMORY;
965 szwComponent = strdupAtoW( szComponent );
968 HeapFree( GetProcessHeap(), 0, szwProduct);
969 return ERROR_OUTOFMEMORY;
973 if( pcchBuf && *pcchBuf > 0 )
974 lpwPathBuf = HeapAlloc( GetProcessHeap(), 0, *pcchBuf * sizeof(WCHAR));
978 incoming_len = *pcchBuf;
979 rc = MsiGetComponentPathW(szwProduct, szwComponent, lpwPathBuf, pcchBuf);
981 HeapFree( GetProcessHeap(), 0, szwProduct);
982 HeapFree( GetProcessHeap(), 0, szwComponent);
985 if (rc != INSTALLSTATE_UNKNOWN)
986 WideCharToMultiByte(CP_ACP, 0, lpwPathBuf, incoming_len,
987 lpPathBuf, incoming_len, NULL, NULL);
988 HeapFree( GetProcessHeap(), 0, lpwPathBuf);
994 INSTALLSTATE WINAPI MsiGetComponentPathW(LPCWSTR szProduct, LPCWSTR szComponent,
995 LPWSTR lpPathBuf, DWORD* pcchBuf)
997 WCHAR squished_pc[GUID_SIZE];
999 INSTALLSTATE rrc = INSTALLSTATE_UNKNOWN;
1004 TRACE("%s %s %p %p\n", debugstr_w(szProduct),
1005 debugstr_w(szComponent), lpPathBuf, pcchBuf);
1007 if( lpPathBuf && !pcchBuf )
1008 return INSTALLSTATE_INVALIDARG;
1010 squash_guid(szProduct,squished_pc);
1012 rc = MSIREG_OpenProductsKey( szProduct, &hkey, FALSE);
1013 if( rc != ERROR_SUCCESS )
1018 rc = MSIREG_OpenComponentsKey( szComponent, &hkey, FALSE);
1019 if( rc != ERROR_SUCCESS )
1024 rc = RegQueryValueExW( hkey, squished_pc, NULL, &type, NULL, &sz );
1025 if( rc != ERROR_SUCCESS )
1027 if( type != REG_SZ )
1030 sz += sizeof(WCHAR);
1031 path = HeapAlloc( GetProcessHeap(), 0, sz );
1035 rc = RegQueryValueExW( hkey, squished_pc, NULL, NULL, (LPVOID) path, &sz );
1036 if( rc != ERROR_SUCCESS )
1039 TRACE("found path of (%s:%s)(%s)\n", debugstr_w(szComponent),
1040 debugstr_w(szProduct), debugstr_w(path));
1044 FIXME("Registry entry.. check entry\n");
1045 rrc = INSTALLSTATE_LOCAL;
1049 /* PROBABLY a file */
1050 if ( GetFileAttributesW(path) != INVALID_FILE_ATTRIBUTES )
1051 rrc = INSTALLSTATE_LOCAL;
1053 rrc = INSTALLSTATE_ABSENT;
1058 sz = sz / sizeof(WCHAR);
1059 if( *pcchBuf >= sz )
1060 lstrcpyW( lpPathBuf, path );
1065 HeapFree(GetProcessHeap(), 0, path );
1070 /******************************************************************
1071 * MsiQueryFeatureStateA [MSI.@]
1073 INSTALLSTATE WINAPI MsiQueryFeatureStateA(LPCSTR szProduct, LPCSTR szFeature)
1076 LPWSTR szwProduct= NULL;
1077 LPWSTR szwFeature= NULL;
1081 szwProduct = strdupAtoW( szProduct );
1083 return ERROR_OUTOFMEMORY;
1088 szwFeature = strdupAtoW( szFeature );
1091 HeapFree( GetProcessHeap(), 0, szwProduct);
1092 return ERROR_OUTOFMEMORY;
1096 rc = MsiQueryFeatureStateW(szwProduct, szwFeature);
1098 HeapFree( GetProcessHeap(), 0, szwProduct);
1099 HeapFree( GetProcessHeap(), 0, szwFeature);
1104 /******************************************************************
1105 * MsiQueryFeatureStateW [MSI.@]
1107 * This does not verify that the Feature is functional. So i am only going to
1108 * check the existence of the key in the registry. This should tell me if it is
1111 INSTALLSTATE WINAPI MsiQueryFeatureStateW(LPCWSTR szProduct, LPCWSTR szFeature)
1117 TRACE("%s %s\n", debugstr_w(szProduct), debugstr_w(szFeature));
1119 rc = MSIREG_OpenFeaturesKey(szProduct, &hkey, FALSE);
1120 if (rc != ERROR_SUCCESS)
1121 return INSTALLSTATE_UNKNOWN;
1123 rc = RegQueryValueExW( hkey, szFeature, NULL, NULL, NULL, &sz);
1126 if (rc == ERROR_SUCCESS)
1127 return INSTALLSTATE_LOCAL;
1129 return INSTALLSTATE_ABSENT;
1132 /******************************************************************
1133 * MsiGetFileVersionA [MSI.@]
1135 UINT WINAPI MsiGetFileVersionA(LPCSTR szFilePath, LPSTR lpVersionBuf,
1136 DWORD* pcchVersionBuf, LPSTR lpLangBuf, DWORD* pcchLangBuf)
1138 LPWSTR szwFilePath = NULL, lpwVersionBuff = NULL, lpwLangBuff = NULL;
1139 UINT ret = ERROR_OUTOFMEMORY;
1143 szwFilePath = strdupAtoW( szFilePath );
1148 if( lpVersionBuf && pcchVersionBuf && *pcchVersionBuf )
1150 lpwVersionBuff = HeapAlloc(GetProcessHeap(), 0, *pcchVersionBuf*sizeof(WCHAR));
1151 if( !lpwVersionBuff )
1155 if( lpLangBuf && pcchLangBuf && *pcchLangBuf )
1157 lpwLangBuff = HeapAlloc(GetProcessHeap(), 0, *pcchVersionBuf*sizeof(WCHAR));
1162 ret = MsiGetFileVersionW(szwFilePath, lpwVersionBuff, pcchVersionBuf,
1163 lpwLangBuff, pcchLangBuf);
1165 if( lpwVersionBuff )
1166 WideCharToMultiByte(CP_ACP, 0, lpwVersionBuff, -1,
1167 lpVersionBuf, *pcchVersionBuf, NULL, NULL);
1169 WideCharToMultiByte(CP_ACP, 0, lpwLangBuff, -1,
1170 lpLangBuf, *pcchLangBuf, NULL, NULL);
1173 HeapFree(GetProcessHeap(), 0, szwFilePath);
1174 HeapFree(GetProcessHeap(), 0, lpwVersionBuff);
1175 HeapFree(GetProcessHeap(), 0, lpwLangBuff);
1180 /******************************************************************
1181 * MsiGetFileVersionW [MSI.@]
1183 UINT WINAPI MsiGetFileVersionW(LPCWSTR szFilePath, LPWSTR lpVersionBuf,
1184 DWORD* pcchVersionBuf, LPWSTR lpLangBuf, DWORD* pcchLangBuf)
1186 static const WCHAR szVersionResource[] = {'\\',0};
1187 static const WCHAR szVersionFormat[] = {
1188 '%','d','.','%','d','.','%','d','.','%','d',0};
1189 static const WCHAR szLangFormat[] = {'%','d',0};
1192 LPVOID lpVer = NULL;
1193 VS_FIXEDFILEINFO *ffi;
1197 TRACE("%s %p %ld %p %ld\n", debugstr_w(szFilePath),
1198 lpVersionBuf, pcchVersionBuf?*pcchVersionBuf:0,
1199 lpLangBuf, pcchLangBuf?*pcchLangBuf:0);
1201 dwVerLen = GetFileVersionInfoSizeW(szFilePath, NULL);
1203 return GetLastError();
1205 lpVer = HeapAlloc(GetProcessHeap(), 0, dwVerLen);
1208 ret = ERROR_OUTOFMEMORY;
1212 if( !GetFileVersionInfoW(szFilePath, 0, dwVerLen, lpVer) )
1214 ret = GetLastError();
1217 if( lpVersionBuf && pcchVersionBuf && *pcchVersionBuf )
1219 if( VerQueryValueW(lpVer, szVersionResource, (LPVOID*)&ffi, &puLen) &&
1222 wsprintfW(tmp, szVersionFormat,
1223 HIWORD(ffi->dwFileVersionMS), LOWORD(ffi->dwFileVersionMS),
1224 HIWORD(ffi->dwFileVersionLS), LOWORD(ffi->dwFileVersionLS));
1225 lstrcpynW(lpVersionBuf, tmp, *pcchVersionBuf);
1226 *pcchVersionBuf = lstrlenW(lpVersionBuf);
1231 *pcchVersionBuf = 0;
1235 if( lpLangBuf && pcchLangBuf && *pcchLangBuf )
1237 DWORD lang = GetUserDefaultLangID();
1239 FIXME("Retrieve language from file\n");
1240 wsprintfW(tmp, szLangFormat, lang);
1241 lstrcpynW(lpLangBuf, tmp, *pcchLangBuf);
1242 *pcchLangBuf = lstrlenW(lpLangBuf);
1246 HeapFree(GetProcessHeap(), 0, lpVer);
1251 /******************************************************************
1254 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
1258 case DLL_PROCESS_ATTACH:
1259 msi_hInstance = hinstDLL;
1260 DisableThreadLibraryCalls(hinstDLL);
1261 msi_dialog_register_class();
1263 case DLL_PROCESS_DETACH:
1264 msi_dialog_unregister_class();
1265 /* FIXME: Cleanup */
1271 typedef struct tagIClassFactoryImpl
1273 const IClassFactoryVtbl *lpVtbl;
1274 } IClassFactoryImpl;
1276 static HRESULT WINAPI MsiCF_QueryInterface(LPCLASSFACTORY iface,
1277 REFIID riid,LPVOID *ppobj)
1279 IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
1280 FIXME("%p %s %p\n",This,debugstr_guid(riid),ppobj);
1281 return E_NOINTERFACE;
1284 static ULONG WINAPI MsiCF_AddRef(LPCLASSFACTORY iface)
1289 static ULONG WINAPI MsiCF_Release(LPCLASSFACTORY iface)
1294 static HRESULT WINAPI MsiCF_CreateInstance(LPCLASSFACTORY iface,
1295 LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj)
1297 IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
1299 FIXME("%p %p %s %p\n", This, pOuter, debugstr_guid(riid), ppobj);
1303 static HRESULT WINAPI MsiCF_LockServer(LPCLASSFACTORY iface, BOOL dolock)
1305 IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
1307 FIXME("%p %d\n", This, dolock);
1311 static const IClassFactoryVtbl MsiCF_Vtbl =
1313 MsiCF_QueryInterface,
1316 MsiCF_CreateInstance,
1320 static IClassFactoryImpl Msi_CF = { &MsiCF_Vtbl };
1322 /******************************************************************
1323 * DllGetClassObject [MSI.@]
1325 HRESULT WINAPI MSI_DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
1327 TRACE("%s %s %p\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
1329 if( IsEqualCLSID (rclsid, &CLSID_IMsiServer) ||
1330 IsEqualCLSID (rclsid, &CLSID_IMsiServerMessage) ||
1331 IsEqualCLSID (rclsid, &CLSID_IMsiServerX1) ||
1332 IsEqualCLSID (rclsid, &CLSID_IMsiServerX2) ||
1333 IsEqualCLSID (rclsid, &CLSID_IMsiServerX3) )
1335 *ppv = (LPVOID) &Msi_CF;
1338 return CLASS_E_CLASSNOTAVAILABLE;
1341 /******************************************************************
1342 * DllGetVersion [MSI.@]
1344 HRESULT WINAPI MSI_DllGetVersion(DLLVERSIONINFO *pdvi)
1348 if (pdvi->cbSize != sizeof(DLLVERSIONINFO))
1349 return E_INVALIDARG;
1351 pdvi->dwMajorVersion = MSI_MAJORVERSION;
1352 pdvi->dwMinorVersion = MSI_MINORVERSION;
1353 pdvi->dwBuildNumber = MSI_BUILDNUMBER;
1354 pdvi->dwPlatformID = 1;
1359 /******************************************************************
1360 * DllCanUnloadNow [MSI.@]
1362 BOOL WINAPI MSI_DllCanUnloadNow(void)
1367 UINT WINAPI MsiGetFeatureUsageW(LPCWSTR szProduct, LPCWSTR szFeature,
1368 DWORD* pdwUseCount, WORD* pwDateUsed)
1370 FIXME("%s %s %p %p\n",debugstr_w(szProduct), debugstr_w(szFeature),
1371 pdwUseCount, pwDateUsed);
1372 return ERROR_CALL_NOT_IMPLEMENTED;
1375 UINT WINAPI MsiGetFeatureUsageA(LPCSTR szProduct, LPCSTR szFeature,
1376 DWORD* pdwUseCount, WORD* pwDateUsed)
1378 FIXME("%s %s %p %p\n", debugstr_a(szProduct), debugstr_a(szFeature),
1379 pdwUseCount, pwDateUsed);
1380 return ERROR_CALL_NOT_IMPLEMENTED;
1383 INSTALLSTATE WINAPI MsiUseFeatureExW(LPCWSTR szProduct, LPCWSTR szFeature,
1384 DWORD dwInstallMode, DWORD dwReserved)
1386 FIXME("%s %s %li %li\n", debugstr_w(szProduct), debugstr_w(szFeature),
1387 dwInstallMode, dwReserved);
1390 * Polls all the components of the feature to find install state and then
1392 * Software\\Microsoft\\Windows\\CurrentVersion\\
1393 * Installer\\Products\\<squishguid>\\<feature>
1394 * "Usage"=dword:........
1397 return INSTALLSTATE_LOCAL;
1400 /***********************************************************************
1401 * MsiUseFeatureExA [MSI.@]
1403 INSTALLSTATE WINAPI MsiUseFeatureExA(LPCSTR szProduct, LPCSTR szFeature,
1404 DWORD dwInstallMode, DWORD dwReserved)
1406 FIXME("%s %s %li %li\n", debugstr_a(szProduct), debugstr_a(szFeature),
1407 dwInstallMode, dwReserved);
1409 return INSTALLSTATE_LOCAL;
1412 INSTALLSTATE WINAPI MsiUseFeatureW(LPCWSTR szProduct, LPCWSTR szFeature)
1414 FIXME("%s %s\n", debugstr_w(szProduct), debugstr_w(szFeature));
1416 return INSTALLSTATE_LOCAL;
1419 INSTALLSTATE WINAPI MsiUseFeatureA(LPCSTR szProduct, LPCSTR szFeature)
1421 FIXME("%s %s\n", debugstr_a(szProduct), debugstr_a(szFeature));
1423 return INSTALLSTATE_LOCAL;
1426 UINT WINAPI MsiProvideQualifiedComponentExW(LPCWSTR szComponent,
1427 LPCWSTR szQualifier, DWORD dwInstallMode, LPWSTR szProduct,
1428 DWORD Unused1, DWORD Unused2, LPWSTR lpPathBuf,
1435 LPWSTR product = NULL;
1436 LPWSTR component = NULL;
1440 TRACE("%s %s %li %s %li %li %p %p\n", debugstr_w(szComponent),
1441 debugstr_w(szQualifier), dwInstallMode, debugstr_w(szProduct),
1442 Unused1, Unused2, lpPathBuf, pcchPathBuf);
1444 rc = MSIREG_OpenUserComponentsKey(szComponent, &hkey, FALSE);
1445 if (rc != ERROR_SUCCESS)
1446 return ERROR_INDEX_ABSENT;
1449 rc = RegQueryValueExW( hkey, szQualifier, NULL, NULL, NULL, &sz);
1453 return ERROR_INDEX_ABSENT;
1456 info = HeapAlloc(GetProcessHeap(),0,sz);
1457 rc = RegQueryValueExW( hkey, szQualifier, NULL, NULL, (LPBYTE)info, &sz);
1458 if (rc != ERROR_SUCCESS)
1461 HeapFree(GetProcessHeap(),0,info);
1462 return ERROR_INDEX_ABSENT;
1465 /* find the component */
1466 ptr = strchrW(&info[20],'>');
1472 HeapFree(GetProcessHeap(),0,info);
1473 return ERROR_INDEX_ABSENT;
1478 decode_base85_guid(info,&clsid);
1479 StringFromCLSID(&clsid, &product);
1481 decode_base85_guid(ptr,&clsid);
1482 StringFromCLSID(&clsid, &component);
1485 rc = MsiGetComponentPathW(product, component, lpPathBuf, pcchPathBuf);
1487 rc = MsiGetComponentPathW(szProduct, component, lpPathBuf, pcchPathBuf);
1490 HeapFree(GetProcessHeap(),0,info);
1491 HeapFree(GetProcessHeap(),0,product);
1492 HeapFree(GetProcessHeap(),0,component);
1494 if (rc == INSTALLSTATE_LOCAL)
1495 return ERROR_SUCCESS;
1497 return ERROR_FILE_NOT_FOUND;
1500 /***********************************************************************
1501 * MsiProvideQualifiedComponentW [MSI.@]
1503 UINT WINAPI MsiProvideQualifiedComponentW( LPCWSTR szComponent,
1504 LPCWSTR szQualifier, DWORD dwInstallMode, LPWSTR lpPathBuf,
1507 return MsiProvideQualifiedComponentExW(szComponent, szQualifier,
1508 dwInstallMode, NULL, 0, 0, lpPathBuf, pcchPathBuf);
1511 /***********************************************************************
1512 * MsiProvideQualifiedComponentA [MSI.@]
1514 UINT WINAPI MsiProvideQualifiedComponentA( LPCSTR szComponent,
1515 LPCSTR szQualifier, DWORD dwInstallMode, LPSTR lpPathBuf,
1518 LPWSTR szwComponent, szwQualifier, lpwPathBuf;
1522 TRACE("%s %s %li %p %p\n",szComponent, szQualifier,
1523 dwInstallMode, lpPathBuf, pcchPathBuf);
1525 szwComponent= strdupAtoW( szComponent);
1526 szwQualifier= strdupAtoW( szQualifier);
1528 lpwPathBuf = HeapAlloc(GetProcessHeap(),0,*pcchPathBuf * sizeof(WCHAR));
1530 pcchwPathBuf = *pcchPathBuf;
1532 rc = MsiProvideQualifiedComponentW(szwComponent, szwQualifier,
1533 dwInstallMode, lpwPathBuf, &pcchwPathBuf);
1535 HeapFree(GetProcessHeap(),0,szwComponent);
1536 HeapFree(GetProcessHeap(),0,szwQualifier);
1537 *pcchPathBuf = WideCharToMultiByte(CP_ACP, 0, lpwPathBuf, pcchwPathBuf,
1538 lpPathBuf, *pcchPathBuf, NULL, NULL);
1540 HeapFree(GetProcessHeap(),0,lpwPathBuf);
1544 USERINFOSTATE WINAPI MsiGetUserInfoW(LPCWSTR szProduct, LPWSTR lpUserNameBuf,
1545 DWORD* pcchUserNameBuf, LPWSTR lpOrgNameBuf,
1546 DWORD* pcchOrgNameBuf, LPWSTR lpSerialBuf, DWORD* pcchSerialBuf)
1550 UINT rc = ERROR_SUCCESS,rc2 = ERROR_SUCCESS;
1551 static const WCHAR szOwner[] = {'R','e','g','O','w','n','e','r',0};
1552 static const WCHAR szCompany[] = {'R','e','g','C','o','m','p','a','n','y',0};
1553 static const WCHAR szSerial[] = {'P','r','o','d','u','c','t','I','D',0};
1555 TRACE("%s %p %p %p %p %p %p\n",debugstr_w(szProduct), lpUserNameBuf,
1556 pcchUserNameBuf, lpOrgNameBuf, pcchOrgNameBuf, lpSerialBuf,
1559 rc = MSIREG_OpenUninstallKey(szProduct, &hkey, FALSE);
1560 if (rc != ERROR_SUCCESS)
1561 return USERINFOSTATE_UNKNOWN;
1565 sz = *lpUserNameBuf * sizeof(WCHAR);
1566 rc = RegQueryValueExW( hkey, szOwner, NULL, NULL, (LPBYTE)lpUserNameBuf,
1569 if (!lpUserNameBuf && pcchUserNameBuf)
1572 rc = RegQueryValueExW( hkey, szOwner, NULL, NULL, NULL, &sz);
1575 if (pcchUserNameBuf)
1576 *pcchUserNameBuf = sz / sizeof(WCHAR);
1580 sz = *pcchOrgNameBuf * sizeof(WCHAR);
1581 rc2 = RegQueryValueExW( hkey, szCompany, NULL, NULL,
1582 (LPBYTE)lpOrgNameBuf, &sz);
1584 if (!lpOrgNameBuf && pcchOrgNameBuf)
1587 rc2 = RegQueryValueExW( hkey, szCompany, NULL, NULL, NULL, &sz);
1591 *pcchOrgNameBuf = sz / sizeof(WCHAR);
1593 if (rc != ERROR_SUCCESS && rc != ERROR_MORE_DATA &&
1594 rc2 != ERROR_SUCCESS && rc2 != ERROR_MORE_DATA)
1597 return USERINFOSTATE_ABSENT;
1602 sz = *pcchSerialBuf * sizeof(WCHAR);
1603 RegQueryValueExW( hkey, szSerial, NULL, NULL, (LPBYTE)lpSerialBuf,
1606 if (!lpSerialBuf && pcchSerialBuf)
1609 rc = RegQueryValueExW( hkey, szSerial, NULL, NULL, NULL, &sz);
1612 *pcchSerialBuf = sz / sizeof(WCHAR);
1615 return USERINFOSTATE_PRESENT;
1618 USERINFOSTATE WINAPI MsiGetUserInfoA(LPCSTR szProduct, LPSTR lpUserNameBuf,
1619 DWORD* pcchUserNameBuf, LPSTR lpOrgNameBuf,
1620 DWORD* pcchOrgNameBuf, LPSTR lpSerialBuf, DWORD* pcchSerialBuf)
1622 FIXME("%s %p %p %p %p %p %p\n",debugstr_a(szProduct), lpUserNameBuf,
1623 pcchUserNameBuf, lpOrgNameBuf, pcchOrgNameBuf, lpSerialBuf,
1626 return USERINFOSTATE_UNKNOWN;
1629 UINT WINAPI MsiCollectUserInfoW(LPCWSTR szProduct)
1633 MSIPACKAGE *package;
1634 static const WCHAR szFirstRun[] = {'F','i','r','s','t','R','u','n',0};
1636 TRACE("(%s)\n",debugstr_w(szProduct));
1638 rc = MsiOpenProductW(szProduct,&handle);
1639 if (rc != ERROR_SUCCESS)
1640 return ERROR_INVALID_PARAMETER;
1642 package = msihandle2msiinfo(handle, MSIHANDLETYPE_PACKAGE);
1643 rc = ACTION_PerformUIAction(package, szFirstRun);
1644 msiobj_release( &package->hdr );
1646 MsiCloseHandle(handle);
1651 UINT WINAPI MsiCollectUserInfoA(LPCSTR szProduct)
1655 MSIPACKAGE *package;
1656 static const WCHAR szFirstRun[] = {'F','i','r','s','t','R','u','n',0};
1658 TRACE("(%s)\n",debugstr_a(szProduct));
1660 rc = MsiOpenProductA(szProduct,&handle);
1661 if (rc != ERROR_SUCCESS)
1662 return ERROR_INVALID_PARAMETER;
1664 package = msihandle2msiinfo(handle, MSIHANDLETYPE_PACKAGE);
1665 rc = ACTION_PerformUIAction(package, szFirstRun);
1666 msiobj_release( &package->hdr );
1668 MsiCloseHandle(handle);
1673 UINT WINAPI MsiCreateAndVerifyInstallerDirectory(DWORD dwReserved)
1675 WCHAR path[MAX_PATH];
1678 FIXME("Don't know how to handle argument %ld\n", dwReserved);
1679 return ERROR_CALL_NOT_IMPLEMENTED;
1682 if(!GetWindowsDirectoryW(path, MAX_PATH)) {
1683 FIXME("GetWindowsDirectory failed unexpected! Error %ld\n",
1685 return ERROR_CALL_NOT_IMPLEMENTED;
1688 strcatW(path, installerW);
1690 CreateDirectoryW(path, NULL);
1695 UINT WINAPI MsiGetShortcutTargetA( LPCSTR szShortcutTarget,
1696 LPSTR szProductCode, LPSTR szFeatureId,
1697 LPSTR szComponentCode )
1700 return ERROR_CALL_NOT_IMPLEMENTED;
1703 UINT WINAPI MsiGetShortcutTargetW( LPCWSTR szShortcutTarget,
1704 LPWSTR szProductCode, LPWSTR szFeatureId,
1705 LPWSTR szComponentCode )
1708 return ERROR_CALL_NOT_IMPLEMENTED;
1711 UINT WINAPI MsiReinstallFeatureW( LPCWSTR szProduct, LPCWSTR szFeature,
1712 DWORD dwReinstallMode )
1714 FIXME("%s %s %li\n", debugstr_w(szProduct), debugstr_w(szFeature),
1716 return ERROR_SUCCESS;
1719 UINT WINAPI MsiReinstallFeatureA( LPCSTR szProduct, LPCSTR szFeature,
1720 DWORD dwReinstallMode )
1722 FIXME("%s %s %li\n", debugstr_a(szProduct), debugstr_a(szFeature),
1724 return ERROR_SUCCESS;