2 * Implementation of the Microsoft Installer (msi.dll)
4 * Copyright 2002-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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
28 #include "wine/debug.h"
29 #include "wine/unicode.h"
38 #include "msiserver.h"
42 WINE_DEFAULT_DEBUG_CHANNEL(msi
);
44 static void MSI_CloseView( MSIOBJECTHDR
*arg
)
46 MSIQUERY
*query
= (MSIQUERY
*) arg
;
49 if( query
->view
&& query
->view
->ops
->delete )
50 query
->view
->ops
->delete( query
->view
);
51 msiobj_release( &query
->db
->hdr
);
53 LIST_FOR_EACH_SAFE( ptr
, t
, &query
->mem
)
59 UINT
VIEW_find_column( MSIVIEW
*table
, LPCWSTR name
, UINT
*n
)
64 r
= table
->ops
->get_dimensions( table
, NULL
, &count
);
65 if( r
!= ERROR_SUCCESS
)
68 for( i
=1; i
<=count
; i
++ )
73 r
= table
->ops
->get_column_info( table
, i
, &col_name
, NULL
, NULL
);
74 if( r
!= ERROR_SUCCESS
)
76 x
= lstrcmpW( name
, col_name
);
85 return ERROR_INVALID_PARAMETER
;
88 UINT WINAPI
MsiDatabaseOpenViewA(MSIHANDLE hdb
,
89 LPCSTR szQuery
, MSIHANDLE
*phView
)
94 TRACE("%d %s %p\n", hdb
, debugstr_a(szQuery
), phView
);
98 szwQuery
= strdupAtoW( szQuery
);
100 return ERROR_FUNCTION_FAILED
;
105 r
= MsiDatabaseOpenViewW( hdb
, szwQuery
, phView
);
107 msi_free( szwQuery
);
111 UINT
MSI_DatabaseOpenViewW(MSIDATABASE
*db
,
112 LPCWSTR szQuery
, MSIQUERY
**pView
)
117 TRACE("%s %p\n", debugstr_w(szQuery
), pView
);
120 return ERROR_INVALID_PARAMETER
;
122 /* pre allocate a handle to hold a pointer to the view */
123 query
= alloc_msiobject( MSIHANDLETYPE_VIEW
, sizeof (MSIQUERY
),
126 return ERROR_FUNCTION_FAILED
;
128 msiobj_addref( &db
->hdr
);
132 list_init( &query
->mem
);
134 r
= MSI_ParseSQL( db
, szQuery
, &query
->view
, &query
->mem
);
135 if( r
== ERROR_SUCCESS
)
137 msiobj_addref( &query
->hdr
);
141 msiobj_release( &query
->hdr
);
145 UINT
MSI_OpenQuery( MSIDATABASE
*db
, MSIQUERY
**view
, LPCWSTR fmt
, ... )
151 /* construct the string */
155 query
= msi_alloc( size
*sizeof(WCHAR
) );
157 res
= vsnprintfW(query
, size
, fmt
, va
);
159 if (res
== -1) size
*= 2;
160 else if (res
>= size
) size
= res
+ 1;
164 /* perform the query */
165 r
= MSI_DatabaseOpenViewW(db
, query
, view
);
170 UINT
MSI_IterateRecords( MSIQUERY
*view
, LPDWORD count
,
171 record_func func
, LPVOID param
)
173 MSIRECORD
*rec
= NULL
;
174 UINT r
, n
= 0, max
= 0;
176 r
= MSI_ViewExecute( view
, NULL
);
177 if( r
!= ERROR_SUCCESS
)
183 /* iterate a query */
184 for( n
= 0; (max
== 0) || (n
< max
); n
++ )
186 r
= MSI_ViewFetch( view
, &rec
);
187 if( r
!= ERROR_SUCCESS
)
190 r
= func( rec
, param
);
191 msiobj_release( &rec
->hdr
);
192 if( r
!= ERROR_SUCCESS
)
196 MSI_ViewClose( view
);
201 if( r
== ERROR_NO_MORE_ITEMS
)
207 /* return a single record from a query */
208 MSIRECORD
*MSI_QueryGetRecord( MSIDATABASE
*db
, LPCWSTR fmt
, ... )
210 MSIRECORD
*rec
= NULL
;
211 MSIQUERY
*view
= NULL
;
216 /* construct the string */
220 query
= msi_alloc( size
*sizeof(WCHAR
) );
222 res
= vsnprintfW(query
, size
, fmt
, va
);
224 if (res
== -1) size
*= 2;
225 else if (res
>= size
) size
= res
+ 1;
229 /* perform the query */
230 r
= MSI_DatabaseOpenViewW(db
, query
, &view
);
233 if( r
== ERROR_SUCCESS
)
235 MSI_ViewExecute( view
, NULL
);
236 MSI_ViewFetch( view
, &rec
);
237 MSI_ViewClose( view
);
238 msiobj_release( &view
->hdr
);
243 UINT WINAPI
MsiDatabaseOpenViewW(MSIHANDLE hdb
,
244 LPCWSTR szQuery
, MSIHANDLE
*phView
)
247 MSIQUERY
*query
= NULL
;
250 TRACE("%s %p\n", debugstr_w(szQuery
), phView
);
252 db
= msihandle2msiinfo( hdb
, MSIHANDLETYPE_DATABASE
);
256 IWineMsiRemoteDatabase
*remote_database
;
258 remote_database
= (IWineMsiRemoteDatabase
*)msi_get_remote( hdb
);
259 if ( !remote_database
)
260 return ERROR_INVALID_HANDLE
;
262 hr
= IWineMsiRemoteDatabase_OpenView( remote_database
, (BSTR
)szQuery
, phView
);
263 IWineMsiRemoteDatabase_Release( remote_database
);
267 if (HRESULT_FACILITY(hr
) == FACILITY_WIN32
)
268 return HRESULT_CODE(hr
);
270 return ERROR_FUNCTION_FAILED
;
273 return ERROR_SUCCESS
;
276 ret
= MSI_DatabaseOpenViewW( db
, szQuery
, &query
);
277 if( ret
== ERROR_SUCCESS
)
279 *phView
= alloc_msihandle( &query
->hdr
);
281 ret
= ERROR_NOT_ENOUGH_MEMORY
;
282 msiobj_release( &query
->hdr
);
284 msiobj_release( &db
->hdr
);
289 UINT
msi_view_get_row(MSIDATABASE
*db
, MSIVIEW
*view
, UINT row
, MSIRECORD
**rec
)
291 UINT row_count
= 0, col_count
= 0, i
, ival
, ret
, type
;
293 TRACE("%p %p %d %p\n", db
, view
, row
, rec
);
295 ret
= view
->ops
->get_dimensions(view
, &row_count
, &col_count
);
300 return ERROR_INVALID_PARAMETER
;
302 if (row
>= row_count
)
303 return ERROR_NO_MORE_ITEMS
;
305 *rec
= MSI_CreateRecord(col_count
);
307 return ERROR_FUNCTION_FAILED
;
309 for (i
= 1; i
<= col_count
; i
++)
311 ret
= view
->ops
->get_column_info(view
, i
, NULL
, &type
, NULL
);
314 ERR("Error getting column type for %d\n", i
);
318 if (MSITYPE_IS_BINARY(type
))
322 ret
= view
->ops
->fetch_stream(view
, row
, i
, &stm
);
323 if ((ret
== ERROR_SUCCESS
) && stm
)
325 MSI_RecordSetIStream(*rec
, i
, stm
);
326 IStream_Release(stm
);
329 WARN("failed to get stream\n");
334 ret
= view
->ops
->fetch_int(view
, row
, i
, &ival
);
337 ERR("Error fetching data for %d\n", i
);
341 if (! (type
& MSITYPE_VALID
))
342 ERR("Invalid type!\n");
344 /* check if it's nul (0) - if so, don't set anything */
348 if (type
& MSITYPE_STRING
)
352 sval
= msi_string_lookup_id(db
->strings
, ival
);
353 MSI_RecordSetStringW(*rec
, i
, sval
);
357 if ((type
& MSI_DATASIZEMASK
) == 2)
358 MSI_RecordSetInteger(*rec
, i
, ival
- (1<<15));
360 MSI_RecordSetInteger(*rec
, i
, ival
- (1<<31));
364 return ERROR_SUCCESS
;
367 UINT
MSI_ViewFetch(MSIQUERY
*query
, MSIRECORD
**prec
)
372 TRACE("%p %p\n", query
, prec
);
376 return ERROR_FUNCTION_FAILED
;
378 r
= msi_view_get_row(query
->db
, view
, query
->row
, prec
);
379 if (r
== ERROR_SUCCESS
)
382 MSI_RecordSetInteger(*prec
, 0, (int)query
);
388 UINT WINAPI
MsiViewFetch(MSIHANDLE hView
, MSIHANDLE
*record
)
391 MSIRECORD
*rec
= NULL
;
394 TRACE("%d %p\n", hView
, record
);
397 return ERROR_INVALID_PARAMETER
;
400 query
= msihandle2msiinfo( hView
, MSIHANDLETYPE_VIEW
);
402 return ERROR_INVALID_HANDLE
;
403 ret
= MSI_ViewFetch( query
, &rec
);
404 if( ret
== ERROR_SUCCESS
)
406 *record
= alloc_msihandle( &rec
->hdr
);
408 ret
= ERROR_NOT_ENOUGH_MEMORY
;
409 msiobj_release( &rec
->hdr
);
411 msiobj_release( &query
->hdr
);
415 UINT
MSI_ViewClose(MSIQUERY
*query
)
419 TRACE("%p\n", query
);
423 return ERROR_FUNCTION_FAILED
;
424 if( !view
->ops
->close
)
425 return ERROR_FUNCTION_FAILED
;
427 return view
->ops
->close( view
);
430 UINT WINAPI
MsiViewClose(MSIHANDLE hView
)
435 TRACE("%d\n", hView
);
437 query
= msihandle2msiinfo( hView
, MSIHANDLETYPE_VIEW
);
439 return ERROR_INVALID_HANDLE
;
441 ret
= MSI_ViewClose( query
);
442 msiobj_release( &query
->hdr
);
446 UINT
MSI_ViewExecute(MSIQUERY
*query
, MSIRECORD
*rec
)
450 TRACE("%p %p\n", query
, rec
);
454 return ERROR_FUNCTION_FAILED
;
455 if( !view
->ops
->execute
)
456 return ERROR_FUNCTION_FAILED
;
459 return view
->ops
->execute( view
, rec
);
462 UINT WINAPI
MsiViewExecute(MSIHANDLE hView
, MSIHANDLE hRec
)
465 MSIRECORD
*rec
= NULL
;
468 TRACE("%d %d\n", hView
, hRec
);
470 query
= msihandle2msiinfo( hView
, MSIHANDLETYPE_VIEW
);
472 return ERROR_INVALID_HANDLE
;
476 rec
= msihandle2msiinfo( hRec
, MSIHANDLETYPE_RECORD
);
479 ret
= ERROR_INVALID_HANDLE
;
484 msiobj_lock( &rec
->hdr
);
485 ret
= MSI_ViewExecute( query
, rec
);
486 msiobj_unlock( &rec
->hdr
);
489 msiobj_release( &query
->hdr
);
491 msiobj_release( &rec
->hdr
);
496 static UINT
msi_set_record_type_string( MSIRECORD
*rec
, UINT field
,
497 UINT type
, BOOL temporary
)
499 static const WCHAR fmt
[] = { '%','d',0 };
502 if (MSITYPE_IS_BINARY(type
))
504 else if (type
& MSITYPE_LOCALIZABLE
)
506 else if (type
& MSITYPE_STRING
)
521 if (type
& MSITYPE_NULLABLE
)
524 sprintfW( &szType
[1], fmt
, (type
&0xff) );
526 TRACE("type %04x -> %s\n", type
, debugstr_w(szType
) );
528 return MSI_RecordSetStringW( rec
, field
, szType
);
531 UINT
MSI_ViewGetColumnInfo( MSIQUERY
*query
, MSICOLINFO info
, MSIRECORD
**prec
)
533 UINT r
= ERROR_FUNCTION_FAILED
, i
, count
= 0, type
;
535 MSIVIEW
*view
= query
->view
;
540 return ERROR_FUNCTION_FAILED
;
542 if( !view
->ops
->get_dimensions
)
543 return ERROR_FUNCTION_FAILED
;
545 r
= view
->ops
->get_dimensions( view
, NULL
, &count
);
546 if( r
!= ERROR_SUCCESS
)
549 return ERROR_INVALID_PARAMETER
;
551 rec
= MSI_CreateRecord( count
);
553 return ERROR_FUNCTION_FAILED
;
555 for( i
=0; i
<count
; i
++ )
558 r
= view
->ops
->get_column_info( view
, i
+1, &name
, &type
, &temporary
);
559 if( r
!= ERROR_SUCCESS
)
561 if (info
== MSICOLINFO_NAMES
)
562 MSI_RecordSetStringW( rec
, i
+1, name
);
564 msi_set_record_type_string( rec
, i
+1, type
, temporary
);
569 return ERROR_SUCCESS
;
572 UINT WINAPI
MsiViewGetColumnInfo(MSIHANDLE hView
, MSICOLINFO info
, MSIHANDLE
*hRec
)
574 MSIQUERY
*query
= NULL
;
575 MSIRECORD
*rec
= NULL
;
578 TRACE("%d %d %p\n", hView
, info
, hRec
);
581 return ERROR_INVALID_PARAMETER
;
583 if( info
!= MSICOLINFO_NAMES
&& info
!= MSICOLINFO_TYPES
)
584 return ERROR_INVALID_PARAMETER
;
586 query
= msihandle2msiinfo( hView
, MSIHANDLETYPE_VIEW
);
588 return ERROR_INVALID_HANDLE
;
590 r
= MSI_ViewGetColumnInfo( query
, info
, &rec
);
591 if ( r
== ERROR_SUCCESS
)
593 *hRec
= alloc_msihandle( &rec
->hdr
);
595 r
= ERROR_NOT_ENOUGH_MEMORY
;
596 msiobj_release( &rec
->hdr
);
599 msiobj_release( &query
->hdr
);
604 UINT
MSI_ViewModify( MSIQUERY
*query
, MSIMODIFY mode
, MSIRECORD
*rec
)
606 MSIVIEW
*view
= NULL
;
609 if ( !query
|| !rec
)
610 return ERROR_INVALID_HANDLE
;
613 if ( !view
|| !view
->ops
->modify
)
614 return ERROR_FUNCTION_FAILED
;
616 if ( mode
== MSIMODIFY_UPDATE
&& MSI_RecordGetInteger( rec
, 0 ) != (int)query
)
617 return ERROR_FUNCTION_FAILED
;
619 r
= view
->ops
->modify( view
, mode
, rec
, query
->row
);
620 if (mode
== MSIMODIFY_DELETE
&& r
== ERROR_SUCCESS
)
626 UINT WINAPI
MsiViewModify( MSIHANDLE hView
, MSIMODIFY eModifyMode
,
629 MSIQUERY
*query
= NULL
;
630 MSIRECORD
*rec
= NULL
;
631 UINT r
= ERROR_FUNCTION_FAILED
;
633 TRACE("%d %x %d\n", hView
, eModifyMode
, hRecord
);
635 query
= msihandle2msiinfo( hView
, MSIHANDLETYPE_VIEW
);
637 return ERROR_INVALID_HANDLE
;
639 rec
= msihandle2msiinfo( hRecord
, MSIHANDLETYPE_RECORD
);
640 r
= MSI_ViewModify( query
, eModifyMode
, rec
);
642 msiobj_release( &query
->hdr
);
644 msiobj_release( &rec
->hdr
);
649 MSIDBERROR WINAPI
MsiViewGetErrorW( MSIHANDLE handle
, LPWSTR szColumnNameBuffer
,
652 MSIQUERY
*query
= NULL
;
653 static const WCHAR szError
[] = { 0 };
654 MSIDBERROR r
= MSIDBERROR_NOERROR
;
657 FIXME("%d %p %p - returns empty error string\n",
658 handle
, szColumnNameBuffer
, pcchBuf
);
661 return MSIDBERROR_INVALIDARG
;
663 query
= msihandle2msiinfo( handle
, MSIHANDLETYPE_VIEW
);
665 return MSIDBERROR_INVALIDARG
;
667 len
= strlenW( szError
);
668 if( szColumnNameBuffer
)
671 lstrcpyW( szColumnNameBuffer
, szError
);
673 r
= MSIDBERROR_MOREDATA
;
677 msiobj_release( &query
->hdr
);
681 MSIDBERROR WINAPI
MsiViewGetErrorA( MSIHANDLE handle
, LPSTR szColumnNameBuffer
,
684 static const CHAR szError
[] = { 0 };
685 MSIQUERY
*query
= NULL
;
686 MSIDBERROR r
= MSIDBERROR_NOERROR
;
689 FIXME("%d %p %p - returns empty error string\n",
690 handle
, szColumnNameBuffer
, pcchBuf
);
693 return MSIDBERROR_INVALIDARG
;
695 query
= msihandle2msiinfo( handle
, MSIHANDLETYPE_VIEW
);
697 return MSIDBERROR_INVALIDARG
;
699 len
= strlen( szError
);
700 if( szColumnNameBuffer
)
703 lstrcpyA( szColumnNameBuffer
, szError
);
705 r
= MSIDBERROR_MOREDATA
;
709 msiobj_release( &query
->hdr
);
713 MSIHANDLE WINAPI
MsiGetLastErrorRecord( void )
719 UINT
MSI_DatabaseApplyTransformW( MSIDATABASE
*db
,
720 LPCWSTR szTransformFile
, int iErrorCond
)
723 UINT ret
= ERROR_FUNCTION_FAILED
;
724 IStorage
*stg
= NULL
;
727 TRACE("%p %s %d\n", db
, debugstr_w(szTransformFile
), iErrorCond
);
729 r
= StgOpenStorage( szTransformFile
, NULL
,
730 STGM_DIRECT
|STGM_READ
|STGM_SHARE_DENY_WRITE
, NULL
, 0, &stg
);
734 r
= IStorage_Stat( stg
, &stat
, STATFLAG_NONAME
);
738 if ( !IsEqualGUID( &stat
.clsid
, &CLSID_MsiTransform
) )
741 if( TRACE_ON( msi
) )
742 enum_stream_names( stg
);
744 ret
= msi_table_apply_transform( db
, stg
);
747 IStorage_Release( stg
);
752 UINT WINAPI
MsiDatabaseApplyTransformW( MSIHANDLE hdb
,
753 LPCWSTR szTransformFile
, int iErrorCond
)
758 db
= msihandle2msiinfo( hdb
, MSIHANDLETYPE_DATABASE
);
761 IWineMsiRemoteDatabase
*remote_database
;
763 remote_database
= (IWineMsiRemoteDatabase
*)msi_get_remote( hdb
);
764 if ( !remote_database
)
765 return ERROR_INVALID_HANDLE
;
767 IWineMsiRemoteDatabase_Release( remote_database
);
768 WARN("MsiDatabaseApplyTransform not allowed during a custom action!\n");
770 return ERROR_SUCCESS
;
773 r
= MSI_DatabaseApplyTransformW( db
, szTransformFile
, iErrorCond
);
774 msiobj_release( &db
->hdr
);
778 UINT WINAPI
MsiDatabaseApplyTransformA( MSIHANDLE hdb
,
779 LPCSTR szTransformFile
, int iErrorCond
)
784 TRACE("%d %s %d\n", hdb
, debugstr_a(szTransformFile
), iErrorCond
);
786 wstr
= strdupAtoW( szTransformFile
);
787 if( szTransformFile
&& !wstr
)
788 return ERROR_NOT_ENOUGH_MEMORY
;
790 ret
= MsiDatabaseApplyTransformW( hdb
, wstr
, iErrorCond
);
797 UINT WINAPI
MsiDatabaseGenerateTransformA( MSIHANDLE hdb
, MSIHANDLE hdbref
,
798 LPCSTR szTransformFile
, int iReserved1
, int iReserved2
)
800 FIXME("%d %d %s %d %d\n", hdb
, hdbref
,
801 debugstr_a(szTransformFile
), iReserved1
, iReserved2
);
802 return ERROR_CALL_NOT_IMPLEMENTED
;
805 UINT WINAPI
MsiDatabaseGenerateTransformW( MSIHANDLE hdb
, MSIHANDLE hdbref
,
806 LPCWSTR szTransformFile
, int iReserved1
, int iReserved2
)
808 FIXME("%d %d %s %d %d\n", hdb
, hdbref
,
809 debugstr_w(szTransformFile
), iReserved1
, iReserved2
);
810 return ERROR_CALL_NOT_IMPLEMENTED
;
813 UINT WINAPI
MsiDatabaseCommit( MSIHANDLE hdb
)
820 db
= msihandle2msiinfo( hdb
, MSIHANDLETYPE_DATABASE
);
823 IWineMsiRemoteDatabase
*remote_database
;
825 remote_database
= (IWineMsiRemoteDatabase
*)msi_get_remote( hdb
);
826 if ( !remote_database
)
827 return ERROR_INVALID_HANDLE
;
829 IWineMsiRemoteDatabase_Release( remote_database
);
830 WARN("MsiDatabaseCommit not allowed during a custom action!\n");
832 return ERROR_SUCCESS
;
835 /* FIXME: lock the database */
837 r
= MSI_CommitTables( db
);
838 if (r
!= ERROR_SUCCESS
) ERR("Failed to commit tables!\n");
840 /* FIXME: unlock the database */
842 msiobj_release( &db
->hdr
);
844 if (r
== ERROR_SUCCESS
)
846 msi_free( db
->deletefile
);
847 db
->deletefile
= NULL
;
853 struct msi_primary_key_record_info
859 static UINT
msi_primary_key_iterator( MSIRECORD
*rec
, LPVOID param
)
861 struct msi_primary_key_record_info
*info
= param
;
865 type
= MSI_RecordGetInteger( rec
, 4 );
866 if( type
& MSITYPE_KEY
)
873 table
= MSI_RecordGetString( rec
, 1 );
874 MSI_RecordSetStringW( info
->rec
, 0, table
);
877 name
= MSI_RecordGetString( rec
, 3 );
878 MSI_RecordSetStringW( info
->rec
, info
->n
, name
);
882 return ERROR_SUCCESS
;
885 UINT
MSI_DatabaseGetPrimaryKeys( MSIDATABASE
*db
,
886 LPCWSTR table
, MSIRECORD
**prec
)
888 static const WCHAR sql
[] = {
889 's','e','l','e','c','t',' ','*',' ',
890 'f','r','o','m',' ','`','_','C','o','l','u','m','n','s','`',' ',
891 'w','h','e','r','e',' ',
892 '`','T','a','b','l','e','`',' ','=',' ','\'','%','s','\'',0 };
893 struct msi_primary_key_record_info info
;
894 MSIQUERY
*query
= NULL
;
897 r
= MSI_OpenQuery( db
, &query
, sql
, table
);
898 if( r
!= ERROR_SUCCESS
)
901 /* count the number of primary key records */
904 r
= MSI_IterateRecords( query
, 0, msi_primary_key_iterator
, &info
);
905 if( r
== ERROR_SUCCESS
)
907 TRACE("Found %d primary keys\n", info
.n
);
909 /* allocate a record and fill in the names of the tables */
910 info
.rec
= MSI_CreateRecord( info
.n
);
912 r
= MSI_IterateRecords( query
, 0, msi_primary_key_iterator
, &info
);
913 if( r
== ERROR_SUCCESS
)
916 msiobj_release( &info
.rec
->hdr
);
918 msiobj_release( &query
->hdr
);
923 UINT WINAPI
MsiDatabaseGetPrimaryKeysW( MSIHANDLE hdb
,
924 LPCWSTR table
, MSIHANDLE
* phRec
)
926 MSIRECORD
*rec
= NULL
;
930 TRACE("%d %s %p\n", hdb
, debugstr_w(table
), phRec
);
932 db
= msihandle2msiinfo( hdb
, MSIHANDLETYPE_DATABASE
);
936 IWineMsiRemoteDatabase
*remote_database
;
938 remote_database
= (IWineMsiRemoteDatabase
*)msi_get_remote( hdb
);
939 if ( !remote_database
)
940 return ERROR_INVALID_HANDLE
;
942 hr
= IWineMsiRemoteDatabase_GetPrimaryKeys( remote_database
, (BSTR
)table
, phRec
);
943 IWineMsiRemoteDatabase_Release( remote_database
);
947 if (HRESULT_FACILITY(hr
) == FACILITY_WIN32
)
948 return HRESULT_CODE(hr
);
950 return ERROR_FUNCTION_FAILED
;
953 return ERROR_SUCCESS
;
956 r
= MSI_DatabaseGetPrimaryKeys( db
, table
, &rec
);
957 if( r
== ERROR_SUCCESS
)
959 *phRec
= alloc_msihandle( &rec
->hdr
);
961 r
= ERROR_NOT_ENOUGH_MEMORY
;
962 msiobj_release( &rec
->hdr
);
964 msiobj_release( &db
->hdr
);
969 UINT WINAPI
MsiDatabaseGetPrimaryKeysA(MSIHANDLE hdb
,
970 LPCSTR table
, MSIHANDLE
* phRec
)
972 LPWSTR szwTable
= NULL
;
975 TRACE("%d %s %p\n", hdb
, debugstr_a(table
), phRec
);
979 szwTable
= strdupAtoW( table
);
981 return ERROR_OUTOFMEMORY
;
983 r
= MsiDatabaseGetPrimaryKeysW( hdb
, szwTable
, phRec
);
984 msi_free( szwTable
);
989 MSICONDITION WINAPI
MsiDatabaseIsTablePersistentA(
990 MSIHANDLE hDatabase
, LPCSTR szTableName
)
992 LPWSTR szwTableName
= NULL
;
995 TRACE("%x %s\n", hDatabase
, debugstr_a(szTableName
));
999 szwTableName
= strdupAtoW( szTableName
);
1001 return MSICONDITION_ERROR
;
1003 r
= MsiDatabaseIsTablePersistentW( hDatabase
, szwTableName
);
1004 msi_free( szwTableName
);
1009 MSICONDITION WINAPI
MsiDatabaseIsTablePersistentW(
1010 MSIHANDLE hDatabase
, LPCWSTR szTableName
)
1015 TRACE("%x %s\n", hDatabase
, debugstr_w(szTableName
));
1017 db
= msihandle2msiinfo( hDatabase
, MSIHANDLETYPE_DATABASE
);
1021 MSICONDITION condition
;
1022 IWineMsiRemoteDatabase
*remote_database
;
1024 remote_database
= (IWineMsiRemoteDatabase
*)msi_get_remote( hDatabase
);
1025 if ( !remote_database
)
1026 return MSICONDITION_ERROR
;
1028 hr
= IWineMsiRemoteDatabase_IsTablePersistent( remote_database
,
1029 (BSTR
)szTableName
, &condition
);
1030 IWineMsiRemoteDatabase_Release( remote_database
);
1033 return MSICONDITION_ERROR
;
1038 r
= MSI_DatabaseIsTablePersistent( db
, szTableName
);
1040 msiobj_release( &db
->hdr
);