2 * Implementation of the Microsoft Installer (msi.dll)
4 * Copyright 2005 Aric Stewart 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
21 /* Msi top level apis directly related to installs */
23 #define WIN32_NO_STATUS
25 #define COM_NO_WINDOWS_H
33 //#include "winerror.h"
34 #include <wine/debug.h>
36 //#include "msidefs.h"
41 #include <msiserver.h>
42 #include <wine/unicode.h>
44 WINE_DEFAULT_DEBUG_CHANNEL(msi
);
46 /***********************************************************************
47 * MsiDoActionA (MSI.@)
49 UINT WINAPI
MsiDoActionA( MSIHANDLE hInstall
, LPCSTR szAction
)
54 TRACE("%s\n", debugstr_a(szAction
));
56 szwAction
= strdupAtoW(szAction
);
57 if (szAction
&& !szwAction
)
58 return ERROR_FUNCTION_FAILED
;
60 ret
= MsiDoActionW( hInstall
, szwAction
);
61 msi_free( szwAction
);
65 /***********************************************************************
66 * MsiDoActionW (MSI.@)
68 UINT WINAPI
MsiDoActionW( MSIHANDLE hInstall
, LPCWSTR szAction
)
73 TRACE("%s\n",debugstr_w(szAction
));
76 return ERROR_INVALID_PARAMETER
;
78 package
= msihandle2msiinfo( hInstall
, MSIHANDLETYPE_PACKAGE
);
83 IWineMsiRemotePackage
*remote_package
;
85 remote_package
= (IWineMsiRemotePackage
*)msi_get_remote( hInstall
);
87 return ERROR_INVALID_HANDLE
;
89 action
= SysAllocString( szAction
);
92 IWineMsiRemotePackage_Release( remote_package
);
93 return ERROR_OUTOFMEMORY
;
96 hr
= IWineMsiRemotePackage_DoAction( remote_package
, action
);
98 SysFreeString( action
);
99 IWineMsiRemotePackage_Release( remote_package
);
103 if (HRESULT_FACILITY(hr
) == FACILITY_WIN32
)
104 return HRESULT_CODE(hr
);
106 return ERROR_FUNCTION_FAILED
;
109 return ERROR_SUCCESS
;
112 ret
= ACTION_PerformUIAction( package
, szAction
, SCRIPT_NONE
);
113 msiobj_release( &package
->hdr
);
118 /***********************************************************************
119 * MsiSequenceA (MSI.@)
121 UINT WINAPI
MsiSequenceA( MSIHANDLE hInstall
, LPCSTR szTable
, INT iSequenceMode
)
126 TRACE("%s, %d\n", debugstr_a(szTable
), iSequenceMode
);
128 szwTable
= strdupAtoW(szTable
);
129 if (szTable
&& !szwTable
)
130 return ERROR_FUNCTION_FAILED
;
132 ret
= MsiSequenceW( hInstall
, szwTable
, iSequenceMode
);
133 msi_free( szwTable
);
137 /***********************************************************************
138 * MsiSequenceW (MSI.@)
140 UINT WINAPI
MsiSequenceW( MSIHANDLE hInstall
, LPCWSTR szTable
, INT iSequenceMode
)
145 TRACE("%s, %d\n", debugstr_w(szTable
), iSequenceMode
);
147 package
= msihandle2msiinfo( hInstall
, MSIHANDLETYPE_PACKAGE
);
152 IWineMsiRemotePackage
*remote_package
;
154 remote_package
= (IWineMsiRemotePackage
*)msi_get_remote( hInstall
);
156 return ERROR_INVALID_HANDLE
;
158 table
= SysAllocString( szTable
);
161 IWineMsiRemotePackage_Release( remote_package
);
162 return ERROR_OUTOFMEMORY
;
165 hr
= IWineMsiRemotePackage_Sequence( remote_package
, table
, iSequenceMode
);
167 SysFreeString( table
);
168 IWineMsiRemotePackage_Release( remote_package
);
172 if (HRESULT_FACILITY(hr
) == FACILITY_WIN32
)
173 return HRESULT_CODE(hr
);
175 return ERROR_FUNCTION_FAILED
;
178 return ERROR_SUCCESS
;
180 ret
= MSI_Sequence( package
, szTable
);
181 msiobj_release( &package
->hdr
);
185 UINT
msi_strcpy_to_awstring( const WCHAR
*str
, int len
, awstring
*awbuf
, DWORD
*sz
)
187 UINT r
= ERROR_SUCCESS
;
189 if (awbuf
->str
.w
&& !sz
)
190 return ERROR_INVALID_PARAMETER
;
192 return ERROR_SUCCESS
;
194 if (len
< 0) len
= strlenW( str
);
196 if (awbuf
->unicode
&& awbuf
->str
.w
)
197 memcpy( awbuf
->str
.w
, str
, min(len
+ 1, *sz
) * sizeof(WCHAR
) );
200 int lenA
= WideCharToMultiByte( CP_ACP
, 0, str
, len
+ 1, NULL
, 0, NULL
, NULL
);
202 WideCharToMultiByte( CP_ACP
, 0, str
, len
+ 1, awbuf
->str
.a
, *sz
, NULL
, NULL
);
203 if (awbuf
->str
.a
&& *sz
&& lenA
>= *sz
)
204 awbuf
->str
.a
[*sz
- 1] = 0;
207 if (awbuf
->str
.w
&& len
>= *sz
)
213 const WCHAR
*msi_get_target_folder( MSIPACKAGE
*package
, const WCHAR
*name
)
215 MSIFOLDER
*folder
= msi_get_loaded_folder( package
, name
);
217 if (!folder
) return NULL
;
218 if (!folder
->ResolvedTarget
)
220 MSIFOLDER
*parent
= folder
;
221 while (parent
->Parent
&& strcmpW( parent
->Parent
, parent
->Directory
))
223 parent
= msi_get_loaded_folder( package
, parent
->Parent
);
225 msi_resolve_target_folder( package
, parent
->Directory
, TRUE
);
227 return folder
->ResolvedTarget
;
230 /***********************************************************************
231 * MsiGetTargetPath (internal)
233 static UINT
MSI_GetTargetPath( MSIHANDLE hInstall
, LPCWSTR szFolder
,
234 awstring
*szPathBuf
, LPDWORD pcchPathBuf
)
238 UINT r
= ERROR_FUNCTION_FAILED
;
241 return ERROR_INVALID_PARAMETER
;
243 package
= msihandle2msiinfo( hInstall
, MSIHANDLETYPE_PACKAGE
);
247 IWineMsiRemotePackage
*remote_package
;
252 remote_package
= (IWineMsiRemotePackage
*)msi_get_remote( hInstall
);
254 return ERROR_INVALID_HANDLE
;
256 folder
= SysAllocString( szFolder
);
259 IWineMsiRemotePackage_Release( remote_package
);
260 return ERROR_OUTOFMEMORY
;
264 hr
= IWineMsiRemotePackage_GetTargetPath( remote_package
, folder
, NULL
, &len
);
269 value
= msi_alloc(len
* sizeof(WCHAR
));
272 r
= ERROR_OUTOFMEMORY
;
276 hr
= IWineMsiRemotePackage_GetTargetPath( remote_package
, folder
, value
, &len
);
280 r
= msi_strcpy_to_awstring( value
, len
, szPathBuf
, pcchPathBuf
);
283 IWineMsiRemotePackage_Release( remote_package
);
284 SysFreeString( folder
);
289 if (HRESULT_FACILITY(hr
) == FACILITY_WIN32
)
290 return HRESULT_CODE(hr
);
292 return ERROR_FUNCTION_FAILED
;
298 path
= msi_get_target_folder( package
, szFolder
);
299 msiobj_release( &package
->hdr
);
302 return ERROR_DIRECTORY
;
304 return msi_strcpy_to_awstring( path
, -1, szPathBuf
, pcchPathBuf
);
307 /***********************************************************************
308 * MsiGetTargetPathA (MSI.@)
310 UINT WINAPI
MsiGetTargetPathA( MSIHANDLE hInstall
, LPCSTR szFolder
,
311 LPSTR szPathBuf
, LPDWORD pcchPathBuf
)
317 TRACE("%s %p %p\n", debugstr_a(szFolder
), szPathBuf
, pcchPathBuf
);
319 szwFolder
= strdupAtoW(szFolder
);
320 if (szFolder
&& !szwFolder
)
321 return ERROR_FUNCTION_FAILED
;
323 path
.unicode
= FALSE
;
324 path
.str
.a
= szPathBuf
;
326 r
= MSI_GetTargetPath( hInstall
, szwFolder
, &path
, pcchPathBuf
);
328 msi_free( szwFolder
);
333 /***********************************************************************
334 * MsiGetTargetPathW (MSI.@)
336 UINT WINAPI
MsiGetTargetPathW( MSIHANDLE hInstall
, LPCWSTR szFolder
,
337 LPWSTR szPathBuf
, LPDWORD pcchPathBuf
)
341 TRACE("%s %p %p\n", debugstr_w(szFolder
), szPathBuf
, pcchPathBuf
);
344 path
.str
.w
= szPathBuf
;
346 return MSI_GetTargetPath( hInstall
, szFolder
, &path
, pcchPathBuf
);
349 static WCHAR
*get_source_root( MSIPACKAGE
*package
)
351 msi_set_sourcedir_props( package
, FALSE
);
352 return msi_dup_property( package
->db
, szSourceDir
);
355 WCHAR
*msi_resolve_source_folder( MSIPACKAGE
*package
, const WCHAR
*name
, MSIFOLDER
**folder
)
358 LPWSTR p
, path
= NULL
, parent
;
360 TRACE("working to resolve %s\n", debugstr_w(name
));
362 if (!strcmpW( name
, szSourceDir
)) name
= szTargetDir
;
363 if (!(f
= msi_get_loaded_folder( package
, name
))) return NULL
;
365 /* special resolving for root dir */
366 if (!strcmpW( name
, szTargetDir
) && !f
->ResolvedSource
)
368 f
->ResolvedSource
= get_source_root( package
);
370 if (folder
) *folder
= f
;
371 if (f
->ResolvedSource
)
373 path
= strdupW( f
->ResolvedSource
);
374 TRACE(" already resolved to %s\n", debugstr_w(path
));
377 if (!f
->Parent
) return path
;
379 TRACE(" ! parent is %s\n", debugstr_w(parent
));
381 p
= msi_resolve_source_folder( package
, parent
, NULL
);
383 if (package
->WordCount
& msidbSumInfoSourceTypeCompressed
)
384 path
= get_source_root( package
);
385 else if (package
->WordCount
& msidbSumInfoSourceTypeSFN
)
386 path
= msi_build_directory_name( 3, p
, f
->SourceShortPath
, NULL
);
388 path
= msi_build_directory_name( 3, p
, f
->SourceLongPath
, NULL
);
390 TRACE("-> %s\n", debugstr_w(path
));
391 f
->ResolvedSource
= strdupW( path
);
397 /***********************************************************************
398 * MSI_GetSourcePath (internal)
400 static UINT
MSI_GetSourcePath( MSIHANDLE hInstall
, LPCWSTR szFolder
,
401 awstring
*szPathBuf
, LPDWORD pcchPathBuf
)
405 UINT r
= ERROR_FUNCTION_FAILED
;
407 TRACE("%s %p %p\n", debugstr_w(szFolder
), szPathBuf
, pcchPathBuf
);
410 return ERROR_INVALID_PARAMETER
;
412 package
= msihandle2msiinfo( hInstall
, MSIHANDLETYPE_PACKAGE
);
416 IWineMsiRemotePackage
*remote_package
;
421 remote_package
= (IWineMsiRemotePackage
*)msi_get_remote( hInstall
);
423 return ERROR_INVALID_HANDLE
;
425 folder
= SysAllocString( szFolder
);
428 IWineMsiRemotePackage_Release( remote_package
);
429 return ERROR_OUTOFMEMORY
;
433 hr
= IWineMsiRemotePackage_GetSourcePath( remote_package
, folder
, NULL
, &len
);
438 value
= msi_alloc(len
* sizeof(WCHAR
));
441 r
= ERROR_OUTOFMEMORY
;
445 hr
= IWineMsiRemotePackage_GetSourcePath( remote_package
, folder
, value
, &len
);
449 r
= msi_strcpy_to_awstring( value
, len
, szPathBuf
, pcchPathBuf
);
452 IWineMsiRemotePackage_Release( remote_package
);
453 SysFreeString( folder
);
458 if (HRESULT_FACILITY(hr
) == FACILITY_WIN32
)
459 return HRESULT_CODE(hr
);
461 return ERROR_FUNCTION_FAILED
;
467 if (szPathBuf
->str
.w
&& !pcchPathBuf
)
469 msiobj_release( &package
->hdr
);
470 return ERROR_INVALID_PARAMETER
;
473 path
= msi_resolve_source_folder( package
, szFolder
, NULL
);
474 msiobj_release( &package
->hdr
);
476 TRACE("path = %s\n", debugstr_w(path
));
478 return ERROR_DIRECTORY
;
480 r
= msi_strcpy_to_awstring( path
, -1, szPathBuf
, pcchPathBuf
);
485 /***********************************************************************
486 * MsiGetSourcePathA (MSI.@)
488 UINT WINAPI
MsiGetSourcePathA( MSIHANDLE hInstall
, LPCSTR szFolder
,
489 LPSTR szPathBuf
, LPDWORD pcchPathBuf
)
495 TRACE("%s %p %p\n", debugstr_a(szFolder
), szPathBuf
, pcchPathBuf
);
498 str
.str
.a
= szPathBuf
;
500 folder
= strdupAtoW( szFolder
);
501 r
= MSI_GetSourcePath( hInstall
, folder
, &str
, pcchPathBuf
);
507 /***********************************************************************
508 * MsiGetSourcePathW (MSI.@)
510 UINT WINAPI
MsiGetSourcePathW( MSIHANDLE hInstall
, LPCWSTR szFolder
,
511 LPWSTR szPathBuf
, LPDWORD pcchPathBuf
)
515 TRACE("%s %p %p\n", debugstr_w(szFolder
), szPathBuf
, pcchPathBuf
);
518 str
.str
.w
= szPathBuf
;
520 return MSI_GetSourcePath( hInstall
, szFolder
, &str
, pcchPathBuf
);
523 /***********************************************************************
524 * MsiSetTargetPathA (MSI.@)
526 UINT WINAPI
MsiSetTargetPathA( MSIHANDLE hInstall
, LPCSTR szFolder
,
527 LPCSTR szFolderPath
)
529 LPWSTR szwFolder
= NULL
, szwFolderPath
= NULL
;
530 UINT rc
= ERROR_OUTOFMEMORY
;
532 if ( !szFolder
|| !szFolderPath
)
533 return ERROR_INVALID_PARAMETER
;
535 szwFolder
= strdupAtoW(szFolder
);
536 szwFolderPath
= strdupAtoW(szFolderPath
);
537 if (!szwFolder
|| !szwFolderPath
)
540 rc
= MsiSetTargetPathW( hInstall
, szwFolder
, szwFolderPath
);
544 msi_free(szwFolderPath
);
549 static void set_target_path( MSIPACKAGE
*package
, MSIFOLDER
*folder
, const WCHAR
*path
)
555 if (!(target_path
= msi_normalize_path( path
))) return;
556 if (strcmpW( target_path
, folder
->ResolvedTarget
))
558 msi_free( folder
->ResolvedTarget
);
559 folder
->ResolvedTarget
= target_path
;
560 msi_set_property( package
->db
, folder
->Directory
, folder
->ResolvedTarget
, -1 );
562 LIST_FOR_EACH_ENTRY( fl
, &folder
->children
, FolderList
, entry
)
565 msi_resolve_target_folder( package
, child
->Directory
, FALSE
);
568 else msi_free( target_path
);
571 UINT
MSI_SetTargetPathW( MSIPACKAGE
*package
, LPCWSTR szFolder
, LPCWSTR szFolderPath
)
577 TRACE("%p %s %s\n", package
, debugstr_w(szFolder
), debugstr_w(szFolderPath
));
579 attrib
= GetFileAttributesW(szFolderPath
);
580 /* native MSI tests writeability by making temporary files at each drive */
581 if (attrib
!= INVALID_FILE_ATTRIBUTES
&&
582 (attrib
& FILE_ATTRIBUTE_OFFLINE
|| attrib
& FILE_ATTRIBUTE_READONLY
))
584 return ERROR_FUNCTION_FAILED
;
586 if (!(folder
= msi_get_loaded_folder( package
, szFolder
))) return ERROR_DIRECTORY
;
588 set_target_path( package
, folder
, szFolderPath
);
590 LIST_FOR_EACH_ENTRY( file
, &package
->files
, MSIFILE
, entry
)
593 MSICOMPONENT
*comp
= file
->Component
;
595 if (!comp
->Enabled
|| (comp
->assembly
&& !comp
->assembly
->application
)) continue;
597 dir
= msi_get_target_folder( package
, comp
->Directory
);
598 msi_free( file
->TargetPath
);
599 file
->TargetPath
= msi_build_directory_name( 2, dir
, file
->FileName
);
601 return ERROR_SUCCESS
;
604 /***********************************************************************
605 * MsiSetTargetPathW (MSI.@)
607 UINT WINAPI
MsiSetTargetPathW(MSIHANDLE hInstall
, LPCWSTR szFolder
,
608 LPCWSTR szFolderPath
)
613 TRACE("%s %s\n",debugstr_w(szFolder
),debugstr_w(szFolderPath
));
615 if ( !szFolder
|| !szFolderPath
)
616 return ERROR_INVALID_PARAMETER
;
618 package
= msihandle2msiinfo(hInstall
, MSIHANDLETYPE_PACKAGE
);
623 IWineMsiRemotePackage
*remote_package
;
625 remote_package
= (IWineMsiRemotePackage
*)msi_get_remote( hInstall
);
627 return ERROR_INVALID_HANDLE
;
629 folder
= SysAllocString( szFolder
);
630 path
= SysAllocString( szFolderPath
);
631 if (!folder
|| !path
)
633 SysFreeString(folder
);
635 IWineMsiRemotePackage_Release( remote_package
);
636 return ERROR_OUTOFMEMORY
;
639 hr
= IWineMsiRemotePackage_SetTargetPath( remote_package
, folder
, path
);
641 SysFreeString(folder
);
643 IWineMsiRemotePackage_Release( remote_package
);
647 if (HRESULT_FACILITY(hr
) == FACILITY_WIN32
)
648 return HRESULT_CODE(hr
);
650 return ERROR_FUNCTION_FAILED
;
653 return ERROR_SUCCESS
;
656 ret
= MSI_SetTargetPathW( package
, szFolder
, szFolderPath
);
657 msiobj_release( &package
->hdr
);
661 /***********************************************************************
664 * Returns an internal installer state (if it is running in a mode iRunMode)
667 * hInstall [I] Handle to the installation
668 * hRunMode [I] Checking run mode
669 * MSIRUNMODE_ADMIN Administrative mode
670 * MSIRUNMODE_ADVERTISE Advertisement mode
671 * MSIRUNMODE_MAINTENANCE Maintenance mode
672 * MSIRUNMODE_ROLLBACKENABLED Rollback is enabled
673 * MSIRUNMODE_LOGENABLED Log file is writing
674 * MSIRUNMODE_OPERATIONS Operations in progress??
675 * MSIRUNMODE_REBOOTATEND We need to reboot after installation completed
676 * MSIRUNMODE_REBOOTNOW We need to reboot to continue the installation
677 * MSIRUNMODE_CABINET Files from cabinet are installed
678 * MSIRUNMODE_SOURCESHORTNAMES Long names in source files is suppressed
679 * MSIRUNMODE_TARGETSHORTNAMES Long names in destination files is suppressed
680 * MSIRUNMODE_RESERVED11 Reserved
681 * MSIRUNMODE_WINDOWS9X Running under Windows95/98
682 * MSIRUNMODE_ZAWENABLED Demand installation is supported
683 * MSIRUNMODE_RESERVED14 Reserved
684 * MSIRUNMODE_RESERVED15 Reserved
685 * MSIRUNMODE_SCHEDULED called from install script
686 * MSIRUNMODE_ROLLBACK called from rollback script
687 * MSIRUNMODE_COMMIT called from commit script
691 * Not in the state: FALSE
694 BOOL WINAPI
MsiGetMode(MSIHANDLE hInstall
, MSIRUNMODE iRunMode
)
699 TRACE("%d %d\n", hInstall
, iRunMode
);
701 package
= msihandle2msiinfo(hInstall
, MSIHANDLETYPE_PACKAGE
);
706 IWineMsiRemotePackage
*remote_package
;
708 remote_package
= (IWineMsiRemotePackage
*)msi_get_remote(hInstall
);
712 hr
= IWineMsiRemotePackage_GetMode(remote_package
, iRunMode
, &ret
);
713 IWineMsiRemotePackage_Release(remote_package
);
723 case MSIRUNMODE_ADMIN
:
724 FIXME("no support for administrative installs\n");
727 case MSIRUNMODE_ADVERTISE
:
728 FIXME("no support for advertised installs\n");
731 case MSIRUNMODE_WINDOWS9X
:
732 if (GetVersion() & 0x80000000)
736 case MSIRUNMODE_OPERATIONS
:
737 case MSIRUNMODE_RESERVED11
:
738 case MSIRUNMODE_RESERVED14
:
739 case MSIRUNMODE_RESERVED15
:
742 case MSIRUNMODE_SCHEDULED
:
743 r
= package
->scheduled_action_running
;
746 case MSIRUNMODE_ROLLBACK
:
747 r
= package
->rollback_action_running
;
750 case MSIRUNMODE_COMMIT
:
751 r
= package
->commit_action_running
;
754 case MSIRUNMODE_MAINTENANCE
:
755 r
= msi_get_property_int( package
->db
, szInstalled
, 0 ) != 0;
758 case MSIRUNMODE_ROLLBACKENABLED
:
759 r
= msi_get_property_int( package
->db
, szRollbackDisabled
, 0 ) == 0;
762 case MSIRUNMODE_REBOOTATEND
:
763 r
= package
->need_reboot_at_end
;
766 case MSIRUNMODE_REBOOTNOW
:
767 r
= package
->need_reboot_now
;
770 case MSIRUNMODE_LOGENABLED
:
771 r
= (package
->log_file
!= INVALID_HANDLE_VALUE
);
775 FIXME("unimplemented run mode: %d\n", iRunMode
);
779 msiobj_release( &package
->hdr
);
783 /***********************************************************************
786 UINT WINAPI
MsiSetMode(MSIHANDLE hInstall
, MSIRUNMODE iRunMode
, BOOL fState
)
791 TRACE("%d %d %d\n", hInstall
, iRunMode
, fState
);
793 package
= msihandle2msiinfo( hInstall
, MSIHANDLETYPE_PACKAGE
);
797 IWineMsiRemotePackage
*remote_package
;
799 remote_package
= (IWineMsiRemotePackage
*)msi_get_remote( hInstall
);
803 hr
= IWineMsiRemotePackage_SetMode( remote_package
, iRunMode
, fState
);
804 IWineMsiRemotePackage_Release( remote_package
);
808 if (HRESULT_FACILITY(hr
) == FACILITY_WIN32
)
809 return HRESULT_CODE(hr
);
811 return ERROR_FUNCTION_FAILED
;
814 return ERROR_SUCCESS
;
819 case MSIRUNMODE_REBOOTATEND
:
820 package
->need_reboot_at_end
= (fState
!= 0);
824 case MSIRUNMODE_REBOOTNOW
:
825 package
->need_reboot_now
= (fState
!= 0);
830 r
= ERROR_ACCESS_DENIED
;
833 msiobj_release( &package
->hdr
);
837 /***********************************************************************
838 * MsiSetFeatureStateA (MSI.@)
840 * According to the docs, when this is called it immediately recalculates
841 * all the component states as well
843 UINT WINAPI
MsiSetFeatureStateA(MSIHANDLE hInstall
, LPCSTR szFeature
,
846 LPWSTR szwFeature
= NULL
;
849 szwFeature
= strdupAtoW(szFeature
);
852 return ERROR_FUNCTION_FAILED
;
854 rc
= MsiSetFeatureStateW(hInstall
,szwFeature
, iState
);
856 msi_free(szwFeature
);
861 /* update component state based on a feature change */
862 void ACTION_UpdateComponentStates( MSIPACKAGE
*package
, MSIFEATURE
*feature
)
864 INSTALLSTATE newstate
;
867 newstate
= feature
->ActionRequest
;
868 if (newstate
== INSTALLSTATE_ABSENT
) newstate
= INSTALLSTATE_UNKNOWN
;
870 LIST_FOR_EACH_ENTRY(cl
, &feature
->Components
, ComponentList
, entry
)
872 MSICOMPONENT
*component
= cl
->component
;
874 if (!component
->Enabled
) continue;
876 TRACE("Modifying (%d): Component %s (Installed %d, Action %d, Request %d)\n",
877 newstate
, debugstr_w(component
->Component
), component
->Installed
,
878 component
->Action
, component
->ActionRequest
);
880 if (newstate
== INSTALLSTATE_LOCAL
)
882 component
->Action
= INSTALLSTATE_LOCAL
;
883 component
->ActionRequest
= INSTALLSTATE_LOCAL
;
887 ComponentList
*clist
;
890 component
->hasLocalFeature
= FALSE
;
892 component
->Action
= newstate
;
893 component
->ActionRequest
= newstate
;
894 /* if any other feature wants it local we need to set it local */
895 LIST_FOR_EACH_ENTRY(f
, &package
->features
, MSIFEATURE
, entry
)
897 if ( f
->ActionRequest
!= INSTALLSTATE_LOCAL
&&
898 f
->ActionRequest
!= INSTALLSTATE_SOURCE
)
902 LIST_FOR_EACH_ENTRY(clist
, &f
->Components
, ComponentList
, entry
)
904 if (clist
->component
== component
&&
905 (f
->ActionRequest
== INSTALLSTATE_LOCAL
||
906 f
->ActionRequest
== INSTALLSTATE_SOURCE
))
908 TRACE("Saved by %s\n", debugstr_w(f
->Feature
));
909 component
->hasLocalFeature
= TRUE
;
911 if (component
->Attributes
& msidbComponentAttributesOptional
)
913 if (f
->Attributes
& msidbFeatureAttributesFavorSource
)
915 component
->Action
= INSTALLSTATE_SOURCE
;
916 component
->ActionRequest
= INSTALLSTATE_SOURCE
;
920 component
->Action
= INSTALLSTATE_LOCAL
;
921 component
->ActionRequest
= INSTALLSTATE_LOCAL
;
924 else if (component
->Attributes
& msidbComponentAttributesSourceOnly
)
926 component
->Action
= INSTALLSTATE_SOURCE
;
927 component
->ActionRequest
= INSTALLSTATE_SOURCE
;
931 component
->Action
= INSTALLSTATE_LOCAL
;
932 component
->ActionRequest
= INSTALLSTATE_LOCAL
;
938 TRACE("Result (%d): Component %s (Installed %d, Action %d, Request %d)\n",
939 newstate
, debugstr_w(component
->Component
), component
->Installed
,
940 component
->Action
, component
->ActionRequest
);
944 UINT
MSI_SetFeatureStateW( MSIPACKAGE
*package
, LPCWSTR szFeature
, INSTALLSTATE iState
)
946 UINT rc
= ERROR_SUCCESS
;
947 MSIFEATURE
*feature
, *child
;
949 TRACE("%s %i\n", debugstr_w(szFeature
), iState
);
951 feature
= msi_get_loaded_feature( package
, szFeature
);
953 return ERROR_UNKNOWN_FEATURE
;
955 if (iState
== INSTALLSTATE_ADVERTISED
&&
956 feature
->Attributes
& msidbFeatureAttributesDisallowAdvertise
)
957 return ERROR_FUNCTION_FAILED
;
959 feature
->ActionRequest
= iState
;
961 ACTION_UpdateComponentStates( package
, feature
);
963 /* update all the features that are children of this feature */
964 LIST_FOR_EACH_ENTRY( child
, &package
->features
, MSIFEATURE
, entry
)
966 if (child
->Feature_Parent
&& !strcmpW( szFeature
, child
->Feature_Parent
))
967 MSI_SetFeatureStateW(package
, child
->Feature
, iState
);
973 /***********************************************************************
974 * MsiSetFeatureStateW (MSI.@)
976 UINT WINAPI
MsiSetFeatureStateW(MSIHANDLE hInstall
, LPCWSTR szFeature
,
980 UINT rc
= ERROR_SUCCESS
;
982 TRACE("%s %i\n",debugstr_w(szFeature
), iState
);
984 package
= msihandle2msiinfo(hInstall
, MSIHANDLETYPE_PACKAGE
);
989 IWineMsiRemotePackage
*remote_package
;
991 remote_package
= (IWineMsiRemotePackage
*)msi_get_remote(hInstall
);
993 return ERROR_INVALID_HANDLE
;
995 feature
= SysAllocString(szFeature
);
998 IWineMsiRemotePackage_Release(remote_package
);
999 return ERROR_OUTOFMEMORY
;
1002 hr
= IWineMsiRemotePackage_SetFeatureState(remote_package
, feature
, iState
);
1004 SysFreeString(feature
);
1005 IWineMsiRemotePackage_Release(remote_package
);
1009 if (HRESULT_FACILITY(hr
) == FACILITY_WIN32
)
1010 return HRESULT_CODE(hr
);
1012 return ERROR_FUNCTION_FAILED
;
1015 return ERROR_SUCCESS
;
1018 rc
= MSI_SetFeatureStateW(package
,szFeature
,iState
);
1020 msiobj_release( &package
->hdr
);
1024 /***********************************************************************
1025 * MsiSetFeatureAttributesA (MSI.@)
1027 UINT WINAPI
MsiSetFeatureAttributesA( MSIHANDLE handle
, LPCSTR feature
, DWORD attrs
)
1030 WCHAR
*featureW
= NULL
;
1032 TRACE("%u, %s, 0x%08x\n", handle
, debugstr_a(feature
), attrs
);
1034 if (feature
&& !(featureW
= strdupAtoW( feature
))) return ERROR_OUTOFMEMORY
;
1036 r
= MsiSetFeatureAttributesW( handle
, featureW
, attrs
);
1037 msi_free( featureW
);
1041 static DWORD
unmap_feature_attributes( DWORD attrs
)
1045 if (attrs
& INSTALLFEATUREATTRIBUTE_FAVORLOCAL
) ret
= msidbFeatureAttributesFavorLocal
;
1046 if (attrs
& INSTALLFEATUREATTRIBUTE_FAVORSOURCE
) ret
|= msidbFeatureAttributesFavorSource
;
1047 if (attrs
& INSTALLFEATUREATTRIBUTE_FOLLOWPARENT
) ret
|= msidbFeatureAttributesFollowParent
;
1048 if (attrs
& INSTALLFEATUREATTRIBUTE_FAVORADVERTISE
) ret
|= msidbFeatureAttributesFavorAdvertise
;
1049 if (attrs
& INSTALLFEATUREATTRIBUTE_DISALLOWADVERTISE
) ret
|= msidbFeatureAttributesDisallowAdvertise
;
1050 if (attrs
& INSTALLFEATUREATTRIBUTE_NOUNSUPPORTEDADVERTISE
) ret
|= msidbFeatureAttributesNoUnsupportedAdvertise
;
1054 /***********************************************************************
1055 * MsiSetFeatureAttributesW (MSI.@)
1057 UINT WINAPI
MsiSetFeatureAttributesW( MSIHANDLE handle
, LPCWSTR name
, DWORD attrs
)
1059 MSIPACKAGE
*package
;
1060 MSIFEATURE
*feature
;
1063 TRACE("%u, %s, 0x%08x\n", handle
, debugstr_w(name
), attrs
);
1065 if (!name
|| !name
[0]) return ERROR_UNKNOWN_FEATURE
;
1067 if (!(package
= msihandle2msiinfo( handle
, MSIHANDLETYPE_PACKAGE
)))
1068 return ERROR_INVALID_HANDLE
;
1070 costing
= msi_dup_property( package
->db
, szCostingComplete
);
1071 if (!costing
|| !strcmpW( costing
, szOne
))
1073 msi_free( costing
);
1074 msiobj_release( &package
->hdr
);
1075 return ERROR_FUNCTION_FAILED
;
1077 msi_free( costing
);
1078 if (!(feature
= msi_get_loaded_feature( package
, name
)))
1080 msiobj_release( &package
->hdr
);
1081 return ERROR_UNKNOWN_FEATURE
;
1083 feature
->Attributes
= unmap_feature_attributes( attrs
);
1084 msiobj_release( &package
->hdr
);
1085 return ERROR_SUCCESS
;
1088 /***********************************************************************
1089 * MsiGetFeatureStateA (MSI.@)
1091 UINT WINAPI
MsiGetFeatureStateA(MSIHANDLE hInstall
, LPCSTR szFeature
,
1092 INSTALLSTATE
*piInstalled
, INSTALLSTATE
*piAction
)
1094 LPWSTR szwFeature
= NULL
;
1097 if (szFeature
&& !(szwFeature
= strdupAtoW(szFeature
))) return ERROR_OUTOFMEMORY
;
1099 rc
= MsiGetFeatureStateW(hInstall
, szwFeature
, piInstalled
, piAction
);
1100 msi_free( szwFeature
);
1104 UINT
MSI_GetFeatureStateW(MSIPACKAGE
*package
, LPCWSTR szFeature
,
1105 INSTALLSTATE
*piInstalled
, INSTALLSTATE
*piAction
)
1107 MSIFEATURE
*feature
;
1109 feature
= msi_get_loaded_feature(package
,szFeature
);
1111 return ERROR_UNKNOWN_FEATURE
;
1114 *piInstalled
= feature
->Installed
;
1117 *piAction
= feature
->ActionRequest
;
1119 TRACE("returning %i %i\n", feature
->Installed
, feature
->ActionRequest
);
1121 return ERROR_SUCCESS
;
1124 /***********************************************************************
1125 * MsiGetFeatureStateW (MSI.@)
1127 UINT WINAPI
MsiGetFeatureStateW(MSIHANDLE hInstall
, LPCWSTR szFeature
,
1128 INSTALLSTATE
*piInstalled
, INSTALLSTATE
*piAction
)
1130 MSIPACKAGE
* package
;
1133 TRACE("%d %s %p %p\n", hInstall
, debugstr_w(szFeature
), piInstalled
, piAction
);
1135 package
= msihandle2msiinfo(hInstall
, MSIHANDLETYPE_PACKAGE
);
1140 IWineMsiRemotePackage
*remote_package
;
1142 remote_package
= (IWineMsiRemotePackage
*)msi_get_remote(hInstall
);
1143 if (!remote_package
)
1144 return ERROR_INVALID_HANDLE
;
1146 feature
= SysAllocString(szFeature
);
1149 IWineMsiRemotePackage_Release(remote_package
);
1150 return ERROR_OUTOFMEMORY
;
1153 hr
= IWineMsiRemotePackage_GetFeatureState(remote_package
, feature
,
1154 piInstalled
, piAction
);
1156 SysFreeString(feature
);
1157 IWineMsiRemotePackage_Release(remote_package
);
1161 if (HRESULT_FACILITY(hr
) == FACILITY_WIN32
)
1162 return HRESULT_CODE(hr
);
1164 return ERROR_FUNCTION_FAILED
;
1167 return ERROR_SUCCESS
;
1170 ret
= MSI_GetFeatureStateW(package
, szFeature
, piInstalled
, piAction
);
1171 msiobj_release( &package
->hdr
);
1175 /***********************************************************************
1176 * MsiGetFeatureCostA (MSI.@)
1178 UINT WINAPI
MsiGetFeatureCostA(MSIHANDLE hInstall
, LPCSTR szFeature
,
1179 MSICOSTTREE iCostTree
, INSTALLSTATE iState
, LPINT piCost
)
1181 LPWSTR szwFeature
= NULL
;
1184 szwFeature
= strdupAtoW(szFeature
);
1186 rc
= MsiGetFeatureCostW(hInstall
, szwFeature
, iCostTree
, iState
, piCost
);
1188 msi_free(szwFeature
);
1193 static INT
feature_cost( MSIFEATURE
*feature
)
1198 LIST_FOR_EACH_ENTRY( comp
, &feature
->Components
, MSICOMPONENT
, entry
)
1205 UINT
MSI_GetFeatureCost( MSIPACKAGE
*package
, MSIFEATURE
*feature
, MSICOSTTREE tree
,
1206 INSTALLSTATE state
, LPINT cost
)
1208 TRACE("%s, %u, %d, %p\n", debugstr_w(feature
->Feature
), tree
, state
, cost
);
1213 case MSICOSTTREE_CHILDREN
:
1217 LIST_FOR_EACH_ENTRY( child
, &feature
->Children
, MSIFEATURE
, entry
)
1219 if (child
->ActionRequest
== state
)
1220 *cost
+= feature_cost( child
);
1224 case MSICOSTTREE_PARENTS
:
1226 const WCHAR
*feature_parent
= feature
->Feature_Parent
;
1229 MSIFEATURE
*parent
= msi_get_loaded_feature( package
, feature_parent
);
1233 if (parent
->ActionRequest
== state
)
1234 *cost
+= feature_cost( parent
);
1236 feature_parent
= parent
->Feature_Parent
;
1240 case MSICOSTTREE_SELFONLY
:
1241 if (feature
->ActionRequest
== state
)
1242 *cost
= feature_cost( feature
);
1246 WARN("unhandled cost tree %u\n", tree
);
1251 return ERROR_SUCCESS
;
1254 /***********************************************************************
1255 * MsiGetFeatureCostW (MSI.@)
1257 UINT WINAPI
MsiGetFeatureCostW(MSIHANDLE hInstall
, LPCWSTR szFeature
,
1258 MSICOSTTREE iCostTree
, INSTALLSTATE iState
, LPINT piCost
)
1260 MSIPACKAGE
*package
;
1261 MSIFEATURE
*feature
;
1264 TRACE("(%d %s %i %i %p)\n", hInstall
, debugstr_w(szFeature
),
1265 iCostTree
, iState
, piCost
);
1267 package
= msihandle2msiinfo(hInstall
, MSIHANDLETYPE_PACKAGE
);
1272 IWineMsiRemotePackage
*remote_package
;
1274 remote_package
= (IWineMsiRemotePackage
*)msi_get_remote(hInstall
);
1275 if (!remote_package
)
1276 return ERROR_INVALID_HANDLE
;
1278 feature
= SysAllocString(szFeature
);
1281 IWineMsiRemotePackage_Release(remote_package
);
1282 return ERROR_OUTOFMEMORY
;
1285 hr
= IWineMsiRemotePackage_GetFeatureCost(remote_package
, feature
,
1286 iCostTree
, iState
, piCost
);
1288 SysFreeString(feature
);
1289 IWineMsiRemotePackage_Release(remote_package
);
1293 if (HRESULT_FACILITY(hr
) == FACILITY_WIN32
)
1294 return HRESULT_CODE(hr
);
1296 return ERROR_FUNCTION_FAILED
;
1299 return ERROR_SUCCESS
;
1302 feature
= msi_get_loaded_feature(package
, szFeature
);
1305 ret
= MSI_GetFeatureCost(package
, feature
, iCostTree
, iState
, piCost
);
1307 ret
= ERROR_UNKNOWN_FEATURE
;
1309 msiobj_release( &package
->hdr
);
1313 /***********************************************************************
1314 * MsiGetFeatureInfoA (MSI.@)
1316 UINT WINAPI
MsiGetFeatureInfoA( MSIHANDLE handle
, LPCSTR feature
, LPDWORD attrs
,
1317 LPSTR title
, LPDWORD title_len
, LPSTR help
, LPDWORD help_len
)
1320 WCHAR
*titleW
= NULL
, *helpW
= NULL
, *featureW
= NULL
;
1322 TRACE("%u, %s, %p, %p, %p, %p, %p\n", handle
, debugstr_a(feature
), attrs
, title
,
1323 title_len
, help
, help_len
);
1325 if (feature
&& !(featureW
= strdupAtoW( feature
))) return ERROR_OUTOFMEMORY
;
1327 if (title
&& title_len
&& !(titleW
= msi_alloc( *title_len
* sizeof(WCHAR
) )))
1329 msi_free( featureW
);
1330 return ERROR_OUTOFMEMORY
;
1332 if (help
&& help_len
&& !(helpW
= msi_alloc( *help_len
* sizeof(WCHAR
) )))
1334 msi_free( featureW
);
1336 return ERROR_OUTOFMEMORY
;
1338 r
= MsiGetFeatureInfoW( handle
, featureW
, attrs
, titleW
, title_len
, helpW
, help_len
);
1339 if (r
== ERROR_SUCCESS
)
1341 if (titleW
) WideCharToMultiByte( CP_ACP
, 0, titleW
, -1, title
, *title_len
+ 1, NULL
, NULL
);
1342 if (helpW
) WideCharToMultiByte( CP_ACP
, 0, helpW
, -1, help
, *help_len
+ 1, NULL
, NULL
);
1346 msi_free( featureW
);
1350 static DWORD
map_feature_attributes( DWORD attrs
)
1354 if (attrs
== msidbFeatureAttributesFavorLocal
) ret
|= INSTALLFEATUREATTRIBUTE_FAVORLOCAL
;
1355 if (attrs
& msidbFeatureAttributesFavorSource
) ret
|= INSTALLFEATUREATTRIBUTE_FAVORSOURCE
;
1356 if (attrs
& msidbFeatureAttributesFollowParent
) ret
|= INSTALLFEATUREATTRIBUTE_FOLLOWPARENT
;
1357 if (attrs
& msidbFeatureAttributesFavorAdvertise
) ret
|= INSTALLFEATUREATTRIBUTE_FAVORADVERTISE
;
1358 if (attrs
& msidbFeatureAttributesDisallowAdvertise
) ret
|= INSTALLFEATUREATTRIBUTE_DISALLOWADVERTISE
;
1359 if (attrs
& msidbFeatureAttributesNoUnsupportedAdvertise
) ret
|= INSTALLFEATUREATTRIBUTE_NOUNSUPPORTEDADVERTISE
;
1363 static UINT
MSI_GetFeatureInfo( MSIPACKAGE
*package
, LPCWSTR name
, LPDWORD attrs
,
1364 LPWSTR title
, LPDWORD title_len
, LPWSTR help
, LPDWORD help_len
)
1366 UINT r
= ERROR_SUCCESS
;
1367 MSIFEATURE
*feature
= msi_get_loaded_feature( package
, name
);
1370 if (!feature
) return ERROR_UNKNOWN_FEATURE
;
1371 if (attrs
) *attrs
= map_feature_attributes( feature
->Attributes
);
1374 if (feature
->Title
) len
= strlenW( feature
->Title
);
1376 if (*title_len
<= len
)
1379 if (title
) r
= ERROR_MORE_DATA
;
1383 if (feature
->Title
) strcpyW( title
, feature
->Title
);
1390 if (feature
->Description
) len
= strlenW( feature
->Description
);
1392 if (*help_len
<= len
)
1395 if (help
) r
= ERROR_MORE_DATA
;
1399 if (feature
->Description
) strcpyW( help
, feature
->Description
);
1407 /***********************************************************************
1408 * MsiGetFeatureInfoW (MSI.@)
1410 UINT WINAPI
MsiGetFeatureInfoW( MSIHANDLE handle
, LPCWSTR feature
, LPDWORD attrs
,
1411 LPWSTR title
, LPDWORD title_len
, LPWSTR help
, LPDWORD help_len
)
1414 MSIPACKAGE
*package
;
1416 TRACE("%u, %s, %p, %p, %p, %p, %p\n", handle
, debugstr_w(feature
), attrs
, title
,
1417 title_len
, help
, help_len
);
1419 if (!feature
) return ERROR_INVALID_PARAMETER
;
1421 if (!(package
= msihandle2msiinfo( handle
, MSIHANDLETYPE_PACKAGE
)))
1422 return ERROR_INVALID_HANDLE
;
1424 /* features may not have been loaded yet */
1425 msi_load_all_components( package
);
1426 msi_load_all_features( package
);
1428 r
= MSI_GetFeatureInfo( package
, feature
, attrs
, title
, title_len
, help
, help_len
);
1429 msiobj_release( &package
->hdr
);
1433 /***********************************************************************
1434 * MsiSetComponentStateA (MSI.@)
1436 UINT WINAPI
MsiSetComponentStateA(MSIHANDLE hInstall
, LPCSTR szComponent
,
1437 INSTALLSTATE iState
)
1440 LPWSTR szwComponent
= strdupAtoW(szComponent
);
1442 rc
= MsiSetComponentStateW(hInstall
, szwComponent
, iState
);
1444 msi_free(szwComponent
);
1449 /***********************************************************************
1450 * MsiGetComponentStateA (MSI.@)
1452 UINT WINAPI
MsiGetComponentStateA(MSIHANDLE hInstall
, LPCSTR szComponent
,
1453 INSTALLSTATE
*piInstalled
, INSTALLSTATE
*piAction
)
1455 LPWSTR szwComponent
= NULL
;
1458 szwComponent
= strdupAtoW(szComponent
);
1460 rc
= MsiGetComponentStateW(hInstall
,szwComponent
,piInstalled
, piAction
);
1462 msi_free( szwComponent
);
1467 static UINT
MSI_SetComponentStateW(MSIPACKAGE
*package
, LPCWSTR szComponent
,
1468 INSTALLSTATE iState
)
1472 TRACE("%p %s %d\n", package
, debugstr_w(szComponent
), iState
);
1474 comp
= msi_get_loaded_component(package
, szComponent
);
1476 return ERROR_UNKNOWN_COMPONENT
;
1479 comp
->Action
= iState
;
1481 return ERROR_SUCCESS
;
1484 UINT
MSI_GetComponentStateW(MSIPACKAGE
*package
, LPCWSTR szComponent
,
1485 INSTALLSTATE
*piInstalled
, INSTALLSTATE
*piAction
)
1489 TRACE("%p %s %p %p\n", package
, debugstr_w(szComponent
),
1490 piInstalled
, piAction
);
1492 comp
= msi_get_loaded_component(package
,szComponent
);
1494 return ERROR_UNKNOWN_COMPONENT
;
1499 *piInstalled
= comp
->Installed
;
1501 *piInstalled
= INSTALLSTATE_UNKNOWN
;
1507 *piAction
= comp
->Action
;
1509 *piAction
= INSTALLSTATE_UNKNOWN
;
1512 TRACE("states (%i, %i)\n", comp
->Installed
, comp
->Action
);
1513 return ERROR_SUCCESS
;
1516 /***********************************************************************
1517 * MsiSetComponentStateW (MSI.@)
1519 UINT WINAPI
MsiSetComponentStateW(MSIHANDLE hInstall
, LPCWSTR szComponent
,
1520 INSTALLSTATE iState
)
1522 MSIPACKAGE
* package
;
1525 package
= msihandle2msiinfo(hInstall
, MSIHANDLETYPE_PACKAGE
);
1530 IWineMsiRemotePackage
*remote_package
;
1532 remote_package
= (IWineMsiRemotePackage
*)msi_get_remote(hInstall
);
1533 if (!remote_package
)
1534 return ERROR_INVALID_HANDLE
;
1536 component
= SysAllocString(szComponent
);
1539 IWineMsiRemotePackage_Release(remote_package
);
1540 return ERROR_OUTOFMEMORY
;
1543 hr
= IWineMsiRemotePackage_SetComponentState(remote_package
, component
, iState
);
1545 SysFreeString(component
);
1546 IWineMsiRemotePackage_Release(remote_package
);
1550 if (HRESULT_FACILITY(hr
) == FACILITY_WIN32
)
1551 return HRESULT_CODE(hr
);
1553 return ERROR_FUNCTION_FAILED
;
1556 return ERROR_SUCCESS
;
1559 ret
= MSI_SetComponentStateW(package
, szComponent
, iState
);
1560 msiobj_release(&package
->hdr
);
1564 /***********************************************************************
1565 * MsiGetComponentStateW (MSI.@)
1567 UINT WINAPI
MsiGetComponentStateW(MSIHANDLE hInstall
, LPCWSTR szComponent
,
1568 INSTALLSTATE
*piInstalled
, INSTALLSTATE
*piAction
)
1570 MSIPACKAGE
* package
;
1573 TRACE("%d %s %p %p\n", hInstall
, debugstr_w(szComponent
),
1574 piInstalled
, piAction
);
1576 package
= msihandle2msiinfo(hInstall
, MSIHANDLETYPE_PACKAGE
);
1581 IWineMsiRemotePackage
*remote_package
;
1583 remote_package
= (IWineMsiRemotePackage
*)msi_get_remote(hInstall
);
1584 if (!remote_package
)
1585 return ERROR_INVALID_HANDLE
;
1587 component
= SysAllocString(szComponent
);
1590 IWineMsiRemotePackage_Release(remote_package
);
1591 return ERROR_OUTOFMEMORY
;
1594 hr
= IWineMsiRemotePackage_GetComponentState(remote_package
, component
,
1595 piInstalled
, piAction
);
1597 SysFreeString(component
);
1598 IWineMsiRemotePackage_Release(remote_package
);
1602 if (HRESULT_FACILITY(hr
) == FACILITY_WIN32
)
1603 return HRESULT_CODE(hr
);
1605 return ERROR_FUNCTION_FAILED
;
1608 return ERROR_SUCCESS
;
1611 ret
= MSI_GetComponentStateW( package
, szComponent
, piInstalled
, piAction
);
1612 msiobj_release( &package
->hdr
);
1616 /***********************************************************************
1617 * MsiGetLanguage (MSI.@)
1619 LANGID WINAPI
MsiGetLanguage(MSIHANDLE hInstall
)
1621 MSIPACKAGE
* package
;
1624 package
= msihandle2msiinfo(hInstall
, MSIHANDLETYPE_PACKAGE
);
1629 IWineMsiRemotePackage
*remote_package
;
1631 remote_package
= (IWineMsiRemotePackage
*)msi_get_remote(hInstall
);
1632 if (!remote_package
)
1633 return ERROR_INVALID_HANDLE
;
1635 hr
= IWineMsiRemotePackage_GetLanguage(remote_package
, &lang
);
1643 langid
= msi_get_property_int( package
->db
, szProductLanguage
, 0 );
1644 msiobj_release( &package
->hdr
);
1648 UINT
MSI_SetInstallLevel( MSIPACKAGE
*package
, int iInstallLevel
)
1650 static const WCHAR fmt
[] = { '%','d',0 };
1655 TRACE("%p %i\n", package
, iInstallLevel
);
1657 if (iInstallLevel
> 32767)
1658 return ERROR_INVALID_PARAMETER
;
1660 if (iInstallLevel
< 1)
1661 return MSI_SetFeatureStates( package
);
1663 len
= sprintfW( level
, fmt
, iInstallLevel
);
1664 r
= msi_set_property( package
->db
, szInstallLevel
, level
, len
);
1665 if ( r
== ERROR_SUCCESS
)
1666 r
= MSI_SetFeatureStates( package
);
1671 /***********************************************************************
1672 * MsiSetInstallLevel (MSI.@)
1674 UINT WINAPI
MsiSetInstallLevel(MSIHANDLE hInstall
, int iInstallLevel
)
1676 MSIPACKAGE
* package
;
1679 TRACE("%d %i\n", hInstall
, iInstallLevel
);
1681 package
= msihandle2msiinfo(hInstall
, MSIHANDLETYPE_PACKAGE
);
1685 IWineMsiRemotePackage
*remote_package
;
1687 remote_package
= (IWineMsiRemotePackage
*)msi_get_remote(hInstall
);
1688 if (!remote_package
)
1689 return ERROR_INVALID_HANDLE
;
1691 hr
= IWineMsiRemotePackage_SetInstallLevel(remote_package
, iInstallLevel
);
1693 IWineMsiRemotePackage_Release(remote_package
);
1697 if (HRESULT_FACILITY(hr
) == FACILITY_WIN32
)
1698 return HRESULT_CODE(hr
);
1700 return ERROR_FUNCTION_FAILED
;
1703 return ERROR_SUCCESS
;
1706 r
= MSI_SetInstallLevel( package
, iInstallLevel
);
1708 msiobj_release( &package
->hdr
);
1713 /***********************************************************************
1714 * MsiGetFeatureValidStatesW (MSI.@)
1716 UINT WINAPI
MsiGetFeatureValidStatesW(MSIHANDLE hInstall
, LPCWSTR szFeature
,
1717 LPDWORD pInstallState
)
1719 if(pInstallState
) *pInstallState
= 1<<INSTALLSTATE_LOCAL
;
1720 FIXME("%d %s %p stub returning %d\n",
1721 hInstall
, debugstr_w(szFeature
), pInstallState
, pInstallState
? *pInstallState
: 0);
1723 return ERROR_SUCCESS
;
1726 /***********************************************************************
1727 * MsiGetFeatureValidStatesA (MSI.@)
1729 UINT WINAPI
MsiGetFeatureValidStatesA(MSIHANDLE hInstall
, LPCSTR szFeature
,
1730 LPDWORD pInstallState
)
1733 LPWSTR szwFeature
= strdupAtoW(szFeature
);
1735 ret
= MsiGetFeatureValidStatesW(hInstall
, szwFeature
, pInstallState
);
1737 msi_free(szwFeature
);