Split out database functions, remove dependence on wine/unicode.h.

This commit is contained in:
Mike McCormack 2005-03-29 11:28:57 +00:00 committed by Alexandre Julliard
parent e732fc023d
commit 180f04059b
3 changed files with 435 additions and 306 deletions

View File

@ -11,6 +11,7 @@ C_SRCS = \
appsearch.c \
create.c \
custom.c \
database.c \
delete.c \
dialog.c \
distinct.c \

345
dlls/msi/database.c Normal file
View File

@ -0,0 +1,345 @@
/*
* Implementation of the Microsoft Installer (msi.dll)
*
* Copyright 2002,2003,2004,2005 Mike McCormack for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <stdarg.h>
#define COBJMACROS
#define NONAMELESSUNION
#include "windef.h"
#include "winbase.h"
#include "winreg.h"
#include "winnls.h"
#include "wine/debug.h"
#include "msi.h"
#include "msiquery.h"
#include "msipriv.h"
#include "objidl.h"
#include "objbase.h"
#include "initguid.h"
WINE_DEFAULT_DEBUG_CHANNEL(msi);
/*
* The MSVC headers define the MSIDBOPEN_* macros cast to LPCTSTR,
* which is a problem because LPCTSTR isn't defined when compiling wine.
* To work around this problem, we need to define LPCTSTR as LPCWSTR here,
* and make sure to only use it in W functions.
*/
#define LPCTSTR LPCWSTR
DEFINE_GUID( CLSID_MsiDatabase, 0x000c1084, 0x0000, 0x0000,
0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
/*
* .MSI file format
*
* An .msi file is a structured storage file.
* It contains a number of streams.
* A stream for each table in the database.
* Two streams for the string table in the database.
* Any binary data in a table is a reference to a stream.
*/
VOID MSI_CloseDatabase( MSIOBJECTHDR *arg )
{
MSIDATABASE *db = (MSIDATABASE *) arg;
DWORD r;
free_cached_tables( db );
r = IStorage_Release( db->storage );
if( r )
ERR("database reference count was not zero (%ld)\n", r);
}
UINT MSI_OpenDatabaseW(LPCWSTR szDBPath, LPCWSTR szPersist, MSIDATABASE **pdb)
{
IStorage *stg = NULL;
HRESULT r;
MSIDATABASE *db = NULL;
UINT ret = ERROR_FUNCTION_FAILED;
LPWSTR szMode;
STATSTG stat;
TRACE("%s %s\n",debugstr_w(szDBPath),debugstr_w(szPersist) );
if( !pdb )
return ERROR_INVALID_PARAMETER;
szMode = (LPWSTR) szPersist;
if( HIWORD( szPersist ) )
{
/* UINT len = lstrlenW( szPerist ) + 1; */
FIXME("don't support persist files yet\b");
return ERROR_INVALID_PARAMETER;
/* szMode = HeapAlloc( GetProcessHeap(), 0, len * sizeof (DWORD) ); */
}
else if( szPersist == MSIDBOPEN_READONLY )
{
r = StgOpenStorage( szDBPath, NULL,
STGM_DIRECT|STGM_READ|STGM_SHARE_DENY_WRITE, NULL, 0, &stg);
}
else if( szPersist == MSIDBOPEN_CREATE )
{
r = StgCreateDocfile( szDBPath,
STGM_DIRECT|STGM_READWRITE|STGM_SHARE_EXCLUSIVE, 0, &stg);
if( r == ERROR_SUCCESS )
{
IStorage_SetClass( stg, &CLSID_MsiDatabase );
r = init_string_table( stg );
}
}
else if( szPersist == MSIDBOPEN_TRANSACT )
{
r = StgOpenStorage( szDBPath, NULL,
STGM_DIRECT|STGM_READWRITE|STGM_SHARE_EXCLUSIVE, NULL, 0, &stg);
}
else
{
ERR("unknown flag %p\n",szPersist);
return ERROR_INVALID_PARAMETER;
}
if( FAILED( r ) )
{
FIXME("open failed r = %08lx!\n",r);
return ERROR_FUNCTION_FAILED;
}
r = IStorage_Stat( stg, &stat, STATFLAG_NONAME );
if( FAILED( r ) )
{
FIXME("Failed to stat storage\n");
goto end;
}
if( memcmp( &stat.clsid, &CLSID_MsiDatabase, sizeof (GUID) ) )
{
ERR("storage GUID is not a MSI database GUID %s\n",
debugstr_guid(&stat.clsid) );
goto end;
}
db = alloc_msiobject( MSIHANDLETYPE_DATABASE, sizeof (MSIDATABASE),
MSI_CloseDatabase );
if( !db )
{
FIXME("Failed to allocate a handle\n");
goto end;
}
if( TRACE_ON( msi ) )
enum_stream_names( stg );
db->storage = stg;
db->mode = szMode;
ret = load_string_table( db );
if( ret != ERROR_SUCCESS )
goto end;
msiobj_addref( &db->hdr );
IStorage_AddRef( stg );
*pdb = db;
end:
if( db )
msiobj_release( &db->hdr );
if( stg )
IStorage_Release( stg );
return ret;
}
UINT WINAPI MsiOpenDatabaseW(LPCWSTR szDBPath, LPCWSTR szPersist, MSIHANDLE *phDB)
{
MSIDATABASE *db;
UINT ret;
TRACE("%s %s %p\n",debugstr_w(szDBPath),debugstr_w(szPersist), phDB);
ret = MSI_OpenDatabaseW( szDBPath, szPersist, &db );
if( ret == ERROR_SUCCESS )
{
*phDB = alloc_msihandle( &db->hdr );
msiobj_release( &db->hdr );
}
return ret;
}
UINT WINAPI MsiOpenDatabaseA(LPCSTR szDBPath, LPCSTR szPersist, MSIHANDLE *phDB)
{
HRESULT r = ERROR_FUNCTION_FAILED;
LPWSTR szwDBPath = NULL, szwPersist = NULL;
TRACE("%s %s %p\n", debugstr_a(szDBPath), debugstr_a(szPersist), phDB);
if( szDBPath )
{
szwDBPath = strdupAtoW( szDBPath );
if( !szwDBPath )
goto end;
}
if( HIWORD(szPersist) )
{
szwPersist = strdupAtoW( szPersist );
if( !szwPersist )
goto end;
}
else
szwPersist = (LPWSTR) szPersist;
r = MsiOpenDatabaseW( szwDBPath, szwPersist, phDB );
end:
HeapFree( GetProcessHeap(), 0, szwPersist );
HeapFree( GetProcessHeap(), 0, szwDBPath );
return r;
}
UINT MSI_DatabaseImport( MSIDATABASE *db, LPCWSTR folder, LPCWSTR file )
{
FIXME("%p %s %s\n", db, debugstr_w(folder), debugstr_w(file) );
if( folder == NULL || file == NULL )
return ERROR_INVALID_PARAMETER;
return ERROR_CALL_NOT_IMPLEMENTED;
}
UINT WINAPI MsiDatabaseImportW(MSIHANDLE handle, LPCWSTR szFolder, LPCWSTR szFilename)
{
MSIDATABASE *db;
UINT r;
TRACE("%lx %s %s\n",handle,debugstr_w(szFolder), debugstr_w(szFilename));
db = msihandle2msiinfo( handle, MSIHANDLETYPE_DATABASE );
if( !db )
return ERROR_INVALID_HANDLE;
r = MSI_DatabaseImport( db, szFolder, szFilename );
msiobj_release( &db->hdr );
return r;
}
UINT WINAPI MsiDatabaseImportA( MSIHANDLE handle,
LPCSTR szFolder, LPCSTR szFilename )
{
LPWSTR path = NULL, file = NULL;
UINT r = ERROR_OUTOFMEMORY;
TRACE("%lx %s %s\n", handle, debugstr_a(szFolder), debugstr_a(szFilename));
if( szFolder )
{
path = strdupAtoW( szFolder );
if( !path )
goto end;
}
if( szFilename )
{
file = strdupAtoW( szFilename );
if( !file )
goto end;
}
r = MsiDatabaseImportW( handle, path, file );
end:
HeapFree( GetProcessHeap(), 0, path );
HeapFree( GetProcessHeap(), 0, file );
return r;
}
UINT MSI_DatabaseExport( MSIDATABASE *db, LPCWSTR table,
LPCWSTR folder, LPCWSTR file )
{
FIXME("%p %s %s %s\n", db, debugstr_w(table),
debugstr_w(folder), debugstr_w(file) );
if( folder == NULL || file == NULL )
return ERROR_INVALID_PARAMETER;
return ERROR_CALL_NOT_IMPLEMENTED;
}
UINT WINAPI MsiDatabaseExportW( MSIHANDLE handle, LPCWSTR szTable,
LPCWSTR szFolder, LPCWSTR szFilename )
{
MSIDATABASE *db;
UINT r;
TRACE("%lx %s %s %s\n", handle, debugstr_w(szTable),
debugstr_w(szFolder), debugstr_w(szFilename));
db = msihandle2msiinfo( handle, MSIHANDLETYPE_DATABASE );
if( !db )
return ERROR_INVALID_HANDLE;
r = MSI_DatabaseExport( db, szTable, szFolder, szFilename );
msiobj_release( &db->hdr );
return r;
}
UINT WINAPI MsiDatabaseExportA( MSIHANDLE handle, LPCSTR szTable,
LPCSTR szFolder, LPCSTR szFilename )
{
LPWSTR path = NULL, file = NULL, table = NULL;
UINT r = ERROR_OUTOFMEMORY;
TRACE("%lx %s %s %s\n", handle, debugstr_a(szTable),
debugstr_a(szFolder), debugstr_a(szFilename));
if( szTable )
{
table = strdupAtoW( szTable );
if( !table )
goto end;
}
if( szFolder )
{
path = strdupAtoW( szFolder );
if( !path )
goto end;
}
if( szFilename )
{
file = strdupAtoW( szFilename );
if( !file )
goto end;
}
r = MsiDatabaseImportW( handle, path, file );
end:
HeapFree( GetProcessHeap(), 0, table );
HeapFree( GetProcessHeap(), 0, path );
HeapFree( GetProcessHeap(), 0, file );
return r;
}

View File

@ -32,15 +32,10 @@
#include "msi.h"
#include "msiquery.h"
#include "msipriv.h"
#include "objidl.h"
#include "wincrypt.h"
#include "wine/unicode.h"
#include "objbase.h"
#include "winver.h"
#include "winuser.h"
#include "initguid.h"
WINE_DEFAULT_DEBUG_CHANNEL(msi);
/*
@ -51,9 +46,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(msi);
*/
#define LPCTSTR LPCWSTR
DEFINE_GUID( CLSID_MsiDatabase, 0x000c1084, 0x0000, 0x0000,
0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
/* the UI level */
INSTALLUILEVEL gUILevel = INSTALLUILEVEL_BASIC;
HWND gUIhwnd = 0;
@ -64,176 +56,9 @@ LPVOID gUIContext = NULL;
WCHAR gszLogFile[MAX_PATH];
HINSTANCE msi_hInstance;
/*
* .MSI file format
*
* A .msi file is a structured storage file.
* It should contain a number of streams.
*/
VOID MSI_CloseDatabase( MSIOBJECTHDR *arg )
{
MSIDATABASE *db = (MSIDATABASE *) arg;
DWORD r;
free_cached_tables( db );
r = IStorage_Release( db->storage );
if( r )
ERR("database reference count was not zero (%ld)\n", r);
}
UINT MSI_OpenDatabaseW(LPCWSTR szDBPath, LPCWSTR szPersist, MSIDATABASE **pdb)
{
IStorage *stg = NULL;
HRESULT r;
MSIDATABASE *db = NULL;
UINT ret = ERROR_FUNCTION_FAILED;
LPWSTR szMode;
STATSTG stat;
TRACE("%s %s\n",debugstr_w(szDBPath),debugstr_w(szPersist) );
if( !pdb )
return ERROR_INVALID_PARAMETER;
szMode = (LPWSTR) szPersist;
if( HIWORD( szPersist ) )
{
/* UINT len = lstrlenW( szPerist ) + 1; */
FIXME("don't support persist files yet\b");
return ERROR_INVALID_PARAMETER;
/* szMode = HeapAlloc( GetProcessHeap(), 0, len * sizeof (DWORD) ); */
}
else if( szPersist == MSIDBOPEN_READONLY )
{
r = StgOpenStorage( szDBPath, NULL,
STGM_DIRECT|STGM_READ|STGM_SHARE_DENY_WRITE, NULL, 0, &stg);
}
else if( szPersist == MSIDBOPEN_CREATE )
{
r = StgCreateDocfile( szDBPath,
STGM_DIRECT|STGM_READWRITE|STGM_SHARE_EXCLUSIVE, 0, &stg);
if( r == ERROR_SUCCESS )
{
IStorage_SetClass( stg, &CLSID_MsiDatabase );
r = init_string_table( stg );
}
}
else if( szPersist == MSIDBOPEN_TRANSACT )
{
r = StgOpenStorage( szDBPath, NULL,
STGM_DIRECT|STGM_READWRITE|STGM_SHARE_EXCLUSIVE, NULL, 0, &stg);
}
else
{
ERR("unknown flag %p\n",szPersist);
return ERROR_INVALID_PARAMETER;
}
if( FAILED( r ) )
{
FIXME("open failed r = %08lx!\n",r);
return ERROR_FUNCTION_FAILED;
}
r = IStorage_Stat( stg, &stat, STATFLAG_NONAME );
if( FAILED( r ) )
{
FIXME("Failed to stat storage\n");
goto end;
}
if( memcmp( &stat.clsid, &CLSID_MsiDatabase, sizeof (GUID) ) )
{
ERR("storage GUID is not a MSI database GUID %s\n",
debugstr_guid(&stat.clsid) );
goto end;
}
db = alloc_msiobject( MSIHANDLETYPE_DATABASE, sizeof (MSIDATABASE),
MSI_CloseDatabase );
if( !db )
{
FIXME("Failed to allocate a handle\n");
goto end;
}
if( TRACE_ON( msi ) )
enum_stream_names( stg );
db->storage = stg;
db->mode = szMode;
ret = load_string_table( db );
if( ret != ERROR_SUCCESS )
goto end;
msiobj_addref( &db->hdr );
IStorage_AddRef( stg );
*pdb = db;
end:
if( db )
msiobj_release( &db->hdr );
if( stg )
IStorage_Release( stg );
return ret;
}
UINT WINAPI MsiOpenDatabaseW(LPCWSTR szDBPath, LPCWSTR szPersist, MSIHANDLE *phDB)
{
MSIDATABASE *db;
UINT ret;
TRACE("%s %s %p\n",debugstr_w(szDBPath),debugstr_w(szPersist), phDB);
ret = MSI_OpenDatabaseW( szDBPath, szPersist, &db );
if( ret == ERROR_SUCCESS )
{
*phDB = alloc_msihandle( &db->hdr );
msiobj_release( &db->hdr );
}
return ret;
}
UINT WINAPI MsiOpenDatabaseA(LPCSTR szDBPath, LPCSTR szPersist, MSIHANDLE *phDB)
{
HRESULT r = ERROR_FUNCTION_FAILED;
LPWSTR szwDBPath = NULL, szwPersist = NULL;
TRACE("%s %s %p\n", debugstr_a(szDBPath), debugstr_a(szPersist), phDB);
if( szDBPath )
{
szwDBPath = strdupAtoW( szDBPath );
if( !szwDBPath )
goto end;
}
if( HIWORD(szPersist) )
{
szwPersist = strdupAtoW( szPersist );
if( !szwPersist )
goto end;
}
else
szwPersist = (LPWSTR) szPersist;
r = MsiOpenDatabaseW( szwDBPath, szwPersist, phDB );
end:
HeapFree( GetProcessHeap(), 0, szwPersist );
HeapFree( GetProcessHeap(), 0, szwDBPath );
return r;
}
UINT WINAPI MsiOpenProductA(LPCSTR szProduct, MSIHANDLE *phProduct)
{
UINT ret;
UINT r;
LPWSTR szwProd = NULL;
TRACE("%s %p\n",debugstr_a(szProduct), phProduct);
@ -245,11 +70,11 @@ UINT WINAPI MsiOpenProductA(LPCSTR szProduct, MSIHANDLE *phProduct)
return ERROR_OUTOFMEMORY;
}
ret = MsiOpenProductW( szwProd, phProduct );
r = MsiOpenProductW( szwProd, phProduct );
HeapFree( GetProcessHeap(), 0, szwProd );
return ret;
return r;
}
UINT WINAPI MsiOpenProductW(LPCWSTR szProduct, MSIHANDLE *phProduct)
@ -341,7 +166,7 @@ UINT WINAPI MsiAdvertiseProductExW( LPCWSTR szPackagePath, LPCWSTR szScriptfileP
UINT WINAPI MsiInstallProductA(LPCSTR szPackagePath, LPCSTR szCommandLine)
{
LPWSTR szwPath = NULL, szwCommand = NULL;
UINT r = ERROR_FUNCTION_FAILED; /* FIXME: check return code */
UINT r = ERROR_OUTOFMEMORY;
TRACE("%s %s\n",debugstr_a(szPackagePath), debugstr_a(szCommandLine));
@ -358,7 +183,7 @@ UINT WINAPI MsiInstallProductA(LPCSTR szPackagePath, LPCSTR szCommandLine)
if( !szwCommand )
goto end;
}
r = MsiInstallProductW( szwPath, szwCommand );
end:
@ -371,26 +196,26 @@ end:
UINT WINAPI MsiInstallProductW(LPCWSTR szPackagePath, LPCWSTR szCommandLine)
{
MSIPACKAGE *package = NULL;
UINT rc = ERROR_SUCCESS;
UINT r;
MSIHANDLE handle;
FIXME("%s %s\n",debugstr_w(szPackagePath), debugstr_w(szCommandLine));
rc = MsiVerifyPackageW(szPackagePath);
if (rc != ERROR_SUCCESS)
return rc;
r = MsiVerifyPackageW(szPackagePath);
if (r != ERROR_SUCCESS)
return r;
rc = MSI_OpenPackageW(szPackagePath,&package);
if (rc != ERROR_SUCCESS)
return rc;
r = MSI_OpenPackageW(szPackagePath,&package);
if (r != ERROR_SUCCESS)
return r;
handle = alloc_msihandle( &package->hdr );
rc = ACTION_DoTopLevelINSTALL(package, szPackagePath, szCommandLine);
r = ACTION_DoTopLevelINSTALL(package, szPackagePath, szCommandLine);
MsiCloseHandle(handle);
msiobj_release( &package->hdr );
return rc;
return r;
}
UINT WINAPI MsiReinstallProductA(LPCSTR szProduct, DWORD dwReinstallMode)
@ -424,7 +249,7 @@ UINT WINAPI MsiApplyPatchW(LPCWSTR szPatchPackage, LPCWSTR szInstallPackage,
UINT WINAPI MsiConfigureProductExW(LPCWSTR szProduct, int iInstallLevel,
INSTALLSTATE eInstallState, LPCWSTR szCommandLine)
{
MSIHANDLE handle;
MSIHANDLE handle;
MSIPACKAGE* package;
UINT rc;
HKEY hkey=0,hkey1=0;
@ -441,7 +266,7 @@ UINT WINAPI MsiConfigureProductExW(LPCWSTR szProduct, int iInstallLevel,
FIXME("%s %d %d %s\n",debugstr_w(szProduct), iInstallLevel, eInstallState,
debugstr_w(szCommandLine));
if (eInstallState != INSTALLSTATE_LOCAL &&
if (eInstallState != INSTALLSTATE_LOCAL &&
eInstallState != INSTALLSTATE_DEFAULT)
{
FIXME("Not implemented for anything other than local installs\n");
@ -466,7 +291,7 @@ UINT WINAPI MsiConfigureProductExW(LPCWSTR szProduct, int iInstallLevel,
* ok 1, we need to find the msi file for this product.
* 2, find the source dir for the files
* 3, do the configure/install.
* 4, cleanupany runonce entry.
* 4, cleanupany runonce entry.
*/
rc = MsiOpenProductW(szProduct,&handle);
@ -479,7 +304,7 @@ UINT WINAPI MsiConfigureProductExW(LPCWSTR szProduct, int iInstallLevel,
rc = ERROR_INVALID_HANDLE;
goto end;
}
sz = lstrlenW(szInstalled);
if (szCommandLine)
@ -487,13 +312,13 @@ UINT WINAPI MsiConfigureProductExW(LPCWSTR szProduct, int iInstallLevel,
commandline = HeapAlloc(GetProcessHeap(),0,sz * sizeof(WCHAR));
if (szCommandLine)
strcpyW(commandline,szCommandLine);
if (szCommandLine)
lstrcpyW(commandline,szCommandLine);
else
commandline[0] = 0;
if (MsiQueryProductStateW(szProduct) != INSTALLSTATE_UNKNOWN)
strcatW(commandline,szInstalled);
lstrcatW(commandline,szInstalled);
rc = ACTION_DoTopLevelINSTALL(package, sourcepath, commandline);
@ -511,7 +336,7 @@ UINT WINAPI MsiConfigureProductExA(LPCSTR szProduct, int iInstallLevel,
{
LPWSTR szwProduct = NULL;
LPWSTR szwCommandLine = NULL;
UINT hr = ERROR_FUNCTION_FAILED;
UINT r = ERROR_OUTOFMEMORY;
if( szProduct )
{
@ -527,78 +352,73 @@ UINT WINAPI MsiConfigureProductExA(LPCSTR szProduct, int iInstallLevel,
goto end;
}
hr = MsiConfigureProductExW( szwProduct, iInstallLevel, eInstallState,
r = MsiConfigureProductExW( szwProduct, iInstallLevel, eInstallState,
szwCommandLine );
end:
HeapFree( GetProcessHeap(), 0, szwProduct );
HeapFree( GetProcessHeap(), 0, szwCommandLine);
return hr;
return r;
}
UINT WINAPI MsiConfigureProductA(LPCSTR szProduct, int iInstallLevel,
UINT WINAPI MsiConfigureProductA(LPCSTR szProduct, int iInstallLevel,
INSTALLSTATE eInstallState)
{
LPWSTR szwProduct = NULL;
UINT hr = ERROR_SUCCESS;
UINT r;
FIXME("%s %d %d\n",debugstr_a(szProduct), iInstallLevel, eInstallState);
TRACE("%s %d %d\n",debugstr_a(szProduct), iInstallLevel, eInstallState);
if( szProduct )
{
szwProduct = strdupAtoW( szProduct );
if( !szwProduct )
goto end;
return ERROR_OUTOFMEMORY;
}
hr = MsiConfigureProductW( szwProduct, iInstallLevel, eInstallState );
end:
r = MsiConfigureProductW( szwProduct, iInstallLevel, eInstallState );
HeapFree( GetProcessHeap(), 0, szwProduct );
return hr;
return r;
}
UINT WINAPI MsiConfigureProductW(LPCWSTR szProduct, int iInstallLevel,
UINT WINAPI MsiConfigureProductW(LPCWSTR szProduct, int iInstallLevel,
INSTALLSTATE eInstallState)
{
FIXME("%s %d %d\n", debugstr_w(szProduct), iInstallLevel, eInstallState);
return MsiConfigureProductExW(szProduct, iInstallLevel, eInstallState,
NULL);
return MsiConfigureProductExW(szProduct, iInstallLevel, eInstallState, NULL);
}
UINT WINAPI MsiGetProductCodeA(LPCSTR szComponent, LPSTR szBuffer)
{
LPWSTR szwComponent = NULL;
UINT hr = ERROR_INSTALL_FAILURE;
UINT r;
WCHAR szwBuffer[GUID_SIZE];
FIXME("%s %s\n",debugstr_a(szComponent), debugstr_a(szBuffer));
TRACE("%s %s\n",debugstr_a(szComponent), debugstr_a(szBuffer));
if( szComponent )
{
szwComponent = strdupAtoW( szComponent );
if( !szwComponent )
goto end;
return ERROR_OUTOFMEMORY;
}
else
return ERROR_INVALID_PARAMETER;
hr = MsiGetProductCodeW( szwComponent, szwBuffer );
r = MsiGetProductCodeW( szwComponent, szwBuffer );
if( ERROR_SUCCESS == hr )
if( ERROR_SUCCESS == r )
WideCharToMultiByte(CP_ACP, 0, szwBuffer, -1, szBuffer, GUID_SIZE, NULL, NULL);
end:
HeapFree( GetProcessHeap(), 0, szwComponent );
return hr;
return r;
}
UINT WINAPI MsiGetProductCodeW(LPCWSTR szComponent, LPWSTR szBuffer)
{
FIXME("%s %s\n",debugstr_w(szComponent), debugstr_w(szBuffer));
FIXME("%s %p\n",debugstr_w(szComponent), szBuffer);
if (NULL == szComponent)
return ERROR_INVALID_PARAMETER;
return ERROR_CALL_NOT_IMPLEMENTED;
@ -608,7 +428,7 @@ UINT WINAPI MsiGetProductInfoA(LPCSTR szProduct, LPCSTR szAttribute,
LPSTR szBuffer, DWORD *pcchValueBuf)
{
LPWSTR szwProduct = NULL, szwAttribute = NULL, szwBuffer = NULL;
UINT hr = ERROR_OUTOFMEMORY;
UINT r = ERROR_OUTOFMEMORY;
TRACE("%s %s %p %p\n", debugstr_a(szProduct), debugstr_a(szAttribute),
szBuffer, pcchValueBuf);
@ -634,9 +454,9 @@ UINT WINAPI MsiGetProductInfoA(LPCSTR szProduct, LPCSTR szAttribute,
goto end;
}
hr = MsiGetProductInfoW( szwProduct, szwAttribute, szwBuffer, pcchValueBuf );
r = MsiGetProductInfoW( szwProduct, szwAttribute, szwBuffer, pcchValueBuf );
if( ERROR_SUCCESS == hr )
if( ERROR_SUCCESS == r )
WideCharToMultiByte(CP_ACP, 0, szwBuffer, -1, szBuffer, *pcchValueBuf, NULL, NULL);
end:
@ -644,15 +464,15 @@ end:
HeapFree( GetProcessHeap(), 0, szwAttribute );
HeapFree( GetProcessHeap(), 0, szwBuffer );
return hr;
return r;
}
UINT WINAPI MsiGetProductInfoW(LPCWSTR szProduct, LPCWSTR szAttribute,
LPWSTR szBuffer, DWORD *pcchValueBuf)
{
MSIHANDLE hProduct;
UINT hr;
UINT r;
FIXME("%s %s %p %p\n",debugstr_w(szProduct), debugstr_w(szAttribute),
szBuffer, pcchValueBuf);
@ -661,49 +481,12 @@ UINT WINAPI MsiGetProductInfoW(LPCWSTR szProduct, LPCWSTR szAttribute,
if (NULL == szProduct || NULL == szAttribute)
return ERROR_INVALID_PARAMETER;
hr = MsiOpenProductW(szProduct, &hProduct);
if (ERROR_SUCCESS != hr)
return hr;
r = MsiOpenProductW(szProduct, &hProduct);
if (ERROR_SUCCESS != r)
return r;
hr = MsiGetPropertyW(hProduct, szAttribute, szBuffer, pcchValueBuf);
r = MsiGetPropertyW(hProduct, szAttribute, szBuffer, pcchValueBuf);
MsiCloseHandle(hProduct);
return hr;
}
UINT WINAPI MsiDatabaseImportW(MSIHANDLE handle, LPCWSTR szFolderPath, LPCWSTR szFilename)
{
FIXME("%lx %s %s\n",handle,debugstr_w(szFolderPath), debugstr_w(szFilename));
return ERROR_CALL_NOT_IMPLEMENTED;
}
UINT WINAPI MsiDatabaseImportA( MSIHANDLE handle,
LPCSTR szFolderPath, LPCSTR szFilename )
{
LPWSTR path = NULL, file = NULL;
UINT r = ERROR_OUTOFMEMORY;
TRACE("%lx %s %s\n", handle, debugstr_a(szFolderPath), debugstr_a(szFilename));
if( szFolderPath )
{
path = strdupAtoW( szFolderPath );
if( !path )
goto end;
}
if( szFilename )
{
file = strdupAtoW( szFilename );
if( !file )
goto end;
}
r = MsiDatabaseImportW( handle, path, file );
end:
HeapFree( GetProcessHeap(), 0, path );
HeapFree( GetProcessHeap(), 0, file );
return r;
}
@ -818,7 +601,7 @@ INSTALLUILEVEL WINAPI MsiSetInternalUI(INSTALLUILEVEL dwUILevel, HWND *phWnd)
return old;
}
INSTALLUI_HANDLERA WINAPI MsiSetExternalUIA(INSTALLUI_HANDLERA puiHandler,
INSTALLUI_HANDLERA WINAPI MsiSetExternalUIA(INSTALLUI_HANDLERA puiHandler,
DWORD dwMessageFilter, LPVOID pvContext)
{
INSTALLUI_HANDLERA prev = gUIHandlerA;
@ -965,7 +748,7 @@ UINT WINAPI MsiMessageBoxW(HWND hWnd, LPCWSTR lpText, LPCWSTR lpCaption, UINT uT
UINT WINAPI MsiProvideAssemblyA( LPCSTR szAssemblyName, LPCSTR szAppContext,
DWORD dwInstallMode, DWORD dwAssemblyInfo, LPSTR lpPathBuf,
DWORD* pcchPathBuf )
DWORD* pcchPathBuf )
{
FIXME("%s %s %08lx %08lx %p %p\n", debugstr_a(szAssemblyName),
debugstr_a(szAppContext), dwInstallMode, dwAssemblyInfo, lpPathBuf,
@ -977,7 +760,7 @@ UINT WINAPI MsiProvideAssemblyW( LPCWSTR szAssemblyName, LPCWSTR szAppContext,
DWORD dwInstallMode, DWORD dwAssemblyInfo, LPWSTR lpPathBuf,
DWORD* pcchPathBuf )
{
FIXME("%s %s %08lx %08lx %p %p\n", debugstr_w(szAssemblyName),
FIXME("%s %s %08lx %08lx %p %p\n", debugstr_w(szAssemblyName),
debugstr_w(szAppContext), dwInstallMode, dwAssemblyInfo, lpPathBuf,
pcchPathBuf);
return ERROR_CALL_NOT_IMPLEMENTED;
@ -1159,7 +942,7 @@ INSTALLSTATE WINAPI MsiGetComponentPathW(LPCWSTR szProduct, LPCWSTR szComponent,
if (path[0]=='0')
{
FIXME("Registry entry.. check entry\n");
rrc = INSTALLSTATE_LOCAL;
rrc = INSTALLSTATE_LOCAL;
}
else
{
@ -1174,7 +957,7 @@ INSTALLSTATE WINAPI MsiGetComponentPathW(LPCWSTR szProduct, LPCWSTR szComponent,
{
sz = sz / sizeof(WCHAR);
if( *pcchBuf >= sz )
strcpyW( lpPathBuf, path );
lstrcpyW( lpPathBuf, path );
*pcchBuf = sz;
}
@ -1229,14 +1012,14 @@ UINT WINAPI MsiGetFileVersionA(LPCSTR szFilePath, LPSTR lpVersionBuf,
{
LPWSTR szwFilePath = NULL, lpwVersionBuff = NULL, lpwLangBuff = NULL;
UINT ret = ERROR_OUTOFMEMORY;
if( szFilePath )
{
szwFilePath = strdupAtoW( szFilePath );
if( !szwFilePath )
goto end;
}
if( lpVersionBuf && pcchVersionBuf && *pcchVersionBuf )
{
lpwVersionBuff = HeapAlloc(GetProcessHeap(), 0, *pcchVersionBuf*sizeof(WCHAR));
@ -1250,22 +1033,22 @@ UINT WINAPI MsiGetFileVersionA(LPCSTR szFilePath, LPSTR lpVersionBuf,
if( !lpwLangBuff )
goto end;
}
ret = MsiGetFileVersionW(szwFilePath, lpwVersionBuff, pcchVersionBuf,
lpwLangBuff, pcchLangBuf);
if( lpwVersionBuff )
WideCharToMultiByte(CP_ACP, 0, lpwVersionBuff, -1,
lpVersionBuf, *pcchVersionBuf, NULL, NULL);
if( lpwLangBuff )
WideCharToMultiByte(CP_ACP, 0, lpwLangBuff, -1,
lpLangBuf, *pcchLangBuf, NULL, NULL);
end:
HeapFree(GetProcessHeap(), 0, szwFilePath);
HeapFree(GetProcessHeap(), 0, lpwVersionBuff);
HeapFree(GetProcessHeap(), 0, lpwLangBuff);
return ret;
}
@ -1312,7 +1095,7 @@ UINT WINAPI MsiGetFileVersionW(LPCWSTR szFilePath, LPWSTR lpVersionBuf,
HIWORD(ffi->dwFileVersionMS), LOWORD(ffi->dwFileVersionMS),
HIWORD(ffi->dwFileVersionLS), LOWORD(ffi->dwFileVersionLS));
lstrcpynW(lpVersionBuf, tmp, *pcchVersionBuf);
*pcchVersionBuf = strlenW(lpVersionBuf);
*pcchVersionBuf = lstrlenW(lpVersionBuf);
}
else
{
@ -1328,7 +1111,7 @@ UINT WINAPI MsiGetFileVersionW(LPCWSTR szFilePath, LPWSTR lpVersionBuf,
FIXME("Retrieve language from file\n");
wsprintfW(tmp, szLangFormat, lang);
lstrcpynW(lpLangBuf, tmp, *pcchLangBuf);
*pcchLangBuf = strlenW(lpLangBuf);
*pcchLangBuf = lstrlenW(lpLangBuf);
}
end:
@ -1433,15 +1216,15 @@ HRESULT WINAPI MSI_DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
HRESULT WINAPI MSI_DllGetVersion(DLLVERSIONINFO *pdvi)
{
TRACE("%p\n",pdvi);
if (pdvi->cbSize != sizeof(DLLVERSIONINFO))
return E_INVALIDARG;
pdvi->dwMajorVersion = MSI_MAJORVERSION;
pdvi->dwMinorVersion = MSI_MINORVERSION;
pdvi->dwBuildNumber = MSI_BUILDNUMBER;
pdvi->dwPlatformID = 1;
return S_OK;
}
@ -1469,7 +1252,7 @@ UINT WINAPI MsiGetFeatureUsageA(LPCSTR szProduct, LPCSTR szFeature,
return ERROR_CALL_NOT_IMPLEMENTED;
}
INSTALLSTATE WINAPI MsiUseFeatureExW(LPCWSTR szProduct, LPCWSTR szFeature,
INSTALLSTATE WINAPI MsiUseFeatureExW(LPCWSTR szProduct, LPCWSTR szFeature,
DWORD dwInstallMode, DWORD dwReserved)
{
FIXME("%s %s %li %li\n", debugstr_w(szProduct), debugstr_w(szFeature),
@ -1481,37 +1264,37 @@ INSTALLSTATE WINAPI MsiUseFeatureExW(LPCWSTR szProduct, LPCWSTR szFeature,
* Software\\Microsoft\\Windows\\CurrentVersion\\
* Installer\\Products\\<squishguid>\\<feature>
* "Usage"=dword:........
*/
return INSTALLSTATE_LOCAL;
*/
return INSTALLSTATE_LOCAL;
}
INSTALLSTATE WINAPI MsiUseFeatureExA(LPCSTR szProduct, LPCSTR szFeature,
INSTALLSTATE WINAPI MsiUseFeatureExA(LPCSTR szProduct, LPCSTR szFeature,
DWORD dwInstallMode, DWORD dwReserved)
{
FIXME("%s %s %li %li\n", debugstr_a(szProduct), debugstr_a(szFeature),
dwInstallMode, dwReserved);
return INSTALLSTATE_LOCAL;
return INSTALLSTATE_LOCAL;
}
INSTALLSTATE WINAPI MsiUseFeatureW(LPCWSTR szProduct, LPCWSTR szFeature)
{
FIXME("%s %s\n", debugstr_w(szProduct), debugstr_w(szFeature));
return INSTALLSTATE_LOCAL;
return INSTALLSTATE_LOCAL;
}
INSTALLSTATE WINAPI MsiUseFeatureA(LPCSTR szProduct, LPCSTR szFeature)
{
FIXME("%s %s\n", debugstr_a(szProduct), debugstr_a(szFeature));
return INSTALLSTATE_LOCAL;
return INSTALLSTATE_LOCAL;
}
UINT WINAPI MsiProvideQualifiedComponentExW(LPCWSTR szComponent,
UINT WINAPI MsiProvideQualifiedComponentExW(LPCWSTR szComponent,
LPCWSTR szQualifier, DWORD dwInstallMode, LPWSTR szProduct,
DWORD Unused1, DWORD Unused2, LPWSTR lpPathBuf,
DWORD Unused1, DWORD Unused2, LPWSTR lpPathBuf,
DWORD* pcchPathBuf)
{
FIXME("%s %s %li %s %li %li %p %p\n", debugstr_w(szComponent),
@ -1521,26 +1304,26 @@ UINT WINAPI MsiProvideQualifiedComponentExW(LPCWSTR szComponent,
return ERROR_INDEX_ABSENT;
}
USERINFOSTATE WINAPI MsiGetUserInfoW(LPCWSTR szProduct, LPWSTR lpUserNameBuf,
DWORD* pcchUserNameBuf, LPWSTR lpOrgNameBuf,
USERINFOSTATE WINAPI MsiGetUserInfoW(LPCWSTR szProduct, LPWSTR lpUserNameBuf,
DWORD* pcchUserNameBuf, LPWSTR lpOrgNameBuf,
DWORD* pcchOrgNameBuf, LPWSTR lpSerialBuf, DWORD* pcchSerialBuf)
{
FIXME("%s %p %p %p %p %p %p\n",debugstr_w(szProduct), lpUserNameBuf,
pcchUserNameBuf, lpOrgNameBuf, pcchOrgNameBuf, lpSerialBuf,
pcchSerialBuf);
return USERINFOSTATE_UNKNOWN;
return USERINFOSTATE_UNKNOWN;
}
USERINFOSTATE WINAPI MsiGetUserInfoA(LPCSTR szProduct, LPSTR lpUserNameBuf,
DWORD* pcchUserNameBuf, LPSTR lpOrgNameBuf,
USERINFOSTATE WINAPI MsiGetUserInfoA(LPCSTR szProduct, LPSTR lpUserNameBuf,
DWORD* pcchUserNameBuf, LPSTR lpOrgNameBuf,
DWORD* pcchOrgNameBuf, LPSTR lpSerialBuf, DWORD* pcchSerialBuf)
{
FIXME("%s %p %p %p %p %p %p\n",debugstr_a(szProduct), lpUserNameBuf,
pcchUserNameBuf, lpOrgNameBuf, pcchOrgNameBuf, lpSerialBuf,
pcchSerialBuf);
return USERINFOSTATE_UNKNOWN;
return USERINFOSTATE_UNKNOWN;
}
UINT WINAPI MsiCollectUserInfoW(LPCWSTR szProduct)
@ -1577,7 +1360,7 @@ UINT WINAPI MsiGetShortcutTargetW( LPCWSTR szShortcutTarget,
return ERROR_CALL_NOT_IMPLEMENTED;
}
UINT WINAPI MsiReinstallFeatureW( LPCWSTR szProduct, LPCWSTR szFeature,
UINT WINAPI MsiReinstallFeatureW( LPCWSTR szProduct, LPCWSTR szFeature,
DWORD dwReinstallMode )
{
FIXME("%s %s %li\n", debugstr_w(szProduct), debugstr_w(szFeature),
@ -1585,7 +1368,7 @@ UINT WINAPI MsiReinstallFeatureW( LPCWSTR szProduct, LPCWSTR szFeature,
return ERROR_SUCCESS;
}
UINT WINAPI MsiReinstallFeatureA( LPCSTR szProduct, LPCSTR szFeature,
UINT WINAPI MsiReinstallFeatureA( LPCSTR szProduct, LPCSTR szFeature,
DWORD dwReinstallMode )
{
FIXME("%s %s %li\n", debugstr_a(szProduct), debugstr_a(szFeature),