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"
37 #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
54 DEFINE_GUID( CLSID_MsiDatabase, 0x000c1084, 0x0000, 0x0000,
55 0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
58 INSTALLUILEVEL gUILevel = INSTALLUILEVEL_BASIC;
60 INSTALLUI_HANDLERA gUIHandlerA = NULL;
61 INSTALLUI_HANDLERW gUIHandlerW = NULL;
63 LPVOID gUIContext = NULL;
64 WCHAR gszLogFile[MAX_PATH];
65 HINSTANCE msi_hInstance;
70 * A .msi file is a structured storage file.
71 * It should contain a number of streams.
74 VOID MSI_CloseDatabase( MSIOBJECTHDR *arg )
76 MSIDATABASE *db = (MSIDATABASE *) arg;
79 free_cached_tables( db );
80 r = IStorage_Release( db->storage );
82 ERR("database reference count was not zero (%ld)\n", r);
85 UINT MSI_OpenDatabaseW(LPCWSTR szDBPath, LPCWSTR szPersist, MSIDATABASE **pdb)
89 MSIDATABASE *db = NULL;
90 UINT ret = ERROR_FUNCTION_FAILED;
94 TRACE("%s %s\n",debugstr_w(szDBPath),debugstr_w(szPersist) );
97 return ERROR_INVALID_PARAMETER;
99 szMode = (LPWSTR) szPersist;
100 if( HIWORD( szPersist ) )
102 /* UINT len = lstrlenW( szPerist ) + 1; */
103 FIXME("don't support persist files yet\b");
104 return ERROR_INVALID_PARAMETER;
105 /* szMode = HeapAlloc( GetProcessHeap(), 0, len * sizeof (DWORD) ); */
107 else if( szPersist == MSIDBOPEN_READONLY )
109 r = StgOpenStorage( szDBPath, NULL,
110 STGM_DIRECT|STGM_READ|STGM_SHARE_DENY_WRITE, NULL, 0, &stg);
112 else if( szPersist == MSIDBOPEN_CREATE )
114 r = StgCreateDocfile( szDBPath,
115 STGM_DIRECT|STGM_READWRITE|STGM_SHARE_EXCLUSIVE, 0, &stg);
116 if( r == ERROR_SUCCESS )
118 IStorage_SetClass( stg, &CLSID_MsiDatabase );
119 r = init_string_table( stg );
122 else if( szPersist == MSIDBOPEN_TRANSACT )
124 r = StgOpenStorage( szDBPath, NULL,
125 STGM_DIRECT|STGM_READWRITE|STGM_SHARE_EXCLUSIVE, NULL, 0, &stg);
129 ERR("unknown flag %p\n",szPersist);
130 return ERROR_INVALID_PARAMETER;
135 FIXME("open failed r = %08lx!\n",r);
136 return ERROR_FUNCTION_FAILED;
139 r = IStorage_Stat( stg, &stat, STATFLAG_NONAME );
142 FIXME("Failed to stat storage\n");
146 if( memcmp( &stat.clsid, &CLSID_MsiDatabase, sizeof (GUID) ) )
148 ERR("storage GUID is not a MSI database GUID %s\n",
149 debugstr_guid(&stat.clsid) );
154 db = alloc_msiobject( MSIHANDLETYPE_DATABASE, sizeof (MSIDATABASE),
158 FIXME("Failed to allocate a handle\n");
162 if( TRACE_ON( msi ) )
163 enum_stream_names( stg );
168 ret = load_string_table( db );
169 if( ret != ERROR_SUCCESS )
172 msiobj_addref( &db->hdr );
173 IStorage_AddRef( stg );
178 msiobj_release( &db->hdr );
180 IStorage_Release( stg );
185 UINT WINAPI MsiOpenDatabaseW(LPCWSTR szDBPath, LPCWSTR szPersist, MSIHANDLE *phDB)
190 TRACE("%s %s %p\n",debugstr_w(szDBPath),debugstr_w(szPersist), phDB);
192 ret = MSI_OpenDatabaseW( szDBPath, szPersist, &db );
193 if( ret == ERROR_SUCCESS )
195 *phDB = alloc_msihandle( &db->hdr );
196 msiobj_release( &db->hdr );
202 UINT WINAPI MsiOpenDatabaseA(LPCSTR szDBPath, LPCSTR szPersist, MSIHANDLE *phDB)
204 HRESULT r = ERROR_FUNCTION_FAILED;
205 LPWSTR szwDBPath = NULL, szwPersist = NULL;
208 TRACE("%s %s %p\n", debugstr_a(szDBPath), debugstr_a(szPersist), phDB);
212 len = MultiByteToWideChar( CP_ACP, 0, szDBPath, -1, NULL, 0 );
213 szwDBPath = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
216 MultiByteToWideChar( CP_ACP, 0, szDBPath, -1, szwDBPath, len );
219 if( HIWORD(szPersist) )
221 len = MultiByteToWideChar( CP_ACP, 0, szPersist, -1, NULL, 0 );
222 szwPersist = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
225 MultiByteToWideChar( CP_ACP, 0, szPersist, -1, szwPersist, len );
228 szwPersist = (LPWSTR) szPersist;
230 r = MsiOpenDatabaseW( szwDBPath, szwPersist, phDB );
233 HeapFree( GetProcessHeap(), 0, szwPersist );
234 HeapFree( GetProcessHeap(), 0, szwDBPath );
239 UINT WINAPI MsiOpenProductA(LPCSTR szProduct, MSIHANDLE *phProduct)
242 LPWSTR szwProd = NULL;
244 TRACE("%s %p\n",debugstr_a(szProduct), phProduct);
248 len = MultiByteToWideChar( CP_ACP, 0, szProduct, -1, NULL, 0 );
249 szwProd = HeapAlloc( GetProcessHeap(), 0, len * sizeof (WCHAR) );
251 MultiByteToWideChar( CP_ACP, 0, szProduct, -1, szwProd, len );
254 ret = MsiOpenProductW( szwProd, phProduct );
256 HeapFree( GetProcessHeap(), 0, szwProd );
261 UINT WINAPI MsiOpenProductW(LPCWSTR szProduct, MSIHANDLE *phProduct)
263 static const WCHAR szLocalPackage[] = {
264 'L','o','c','a','l','P','a','c','k','a','g','e', 0
268 HKEY hKeyProduct = NULL;
271 TRACE("%s %p\n",debugstr_w(szProduct), phProduct);
273 r = MSIREG_OpenUninstallKey(szProduct,&hKeyProduct,FALSE);
274 if( r != ERROR_SUCCESS )
276 r = ERROR_UNKNOWN_PRODUCT;
280 /* find the size of the path */
282 r = RegQueryValueExW( hKeyProduct, szLocalPackage,
283 NULL, &type, NULL, &count );
284 if( r != ERROR_SUCCESS )
286 r = ERROR_UNKNOWN_PRODUCT;
290 /* now alloc and fetch the path of the database to open */
291 path = HeapAlloc( GetProcessHeap(), 0, count );
295 r = RegQueryValueExW( hKeyProduct, szLocalPackage,
296 NULL, &type, (LPBYTE) path, &count );
297 if( r != ERROR_SUCCESS )
299 r = ERROR_UNKNOWN_PRODUCT;
303 r = MsiOpenPackageW( path, phProduct );
306 HeapFree( GetProcessHeap(), 0, path );
308 RegCloseKey( hKeyProduct );
313 UINT WINAPI MsiAdvertiseProductA(LPCSTR szPackagePath, LPCSTR szScriptfilePath,
314 LPCSTR szTransforms, LANGID lgidLanguage)
316 FIXME("%s %s %s %08x\n",debugstr_a(szPackagePath),
317 debugstr_a(szScriptfilePath), debugstr_a(szTransforms), lgidLanguage);
318 return ERROR_CALL_NOT_IMPLEMENTED;
321 UINT WINAPI MsiAdvertiseProductW(LPCWSTR szPackagePath, LPCWSTR szScriptfilePath,
322 LPCWSTR szTransforms, LANGID lgidLanguage)
324 FIXME("%s %s %s %08x\n",debugstr_w(szPackagePath),
325 debugstr_w(szScriptfilePath), debugstr_w(szTransforms), lgidLanguage);
326 return ERROR_CALL_NOT_IMPLEMENTED;
329 UINT WINAPI MsiAdvertiseProductExA(LPCSTR szPackagePath, LPCSTR szScriptfilePath,
330 LPCSTR szTransforms, LANGID lgidLanguage, DWORD dwPlatform, DWORD dwOptions)
332 FIXME("%s %s %s %08x %08lx %08lx\n", debugstr_a(szPackagePath),
333 debugstr_a(szScriptfilePath), debugstr_a(szTransforms),
334 lgidLanguage, dwPlatform, dwOptions);
335 return ERROR_CALL_NOT_IMPLEMENTED;
338 UINT WINAPI MsiAdvertiseProductExW( LPCWSTR szPackagePath, LPCWSTR szScriptfilePath,
339 LPCWSTR szTransforms, LANGID lgidLanguage, DWORD dwPlatform, DWORD dwOptions)
341 FIXME("%s %s %s %08x %08lx %08lx\n", debugstr_w(szPackagePath),
342 debugstr_w(szScriptfilePath), debugstr_w(szTransforms),
343 lgidLanguage, dwPlatform, dwOptions);
344 return ERROR_CALL_NOT_IMPLEMENTED;
347 UINT WINAPI MsiInstallProductA(LPCSTR szPackagePath, LPCSTR szCommandLine)
349 LPWSTR szwPath = NULL, szwCommand = NULL;
350 UINT r = ERROR_FUNCTION_FAILED; /* FIXME: check return code */
352 TRACE("%s %s\n",debugstr_a(szPackagePath), debugstr_a(szCommandLine));
356 UINT len = MultiByteToWideChar( CP_ACP, 0, szPackagePath, -1, NULL, 0 );
357 szwPath = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
360 MultiByteToWideChar( CP_ACP, 0, szPackagePath, -1, szwPath, len );
365 UINT len = MultiByteToWideChar( CP_ACP, 0, szCommandLine, -1, NULL, 0 );
366 szwCommand = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
369 MultiByteToWideChar( CP_ACP, 0, szCommandLine, -1, szwCommand, len );
372 r = MsiInstallProductW( szwPath, szwCommand );
375 HeapFree( GetProcessHeap(), 0, szwPath );
376 HeapFree( GetProcessHeap(), 0, szwCommand );
381 UINT WINAPI MsiInstallProductW(LPCWSTR szPackagePath, LPCWSTR szCommandLine)
383 MSIPACKAGE *package = NULL;
384 UINT rc = ERROR_SUCCESS;
387 FIXME("%s %s\n",debugstr_w(szPackagePath), debugstr_w(szCommandLine));
389 rc = MsiVerifyPackageW(szPackagePath);
390 if (rc != ERROR_SUCCESS)
393 rc = MSI_OpenPackageW(szPackagePath,&package);
394 if (rc != ERROR_SUCCESS)
397 handle = alloc_msihandle( &package->hdr );
399 rc = ACTION_DoTopLevelINSTALL(package, szPackagePath, szCommandLine);
401 MsiCloseHandle(handle);
402 msiobj_release( &package->hdr );
406 UINT WINAPI MsiReinstallProductA(LPCSTR szProduct, DWORD dwReinstallMode)
408 FIXME("%s %08lx\n", debugstr_a(szProduct), dwReinstallMode);
409 return ERROR_CALL_NOT_IMPLEMENTED;
412 UINT WINAPI MsiReinstallProductW(LPCWSTR szProduct, DWORD dwReinstallMode)
414 FIXME("%s %08lx\n", debugstr_w(szProduct), dwReinstallMode);
415 return ERROR_CALL_NOT_IMPLEMENTED;
418 UINT WINAPI MsiApplyPatchA(LPCSTR szPatchPackage, LPCSTR szInstallPackage,
419 INSTALLTYPE eInstallType, LPCSTR szCommandLine)
421 FIXME("%s %s %d %s\n", debugstr_a(szPatchPackage), debugstr_a(szInstallPackage),
422 eInstallType, debugstr_a(szCommandLine));
423 return ERROR_CALL_NOT_IMPLEMENTED;
426 UINT WINAPI MsiApplyPatchW(LPCWSTR szPatchPackage, LPCWSTR szInstallPackage,
427 INSTALLTYPE eInstallType, LPCWSTR szCommandLine)
429 FIXME("%s %s %d %s\n", debugstr_w(szPatchPackage), debugstr_w(szInstallPackage),
430 eInstallType, debugstr_w(szCommandLine));
431 return ERROR_CALL_NOT_IMPLEMENTED;
434 UINT WINAPI MsiConfigureProductExW(LPCWSTR szProduct, int iInstallLevel,
435 INSTALLSTATE eInstallState, LPCWSTR szCommandLine)
442 static const WCHAR szSouceList[] = {
443 'S','o','u','r','c','e','L','i','s','t',0};
444 static const WCHAR szLUS[] = {
445 'L','a','s','t','U','s','e','d','S','o','u','r','c','e',0};
446 WCHAR sourcepath[0x200];
447 static const WCHAR szInstalled[] = {
448 ' ','I','n','s','t','a','l','l','e','d','=','1',0};
451 FIXME("%s %d %d %s\n",debugstr_w(szProduct), iInstallLevel, eInstallState,
452 debugstr_w(szCommandLine));
454 if (eInstallState != INSTALLSTATE_LOCAL &&
455 eInstallState != INSTALLSTATE_DEFAULT)
457 FIXME("Not implemented for anything other than local installs\n");
458 return ERROR_CALL_NOT_IMPLEMENTED;
461 rc = MSIREG_OpenUserProductsKey(szProduct,&hkey,FALSE);
462 if (rc != ERROR_SUCCESS)
465 rc = RegOpenKeyW(hkey,szSouceList,&hkey1);
466 if (rc != ERROR_SUCCESS)
469 sz = sizeof(sourcepath);
470 rc = RegQueryValueExW(hkey1, szLUS, NULL, NULL,(LPBYTE)sourcepath, &sz);
471 if (rc != ERROR_SUCCESS)
476 * ok 1, we need to find the msi file for this product.
477 * 2, find the source dir for the files
478 * 3, do the configure/install.
479 4, cleanupany runonce entry.
482 rc = MsiOpenProductW(szProduct,&handle);
483 if (rc != ERROR_SUCCESS)
486 package = msihandle2msiinfo(handle, MSIHANDLETYPE_PACKAGE);
488 sz = strlenW(szInstalled);
491 sz += strlenW(szCommandLine);
493 commandline = HeapAlloc(GetProcessHeap(),0,sz * sizeof(WCHAR));
496 strcpyW(commandline,szCommandLine);
500 if (MsiQueryProductStateW(szProduct) != INSTALLSTATE_UNKNOWN)
501 strcatW(commandline,szInstalled);
503 rc = ACTION_DoTopLevelINSTALL(package, sourcepath, commandline);
505 HeapFree(GetProcessHeap(),0,commandline);
512 UINT WINAPI MsiConfigureProductExA(LPCSTR szProduct, int iInstallLevel,
513 INSTALLSTATE eInstallState, LPCSTR szCommandLine)
515 LPWSTR szwProduct = NULL;
516 LPWSTR szwCommandLine = NULL;
517 UINT hr = ERROR_FUNCTION_FAILED;
521 UINT len = MultiByteToWideChar( CP_ACP, 0, szProduct, -1, NULL, 0 );
522 szwProduct = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
525 MultiByteToWideChar( CP_ACP, 0, szProduct, -1, szwProduct, len );
530 UINT len = MultiByteToWideChar( CP_ACP, 0, szCommandLine, -1, NULL, 0 );
531 szwCommandLine= HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
534 MultiByteToWideChar( CP_ACP, 0, szCommandLine, -1, szwCommandLine, len );
537 hr = MsiConfigureProductExW( szwProduct, iInstallLevel, eInstallState,
540 HeapFree( GetProcessHeap(), 0, szwProduct );
541 HeapFree( GetProcessHeap(), 0, szwCommandLine);
546 UINT WINAPI MsiConfigureProductA(LPCSTR szProduct, int iInstallLevel,
547 INSTALLSTATE eInstallState)
549 LPWSTR szwProduct = NULL;
550 UINT hr = ERROR_SUCCESS;
552 FIXME("%s %d %d\n",debugstr_a(szProduct), iInstallLevel, eInstallState);
556 UINT len = MultiByteToWideChar( CP_ACP, 0, szProduct, -1, NULL, 0 );
557 szwProduct = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
560 MultiByteToWideChar( CP_ACP, 0, szProduct, -1, szwProduct, len );
563 hr = MsiConfigureProductW( szwProduct, iInstallLevel, eInstallState );
566 HeapFree( GetProcessHeap(), 0, szwProduct );
571 UINT WINAPI MsiConfigureProductW(LPCWSTR szProduct, int iInstallLevel,
572 INSTALLSTATE eInstallState)
574 FIXME("%s %d %d\n", debugstr_w(szProduct), iInstallLevel, eInstallState);
576 return MsiConfigureProductExW(szProduct, iInstallLevel, eInstallState,
580 UINT WINAPI MsiGetProductCodeA(LPCSTR szComponent, LPSTR szBuffer)
582 LPWSTR szwComponent = NULL;
583 UINT hr = ERROR_INSTALL_FAILURE;
584 WCHAR szwBuffer[GUID_SIZE];
586 FIXME("%s %s\n",debugstr_a(szComponent), debugstr_a(szBuffer));
590 UINT len = MultiByteToWideChar( CP_ACP, 0, szComponent, -1, NULL, 0 );
591 szwComponent = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
594 MultiByteToWideChar( CP_ACP, 0, szComponent, -1, szwComponent, len );
597 return ERROR_INVALID_PARAMETER;
599 hr = MsiGetProductCodeW( szwComponent, szwBuffer );
601 if( ERROR_SUCCESS == hr )
602 WideCharToMultiByte(CP_ACP, 0, szwBuffer, -1, szBuffer, GUID_SIZE, NULL, NULL);
605 HeapFree( GetProcessHeap(), 0, szwComponent );
610 UINT WINAPI MsiGetProductCodeW(LPCWSTR szComponent, LPWSTR szBuffer)
612 FIXME("%s %s\n",debugstr_w(szComponent), debugstr_w(szBuffer));
613 if (NULL == szComponent)
614 return ERROR_INVALID_PARAMETER;
615 return ERROR_CALL_NOT_IMPLEMENTED;
618 UINT WINAPI MsiGetProductInfoA(LPCSTR szProduct, LPCSTR szAttribute,
619 LPSTR szBuffer, DWORD *pcchValueBuf)
621 LPWSTR szwProduct = NULL, szwAttribute = NULL, szwBuffer = NULL;
622 UINT hr = ERROR_INSTALL_FAILURE;
624 FIXME("%s %s %p %p\n",debugstr_a(szProduct), debugstr_a(szAttribute),
625 szBuffer, pcchValueBuf);
627 if( NULL != szBuffer && NULL == pcchValueBuf )
628 return ERROR_INVALID_PARAMETER;
631 UINT len = MultiByteToWideChar( CP_ACP, 0, szProduct, -1, NULL, 0 );
632 szwProduct = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
635 MultiByteToWideChar( CP_ACP, 0, szProduct, -1, szwProduct, len );
638 return ERROR_INVALID_PARAMETER;
642 UINT len = MultiByteToWideChar( CP_ACP, 0, szAttribute, -1, NULL, 0 );
643 szwAttribute = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
646 MultiByteToWideChar( CP_ACP, 0, szAttribute, -1, szwAttribute, len );
650 hr = ERROR_INVALID_PARAMETER;
656 szwBuffer = HeapAlloc( GetProcessHeap(), 0, (*pcchValueBuf) * sizeof(WCHAR) );
661 hr = MsiGetProductInfoW( szwProduct, szwAttribute, szwBuffer, pcchValueBuf );
663 if( ERROR_SUCCESS == hr )
664 WideCharToMultiByte(CP_ACP, 0, szwBuffer, -1, szBuffer, *pcchValueBuf, NULL, NULL);
667 HeapFree( GetProcessHeap(), 0, szwProduct );
668 HeapFree( GetProcessHeap(), 0, szwAttribute );
669 HeapFree( GetProcessHeap(), 0, szwBuffer );
674 UINT WINAPI MsiGetProductInfoW(LPCWSTR szProduct, LPCWSTR szAttribute,
675 LPWSTR szBuffer, DWORD *pcchValueBuf)
680 FIXME("%s %s %p %p\n",debugstr_w(szProduct), debugstr_w(szAttribute),
681 szBuffer, pcchValueBuf);
683 if (NULL != szBuffer && NULL == pcchValueBuf)
684 return ERROR_INVALID_PARAMETER;
685 if (NULL == szProduct || NULL == szAttribute)
686 return ERROR_INVALID_PARAMETER;
688 hr = MsiOpenProductW(szProduct, &hProduct);
689 if (ERROR_SUCCESS != hr)
692 hr = MsiGetPropertyW(hProduct, szAttribute, szBuffer, pcchValueBuf);
693 MsiCloseHandle(hProduct);
697 UINT WINAPI MsiDatabaseImportA(LPCSTR szFolderPath, LPCSTR szFilename)
699 FIXME("%s %s\n",debugstr_a(szFolderPath), debugstr_a(szFilename));
700 return ERROR_CALL_NOT_IMPLEMENTED;
703 UINT WINAPI MsiDatabaseImportW(LPCWSTR szFolderPath, LPCWSTR szFilename)
705 FIXME("%s %s\n",debugstr_w(szFolderPath), debugstr_w(szFilename));
706 return ERROR_CALL_NOT_IMPLEMENTED;
709 UINT WINAPI MsiEnableLogA(DWORD dwLogMode, LPCSTR szLogFile, DWORD attributes)
711 LPWSTR szwLogFile = NULL;
712 UINT hr = ERROR_INSTALL_FAILURE;
714 FIXME("%08lx %s %08lx\n", dwLogMode, debugstr_a(szLogFile), attributes);
718 UINT len = MultiByteToWideChar( CP_ACP, 0, szLogFile, -1, NULL, 0 );
719 szwLogFile = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
722 MultiByteToWideChar( CP_ACP, 0, szLogFile, -1, szwLogFile, len );
725 return ERROR_INVALID_PARAMETER;
727 hr = MsiEnableLogW( dwLogMode, szwLogFile, attributes );
730 HeapFree( GetProcessHeap(), 0, szwLogFile );
735 UINT WINAPI MsiEnableLogW(DWORD dwLogMode, LPCWSTR szLogFile, DWORD attributes)
737 HANDLE file = INVALID_HANDLE_VALUE;
739 TRACE("%08lx %s %08lx\n", dwLogMode, debugstr_w(szLogFile), attributes);
741 strcpyW(gszLogFile,szLogFile);
742 if (!(attributes & INSTALLLOGATTRIBUTES_APPEND))
743 DeleteFileW(szLogFile);
744 file = CreateFileW(szLogFile, GENERIC_WRITE, 0, NULL, OPEN_ALWAYS,
745 FILE_ATTRIBUTE_NORMAL, NULL);
746 if (file != INVALID_HANDLE_VALUE)
749 ERR("Unable to enable log %s\n",debugstr_w(szLogFile));
751 return ERROR_SUCCESS;
754 INSTALLSTATE WINAPI MsiQueryProductStateA(LPCSTR szProduct)
760 len = MultiByteToWideChar(CP_ACP,0,szProduct,-1,NULL,0);
761 szwProduct = HeapAlloc(GetProcessHeap(),0,len*sizeof(WCHAR));
762 MultiByteToWideChar(CP_ACP,0,szProduct,-1,szwProduct,len);
763 rc = MsiQueryProductStateW(szwProduct);
764 HeapFree(GetProcessHeap(),0,szwProduct);
768 INSTALLSTATE WINAPI MsiQueryProductStateW(LPCWSTR szProduct)
771 INSTALLSTATE rrc = INSTALLSTATE_UNKNOWN;
773 static const WCHAR szWindowsInstaller[] = {
774 'W','i','n','d','o','w','s','I','n','s','t','a','l','l','e','r',0 };
777 TRACE("%s\n", debugstr_w(szProduct));
779 rc = MSIREG_OpenUserProductsKey(szProduct,&hkey,FALSE);
780 if (rc != ERROR_SUCCESS)
785 rc = MSIREG_OpenUninstallKey(szProduct,&hkey,FALSE);
786 if (rc != ERROR_SUCCESS)
790 rc = RegQueryValueExW(hkey,szWindowsInstaller,NULL,NULL,(LPVOID)&rrc, &sz);
791 if (rc != ERROR_SUCCESS)
798 rrc = INSTALLSTATE_DEFAULT;
801 FIXME("Unknown install state read from registry (%i)\n",rrc);
802 rrc = INSTALLSTATE_UNKNOWN;
810 INSTALLUILEVEL WINAPI MsiSetInternalUI(INSTALLUILEVEL dwUILevel, HWND *phWnd)
812 INSTALLUILEVEL old = gUILevel;
813 HWND oldwnd = gUIhwnd;
815 TRACE("%08x %p\n", dwUILevel, phWnd);
817 gUILevel = dwUILevel;
826 INSTALLUI_HANDLERA WINAPI MsiSetExternalUIA(INSTALLUI_HANDLERA puiHandler,
827 DWORD dwMessageFilter, LPVOID pvContext)
829 INSTALLUI_HANDLERA prev = gUIHandlerA;
831 TRACE("%p %lx %p\n",puiHandler, dwMessageFilter,pvContext);
832 gUIHandlerA = puiHandler;
833 gUIFilter = dwMessageFilter;
834 gUIContext = pvContext;
839 INSTALLUI_HANDLERW WINAPI MsiSetExternalUIW(INSTALLUI_HANDLERW puiHandler,
840 DWORD dwMessageFilter, LPVOID pvContext)
842 INSTALLUI_HANDLERW prev = gUIHandlerW;
844 TRACE("%p %lx %p\n",puiHandler,dwMessageFilter,pvContext);
845 gUIHandlerW = puiHandler;
846 gUIFilter = dwMessageFilter;
847 gUIContext = pvContext;
852 /******************************************************************
853 * MsiLoadStringW [MSI.@]
855 * Loads a string from MSI's string resources.
859 * handle [I] only -1 is handled currently
860 * id [I] id of the string to be loaded
861 * lpBuffer [O] buffer for the string to be written to
862 * nBufferMax [I] maximum size of the buffer in characters
863 * lang [I] the prefered language for the string
867 * If successful, this function returns the language id of the string loaded
868 * If the function fails, the function returns zero.
872 * The type of the first parameter is unknown. LoadString's prototype
873 * suggests that it might be a module handle. I have made it an MSI handle
874 * for starters, as -1 is an invalid MSI handle, but not an invalid module
875 * handle. Maybe strings can be stored in an MSI database somehow.
877 LANGID WINAPI MsiLoadStringW( MSIHANDLE handle, UINT id, LPWSTR lpBuffer,
878 int nBufferMax, LANGID lang )
885 TRACE("%ld %u %p %d %d\n", handle, id, lpBuffer, nBufferMax, lang);
888 FIXME("don't know how to deal with handle = %08lx\n", handle);
891 lang = GetUserDefaultLangID();
893 hres = FindResourceExW( msi_hInstance, (LPCWSTR) RT_STRING,
897 hResData = LoadResource( msi_hInstance, hres );
900 p = LockResource( hResData );
904 for (i = 0; i < (id&0xf); i++)
908 if( nBufferMax <= len )
911 memcpy( lpBuffer, p+1, len * sizeof(WCHAR));
914 TRACE("found -> %s\n", debugstr_w(lpBuffer));
919 LANGID WINAPI MsiLoadStringA( MSIHANDLE handle, UINT id, LPSTR lpBuffer,
920 int nBufferMax, LANGID lang )
926 bufW = HeapAlloc(GetProcessHeap(), 0, nBufferMax*sizeof(WCHAR));
927 r = MsiLoadStringW(handle, id, bufW, nBufferMax, lang);
930 len = WideCharToMultiByte(CP_ACP, 0, bufW, -1, NULL, 0, NULL, NULL );
931 if( len <= nBufferMax )
932 WideCharToMultiByte( CP_ACP, 0, bufW, -1,
933 lpBuffer, nBufferMax, NULL, NULL );
937 HeapFree(GetProcessHeap(), 0, bufW);
941 INSTALLSTATE WINAPI MsiLocateComponentA(LPCSTR szComponent, LPSTR lpPathBuf,
944 FIXME("%s %p %08lx\n", debugstr_a(szComponent), lpPathBuf, *pcchBuf);
945 return INSTALLSTATE_UNKNOWN;
948 INSTALLSTATE WINAPI MsiLocateComponentW(LPCWSTR szComponent, LPSTR lpPathBuf,
951 FIXME("%s %p %08lx\n", debugstr_w(szComponent), lpPathBuf, *pcchBuf);
952 return INSTALLSTATE_UNKNOWN;
955 UINT WINAPI MsiMessageBoxA(HWND hWnd, LPCSTR lpText, LPCSTR lpCaption, UINT uType,
956 WORD wLanguageId, DWORD f)
958 FIXME("%p %s %s %u %08x %08lx\n",hWnd,debugstr_a(lpText),debugstr_a(lpCaption),
959 uType,wLanguageId,f);
960 return ERROR_CALL_NOT_IMPLEMENTED;
963 UINT WINAPI MsiMessageBoxW(HWND hWnd, LPCWSTR lpText, LPCWSTR lpCaption, UINT uType,
964 WORD wLanguageId, DWORD f)
966 FIXME("%p %s %s %u %08x %08lx\n",hWnd,debugstr_w(lpText),debugstr_w(lpCaption),
967 uType,wLanguageId,f);
968 return ERROR_CALL_NOT_IMPLEMENTED;
971 UINT WINAPI MsiEnumProductsA(DWORD index, LPSTR lpguid)
974 WCHAR szwGuid[GUID_SIZE];
976 TRACE("%ld %p\n",index,lpguid);
978 if (NULL == lpguid) {
979 return ERROR_INVALID_PARAMETER;
981 r = MsiEnumProductsW(index, szwGuid);
982 if( r == ERROR_SUCCESS )
983 WideCharToMultiByte(CP_ACP, 0, szwGuid, -1, lpguid, GUID_SIZE, NULL, NULL);
988 UINT WINAPI MsiEnumProductsW(DWORD index, LPWSTR lpguid)
990 HKEY hkeyFeatures = 0;
994 TRACE("%ld %p\n",index,lpguid);
997 return ERROR_INVALID_PARAMETER;
999 r = MSIREG_OpenFeatures(&hkeyFeatures);
1000 if( r != ERROR_SUCCESS )
1003 r = RegEnumKeyW(hkeyFeatures, index, szKeyName, GUID_SIZE);
1005 unsquash_guid(szKeyName, lpguid);
1010 RegCloseKey(hkeyFeatures);
1015 UINT WINAPI MsiEnumFeaturesA(LPCSTR szProduct, DWORD index,
1016 LPSTR szFeature, LPSTR szParent)
1019 WCHAR szwFeature[GUID_SIZE], szwParent[GUID_SIZE];
1020 LPWSTR szwProduct = NULL;
1022 TRACE("%s %ld %p %p\n",debugstr_a(szProduct),index,szFeature,szParent);
1026 UINT len = MultiByteToWideChar( CP_ACP, 0, szProduct, -1, NULL, 0 );
1027 szwProduct = HeapAlloc( GetProcessHeap(), 0, len * sizeof (WCHAR) );
1029 MultiByteToWideChar( CP_ACP, 0, szProduct, -1, szwProduct, len );
1031 return ERROR_FUNCTION_FAILED;
1034 r = MsiEnumFeaturesW(szwProduct, index, szwFeature, szwParent);
1035 if( r == ERROR_SUCCESS )
1037 WideCharToMultiByte(CP_ACP, 0, szwFeature, -1,
1038 szFeature, GUID_SIZE, NULL, NULL);
1039 WideCharToMultiByte(CP_ACP, 0, szwParent, -1,
1040 szParent, GUID_SIZE, NULL, NULL);
1043 HeapFree( GetProcessHeap(), 0, szwProduct);
1048 UINT WINAPI MsiEnumFeaturesW(LPCWSTR szProduct, DWORD index,
1049 LPWSTR szFeature, LPWSTR szParent)
1051 HKEY hkeyProduct = 0;
1054 TRACE("%s %ld %p %p\n",debugstr_w(szProduct),index,szFeature,szParent);
1056 r = MSIREG_OpenFeaturesKey(szProduct,&hkeyProduct,FALSE);
1057 if( r != ERROR_SUCCESS )
1061 r = RegEnumValueW(hkeyProduct, index, szFeature, &sz, NULL, NULL, NULL, NULL);
1065 RegCloseKey(hkeyProduct);
1070 UINT WINAPI MsiEnumComponentsA(DWORD index, LPSTR lpguid)
1073 WCHAR szwGuid[GUID_SIZE];
1075 TRACE("%ld %p\n",index,lpguid);
1077 r = MsiEnumComponentsW(index, szwGuid);
1078 if( r == ERROR_SUCCESS )
1079 WideCharToMultiByte(CP_ACP, 0, szwGuid, -1, lpguid, GUID_SIZE, NULL, NULL);
1084 UINT WINAPI MsiEnumComponentsW(DWORD index, LPWSTR lpguid)
1086 HKEY hkeyComponents = 0;
1088 WCHAR szKeyName[33];
1090 TRACE("%ld %p\n",index,lpguid);
1092 r = MSIREG_OpenComponents(&hkeyComponents);
1093 if( r != ERROR_SUCCESS )
1096 r = RegEnumKeyW(hkeyComponents, index, szKeyName, GUID_SIZE);
1098 unsquash_guid(szKeyName, lpguid);
1102 if( hkeyComponents )
1103 RegCloseKey(hkeyComponents);
1108 UINT WINAPI MsiEnumClientsA(LPCSTR szComponent, DWORD index, LPSTR szProduct)
1111 WCHAR szwProduct[GUID_SIZE];
1112 LPWSTR szwComponent = NULL;
1114 TRACE("%s %ld %p\n",debugstr_a(szComponent),index,szProduct);
1118 UINT len = MultiByteToWideChar( CP_ACP, 0, szComponent, -1, NULL, 0 );
1119 szwComponent = HeapAlloc( GetProcessHeap(), 0, len * sizeof (WCHAR) );
1121 MultiByteToWideChar( CP_ACP, 0, szComponent, -1, szwComponent, len );
1123 return ERROR_FUNCTION_FAILED;
1126 r = MsiEnumClientsW(szComponent?szwComponent:NULL, index, szwProduct);
1127 if( r == ERROR_SUCCESS )
1129 WideCharToMultiByte(CP_ACP, 0, szwProduct, -1,
1130 szProduct, GUID_SIZE, NULL, NULL);
1133 HeapFree( GetProcessHeap(), 0, szwComponent);
1138 UINT WINAPI MsiEnumClientsW(LPCWSTR szComponent, DWORD index, LPWSTR szProduct)
1142 WCHAR szValName[GUID_SIZE];
1144 TRACE("%s %ld %p\n",debugstr_w(szComponent),index,szProduct);
1146 r = MSIREG_OpenComponentsKey(szComponent,&hkeyComp,FALSE);
1147 if( r != ERROR_SUCCESS )
1151 r = RegEnumValueW(hkeyComp, index, szValName, &sz, NULL, NULL, NULL, NULL);
1152 if( r != ERROR_SUCCESS )
1155 unsquash_guid(szValName, szProduct);
1159 RegCloseKey(hkeyComp);
1164 UINT WINAPI MsiEnumComponentQualifiersA( LPSTR szComponent, DWORD iIndex,
1165 LPSTR lpQualifierBuf, DWORD* pcchQualifierBuf,
1166 LPSTR lpApplicationDataBuf, DWORD* pcchApplicationDataBuf)
1168 FIXME("%s %08lx %p %p %p %p\n", debugstr_a(szComponent), iIndex,
1169 lpQualifierBuf, pcchQualifierBuf, lpApplicationDataBuf,
1170 pcchApplicationDataBuf);
1171 return ERROR_CALL_NOT_IMPLEMENTED;
1174 UINT WINAPI MsiEnumComponentQualifiersW( LPWSTR szComponent, DWORD iIndex,
1175 LPWSTR lpQualifierBuf, DWORD* pcchQualifierBuf,
1176 LPWSTR lpApplicationDataBuf, DWORD* pcchApplicationDataBuf )
1178 FIXME("%s %08lx %p %p %p %p\n", debugstr_w(szComponent), iIndex,
1179 lpQualifierBuf, pcchQualifierBuf, lpApplicationDataBuf,
1180 pcchApplicationDataBuf);
1181 return ERROR_CALL_NOT_IMPLEMENTED;
1184 UINT WINAPI MsiProvideAssemblyA( LPCSTR szAssemblyName, LPCSTR szAppContext,
1185 DWORD dwInstallMode, DWORD dwAssemblyInfo, LPSTR lpPathBuf,
1186 DWORD* pcchPathBuf )
1188 FIXME("%s %s %08lx %08lx %p %p\n", debugstr_a(szAssemblyName),
1189 debugstr_a(szAppContext), dwInstallMode, dwAssemblyInfo, lpPathBuf,
1191 return ERROR_CALL_NOT_IMPLEMENTED;
1194 UINT WINAPI MsiProvideAssemblyW( LPCWSTR szAssemblyName, LPCWSTR szAppContext,
1195 DWORD dwInstallMode, DWORD dwAssemblyInfo, LPWSTR lpPathBuf,
1196 DWORD* pcchPathBuf )
1198 FIXME("%s %s %08lx %08lx %p %p\n", debugstr_w(szAssemblyName),
1199 debugstr_w(szAppContext), dwInstallMode, dwAssemblyInfo, lpPathBuf,
1201 return ERROR_CALL_NOT_IMPLEMENTED;
1204 UINT WINAPI MsiProvideComponentFromDescriptorA( LPCSTR szDescriptor,
1205 LPSTR szPath, DWORD *pcchPath, DWORD *pcchArgs )
1207 FIXME("%s %p %p %p\n", debugstr_a(szDescriptor), szPath, pcchPath, pcchArgs );
1208 return ERROR_CALL_NOT_IMPLEMENTED;
1211 UINT WINAPI MsiProvideComponentFromDescriptorW( LPCWSTR szDescriptor,
1212 LPWSTR szPath, DWORD *pcchPath, DWORD *pcchArgs )
1214 FIXME("%s %p %p %p\n", debugstr_w(szDescriptor), szPath, pcchPath, pcchArgs );
1215 return ERROR_CALL_NOT_IMPLEMENTED;
1218 HRESULT WINAPI MsiGetFileSignatureInformationA( LPCSTR szSignedObjectPath,
1219 DWORD dwFlags, PCCERT_CONTEXT* ppcCertContext, BYTE* pbHashData,
1222 FIXME("%s %08lx %p %p %p\n", debugstr_a(szSignedObjectPath), dwFlags,
1223 ppcCertContext, pbHashData, pcbHashData);
1224 return ERROR_CALL_NOT_IMPLEMENTED;
1227 HRESULT WINAPI MsiGetFileSignatureInformationW( LPCWSTR szSignedObjectPath,
1228 DWORD dwFlags, PCCERT_CONTEXT* ppcCertContext, BYTE* pbHashData,
1231 FIXME("%s %08lx %p %p %p\n", debugstr_w(szSignedObjectPath), dwFlags,
1232 ppcCertContext, pbHashData, pcbHashData);
1233 return ERROR_CALL_NOT_IMPLEMENTED;
1236 UINT WINAPI MsiGetProductPropertyA( MSIHANDLE hProduct, LPCSTR szProperty,
1237 LPSTR szValue, DWORD *pccbValue )
1239 FIXME("%ld %s %p %p\n", hProduct, debugstr_a(szProperty), szValue, pccbValue);
1240 return ERROR_CALL_NOT_IMPLEMENTED;
1243 UINT WINAPI MsiGetProductPropertyW( MSIHANDLE hProduct, LPCWSTR szProperty,
1244 LPWSTR szValue, DWORD *pccbValue )
1246 FIXME("%ld %s %p %p\n", hProduct, debugstr_w(szProperty), szValue, pccbValue);
1247 return ERROR_CALL_NOT_IMPLEMENTED;
1250 UINT WINAPI MsiVerifyPackageA( LPCSTR szPackage )
1253 LPWSTR szPack = NULL;
1255 TRACE("%s\n", debugstr_a(szPackage) );
1259 len = MultiByteToWideChar( CP_ACP, 0, szPackage, -1, NULL, 0 );
1260 szPack = HeapAlloc( GetProcessHeap(), 0, len*sizeof(WCHAR) );
1262 return ERROR_OUTOFMEMORY;
1263 MultiByteToWideChar( CP_ACP, 0, szPackage, -1, szPack, len );
1266 r = MsiVerifyPackageW( szPack );
1268 HeapFree( GetProcessHeap(), 0, szPack );
1273 UINT WINAPI MsiVerifyPackageW( LPCWSTR szPackage )
1278 TRACE("%s\n", debugstr_w(szPackage) );
1280 r = MsiOpenDatabaseW( szPackage, MSIDBOPEN_READONLY, &handle );
1281 MsiCloseHandle( handle );
1286 INSTALLSTATE WINAPI MsiGetComponentPathA(LPCSTR szProduct, LPCSTR szComponent,
1287 LPSTR lpPathBuf, DWORD* pcchBuf)
1289 LPWSTR szwProduct = NULL, szwComponent = NULL, lpwPathBuf= NULL;
1291 UINT len, incoming_len;
1295 len = MultiByteToWideChar( CP_ACP, 0, szProduct, -1, NULL, 0 );
1296 szwProduct= HeapAlloc( GetProcessHeap(), 0, len*sizeof(WCHAR) );
1298 return ERROR_OUTOFMEMORY;
1299 MultiByteToWideChar( CP_ACP, 0, szProduct, -1, szwProduct, len );
1304 len = MultiByteToWideChar( CP_ACP, 0, szComponent, -1, NULL, 0 );
1305 szwComponent= HeapAlloc( GetProcessHeap(), 0, len*sizeof(WCHAR) );
1308 HeapFree( GetProcessHeap(), 0, szwProduct);
1309 return ERROR_OUTOFMEMORY;
1311 MultiByteToWideChar( CP_ACP, 0, szComponent, -1, szwComponent, len );
1314 if( pcchBuf && *pcchBuf > 0 )
1315 lpwPathBuf = HeapAlloc( GetProcessHeap(), 0, *pcchBuf * sizeof(WCHAR));
1319 incoming_len = *pcchBuf;
1320 rc = MsiGetComponentPathW(szwProduct, szwComponent, lpwPathBuf, pcchBuf);
1322 HeapFree( GetProcessHeap(), 0, szwProduct);
1323 HeapFree( GetProcessHeap(), 0, szwComponent);
1326 if (rc != INSTALLSTATE_UNKNOWN)
1327 WideCharToMultiByte(CP_ACP, 0, lpwPathBuf, incoming_len,
1328 lpPathBuf, incoming_len, NULL, NULL);
1329 HeapFree( GetProcessHeap(), 0, lpwPathBuf);
1335 INSTALLSTATE WINAPI MsiGetComponentPathW(LPCWSTR szProduct, LPCWSTR szComponent,
1336 LPWSTR lpPathBuf, DWORD* pcchBuf)
1338 WCHAR squished_pc[GUID_SIZE];
1340 INSTALLSTATE rrc = INSTALLSTATE_UNKNOWN;
1343 TRACE("%s %s %p %p\n", debugstr_w(szProduct),
1344 debugstr_w(szComponent), lpPathBuf, pcchBuf);
1346 squash_guid(szProduct,squished_pc);
1348 rc = MSIREG_OpenProductsKey(szProduct,&hkey,FALSE);
1349 if (rc != ERROR_SUCCESS)
1354 rc = MSIREG_OpenComponentsKey(szComponent,&hkey,FALSE);
1355 if (rc != ERROR_SUCCESS)
1358 *pcchBuf *= sizeof(WCHAR);
1359 rc = RegQueryValueExW(hkey,squished_pc,NULL,NULL,(LPVOID)lpPathBuf,
1361 *pcchBuf /= sizeof(WCHAR);
1363 if (rc!= ERROR_SUCCESS)
1366 TRACE("found path of (%s:%s)(%s)\n", debugstr_w(szComponent),
1367 debugstr_w(szProduct), debugstr_w(lpPathBuf));
1369 FIXME("Only working for installed files, not registry keys\n");
1370 if (GetFileAttributesW(lpPathBuf) != INVALID_FILE_ATTRIBUTES)
1371 rrc = INSTALLSTATE_LOCAL;
1373 rrc = INSTALLSTATE_ABSENT;
1380 INSTALLSTATE WINAPI MsiQueryFeatureStateA(LPCSTR szProduct, LPCSTR szFeature)
1384 LPWSTR szwProduct= NULL;
1385 LPWSTR szwFeature= NULL;
1389 len = MultiByteToWideChar( CP_ACP, 0, szProduct, -1, NULL, 0 );
1390 szwProduct= HeapAlloc( GetProcessHeap(), 0, len*sizeof(WCHAR) );
1392 return ERROR_OUTOFMEMORY;
1393 MultiByteToWideChar( CP_ACP, 0, szProduct, -1, szwProduct, len );
1398 len = MultiByteToWideChar( CP_ACP, 0, szFeature, -1, NULL, 0 );
1399 szwFeature= HeapAlloc( GetProcessHeap(), 0, len*sizeof(WCHAR) );
1402 HeapFree( GetProcessHeap(), 0, szwProduct);
1403 return ERROR_OUTOFMEMORY;
1405 MultiByteToWideChar( CP_ACP, 0, szFeature, -1, szwFeature, len );
1408 rc = MsiQueryFeatureStateW(szwProduct, szwFeature);
1410 HeapFree( GetProcessHeap(), 0, szwProduct);
1411 HeapFree( GetProcessHeap(), 0, szwFeature);
1416 INSTALLSTATE WINAPI MsiQueryFeatureStateW(LPCWSTR szProduct, LPCWSTR szFeature)
1418 FIXME("%s %s\n", debugstr_w(szProduct), debugstr_w(szFeature));
1419 return INSTALLSTATE_UNKNOWN;
1422 UINT WINAPI MsiGetFileVersionA(LPCSTR szFilePath, LPSTR lpVersionBuf,
1423 DWORD* pcchVersionBuf, LPSTR lpLangBuf, DWORD* pcchLangBuf)
1425 LPWSTR szwFilePath = NULL, lpwVersionBuff = NULL, lpwLangBuff = NULL;
1426 UINT len, ret = ERROR_OUTOFMEMORY;
1430 len = MultiByteToWideChar( CP_ACP, 0, szFilePath, -1, NULL, 0 );
1431 szwFilePath = HeapAlloc( GetProcessHeap(), 0, len*sizeof(WCHAR) );
1434 MultiByteToWideChar( CP_ACP, 0, szFilePath, -1, szwFilePath, len );
1437 if( lpVersionBuf && pcchVersionBuf && *pcchVersionBuf )
1439 lpwVersionBuff = HeapAlloc(GetProcessHeap(), 0, *pcchVersionBuf*sizeof(WCHAR));
1440 if( !lpwVersionBuff )
1444 if( lpLangBuf && pcchLangBuf && *pcchLangBuf )
1446 lpwLangBuff = HeapAlloc(GetProcessHeap(), 0, *pcchVersionBuf*sizeof(WCHAR));
1451 ret = MsiGetFileVersionW(szwFilePath, lpwVersionBuff, pcchVersionBuf,
1452 lpwLangBuff, pcchLangBuf);
1454 if( lpwVersionBuff )
1455 WideCharToMultiByte(CP_ACP, 0, lpwVersionBuff, -1,
1456 lpVersionBuf, *pcchVersionBuf, NULL, NULL);
1458 WideCharToMultiByte(CP_ACP, 0, lpwLangBuff, -1,
1459 lpLangBuf, *pcchLangBuf, NULL, NULL);
1462 HeapFree(GetProcessHeap(), 0, szwFilePath);
1463 HeapFree(GetProcessHeap(), 0, lpwVersionBuff);
1464 HeapFree(GetProcessHeap(), 0, lpwLangBuff);
1469 UINT WINAPI MsiGetFileVersionW(LPCWSTR szFilePath, LPWSTR lpVersionBuf,
1470 DWORD* pcchVersionBuf, LPWSTR lpLangBuf, DWORD* pcchLangBuf)
1472 static const WCHAR szVersionResource[] = {'\\',0};
1473 static const WCHAR szVersionFormat[] = {
1474 '%','d','.','%','d','.','%','d','.','%','d',0};
1475 static const WCHAR szLangFormat[] = {'%','d',0};
1478 LPVOID lpVer = NULL;
1479 VS_FIXEDFILEINFO *ffi;
1483 TRACE("%s %p %ld %p %ld\n", debugstr_w(szFilePath),
1484 lpVersionBuf, pcchVersionBuf?*pcchVersionBuf:0,
1485 lpLangBuf, pcchLangBuf?*pcchLangBuf:0);
1487 dwVerLen = GetFileVersionInfoSizeW(szFilePath, NULL);
1489 return GetLastError();
1491 lpVer = HeapAlloc(GetProcessHeap(), 0, dwVerLen);
1494 ret = ERROR_OUTOFMEMORY;
1498 if( !GetFileVersionInfoW(szFilePath, 0, dwVerLen, lpVer) )
1500 ret = GetLastError();
1503 if( lpVersionBuf && pcchVersionBuf && *pcchVersionBuf )
1505 if( VerQueryValueW(lpVer, szVersionResource, (LPVOID*)&ffi, &puLen) &&
1508 wsprintfW(tmp, szVersionFormat,
1509 HIWORD(ffi->dwFileVersionMS), LOWORD(ffi->dwFileVersionMS),
1510 HIWORD(ffi->dwFileVersionLS), LOWORD(ffi->dwFileVersionLS));
1511 lstrcpynW(lpVersionBuf, tmp, *pcchVersionBuf);
1512 *pcchVersionBuf = strlenW(lpVersionBuf);
1517 *pcchVersionBuf = 0;
1521 if( lpLangBuf && pcchLangBuf && *pcchLangBuf )
1523 DWORD lang = GetUserDefaultLangID();
1525 FIXME("Retrieve language from file\n");
1526 wsprintfW(tmp, szLangFormat, lang);
1527 lstrcpynW(lpLangBuf, tmp, *pcchLangBuf);
1528 *pcchLangBuf = strlenW(lpLangBuf);
1532 HeapFree(GetProcessHeap(), 0, lpVer);
1537 /******************************************************************
1540 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
1544 case DLL_PROCESS_ATTACH:
1545 msi_hInstance = hinstDLL;
1546 DisableThreadLibraryCalls(hinstDLL);
1547 msi_dialog_register_class();
1549 case DLL_PROCESS_DETACH:
1550 msi_dialog_unregister_class();
1551 /* FIXME: Cleanup */
1557 typedef struct tagIClassFactoryImpl
1559 IClassFactoryVtbl *lpVtbl;
1560 } IClassFactoryImpl;
1562 static HRESULT WINAPI MsiCF_QueryInterface(LPCLASSFACTORY iface,
1563 REFIID riid,LPVOID *ppobj)
1565 IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
1566 FIXME("%p %s %p\n",This,debugstr_guid(riid),ppobj);
1567 return E_NOINTERFACE;
1570 static ULONG WINAPI MsiCF_AddRef(LPCLASSFACTORY iface)
1575 static ULONG WINAPI MsiCF_Release(LPCLASSFACTORY iface)
1580 static HRESULT WINAPI MsiCF_CreateInstance(LPCLASSFACTORY iface,
1581 LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj)
1583 IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
1585 FIXME("%p %p %s %p\n", This, pOuter, debugstr_guid(riid), ppobj);
1589 static HRESULT WINAPI MsiCF_LockServer(LPCLASSFACTORY iface, BOOL dolock)
1591 IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
1593 FIXME("%p %d\n", This, dolock);
1597 static IClassFactoryVtbl MsiCF_Vtbl =
1599 MsiCF_QueryInterface,
1602 MsiCF_CreateInstance,
1606 static IClassFactoryImpl Msi_CF = { &MsiCF_Vtbl };
1608 /******************************************************************
1609 * DllGetClassObject [MSI.@]
1611 HRESULT WINAPI MSI_DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
1613 TRACE("%s %s %p\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
1615 if( IsEqualCLSID (rclsid, &CLSID_IMsiServer) ||
1616 IsEqualCLSID (rclsid, &CLSID_IMsiServerMessage) ||
1617 IsEqualCLSID (rclsid, &CLSID_IMsiServerX1) ||
1618 IsEqualCLSID (rclsid, &CLSID_IMsiServerX2) ||
1619 IsEqualCLSID (rclsid, &CLSID_IMsiServerX3) )
1621 *ppv = (LPVOID) &Msi_CF;
1624 return CLASS_E_CLASSNOTAVAILABLE;
1627 /******************************************************************
1628 * DllGetVersion [MSI.@]
1630 HRESULT WINAPI MSI_DllGetVersion(DLLVERSIONINFO *pdvi)
1634 if (pdvi->cbSize != sizeof(DLLVERSIONINFO))
1635 return E_INVALIDARG;
1637 pdvi->dwMajorVersion = MSI_MAJORVERSION;
1638 pdvi->dwMinorVersion = MSI_MINORVERSION;
1639 pdvi->dwBuildNumber = MSI_BUILDNUMBER;
1640 pdvi->dwPlatformID = 1;
1645 /******************************************************************
1646 * DllCanUnloadNow [MSI.@]
1648 BOOL WINAPI MSI_DllCanUnloadNow(void)
1653 UINT WINAPI MsiEnumRelatedProductsW(LPCWSTR szUpgradeCode, DWORD dwReserved,
1654 DWORD iProductIndex, LPWSTR lpProductBuf)
1656 FIXME("%s %lu %lu %p\n", debugstr_w(szUpgradeCode), dwReserved,
1657 iProductIndex, lpProductBuf);
1658 return ERROR_CALL_NOT_IMPLEMENTED;
1661 UINT WINAPI MsiEnumRelatedProductsA(LPCSTR szUpgradeCode, DWORD dwReserved,
1662 DWORD iProductIndex, LPSTR lpProductBuf)
1664 FIXME("%s %lu %lu %p\n", debugstr_a(szUpgradeCode), dwReserved,
1665 iProductIndex, lpProductBuf);
1666 return ERROR_CALL_NOT_IMPLEMENTED;
1669 UINT WINAPI MsiGetFeatureUsageW(LPCWSTR szProduct, LPCWSTR szFeature,
1670 DWORD* pdwUseCount, WORD* pwDateUsed)
1672 FIXME("%s %s %p %p\n",debugstr_w(szProduct), debugstr_w(szFeature),
1673 pdwUseCount, pwDateUsed);
1674 return ERROR_CALL_NOT_IMPLEMENTED;
1677 UINT WINAPI MsiGetFeatureUsageA(LPCSTR szProduct, LPCSTR szFeature,
1678 DWORD* pdwUseCount, WORD* pwDateUsed)
1680 FIXME("%s %s %p %p\n", debugstr_a(szProduct), debugstr_a(szFeature),
1681 pdwUseCount, pwDateUsed);
1682 return ERROR_CALL_NOT_IMPLEMENTED;
1685 UINT WINAPI MsiUseFeatureExW(LPCWSTR szProduct, LPCWSTR szFeature,
1686 DWORD dwInstallMode, DWORD dwReserved)
1688 FIXME("%s %s %li %li\n", debugstr_w(szProduct), debugstr_w(szFeature),
1689 dwInstallMode, dwReserved);
1691 return INSTALLSTATE_LOCAL;
1694 UINT WINAPI MsiProvideQualifiedComponentExW(LPCWSTR szComponent,
1695 LPCWSTR szQualifier, DWORD dwInstallMode, LPWSTR szProduct,
1696 DWORD Unused1, DWORD Unused2, LPWSTR lpPathBuf,
1699 FIXME("%s %s %li %s %li %li %p %p\n", debugstr_w(szComponent),
1700 debugstr_w(szQualifier), dwInstallMode, debugstr_w(szProduct),
1701 Unused1, Unused2, lpPathBuf, pcchPathBuf);
1703 return ERROR_INDEX_ABSENT;
1706 UINT WINAPI MsiGetUserInfoW(LPCWSTR szProduct, LPWSTR lpUserNameBuf,
1707 DWORD* pcchUserNameBuf, LPWSTR lpOrgNameBuf,
1708 DWORD* pcchOrgNameBuf, LPWSTR lpSerialBuf, DWORD* pcchSerialBuf)
1710 FIXME("%s, %p %p %p %p %p %p\n",debugstr_w(szProduct), lpUserNameBuf,
1711 pcchUserNameBuf, lpOrgNameBuf, pcchOrgNameBuf, lpSerialBuf,
1714 return USERINFOSTATE_UNKNOWN;
1717 UINT WINAPI MsiCollectUserInfoW(LPCWSTR szProduct)
1719 FIXME("%s\n",debugstr_w(szProduct));
1720 return ERROR_CALL_NOT_IMPLEMENTED;
1723 UINT WINAPI MsiCollectUserInfoA(LPCSTR szProduct)
1725 FIXME("%s\n",debugstr_a(szProduct));
1726 return ERROR_CALL_NOT_IMPLEMENTED;
1729 UINT WINAPI MsiCreateAndVerifyInstallerDirectory(void)
1732 return ERROR_CALL_NOT_IMPLEMENTED;