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 */
30 #include "wine/debug.h"
35 #include "msiserver.h"
36 #include "wine/unicode.h"
38 WINE_DEFAULT_DEBUG_CHANNEL(msi
);
40 /***********************************************************************
41 * MsiDoActionA (MSI.@)
43 UINT WINAPI
MsiDoActionA( MSIHANDLE hInstall
, LPCSTR szAction
)
48 TRACE("%s\n", debugstr_a(szAction
));
50 szwAction
= strdupAtoW(szAction
);
51 if (szAction
&& !szwAction
)
52 return ERROR_FUNCTION_FAILED
;
54 ret
= MsiDoActionW( hInstall
, szwAction
);
55 msi_free( szwAction
);
59 /***********************************************************************
60 * MsiDoActionW (MSI.@)
62 UINT WINAPI
MsiDoActionW( MSIHANDLE hInstall
, LPCWSTR szAction
)
67 TRACE("%s\n",debugstr_w(szAction
));
70 return ERROR_INVALID_PARAMETER
;
72 package
= msihandle2msiinfo( hInstall
, MSIHANDLETYPE_PACKAGE
);
76 IWineMsiRemotePackage
*remote_package
;
78 remote_package
= (IWineMsiRemotePackage
*)msi_get_remote( hInstall
);
80 return ERROR_INVALID_HANDLE
;
82 hr
= IWineMsiRemotePackage_DoAction( remote_package
, (BSTR
*)szAction
);
84 IWineMsiRemotePackage_Release( remote_package
);
88 if (HRESULT_FACILITY(hr
) == FACILITY_WIN32
)
89 return HRESULT_CODE(hr
);
91 return ERROR_FUNCTION_FAILED
;
97 ret
= ACTION_PerformUIAction( package
, szAction
, -1 );
98 msiobj_release( &package
->hdr
);
103 /***********************************************************************
104 * MsiSequenceA (MSI.@)
106 UINT WINAPI
MsiSequenceA( MSIHANDLE hInstall
, LPCSTR szTable
, INT iSequenceMode
)
111 TRACE("%s\n", debugstr_a(szTable
));
113 szwTable
= strdupAtoW(szTable
);
114 if (szTable
&& !szwTable
)
115 return ERROR_FUNCTION_FAILED
;
117 ret
= MsiSequenceW( hInstall
, szwTable
, iSequenceMode
);
118 msi_free( szwTable
);
122 /***********************************************************************
123 * MsiSequenceW (MSI.@)
125 UINT WINAPI
MsiSequenceW( MSIHANDLE hInstall
, LPCWSTR szTable
, INT iSequenceMode
)
130 TRACE("%s\n", debugstr_w(szTable
));
132 package
= msihandle2msiinfo( hInstall
, MSIHANDLETYPE_PACKAGE
);
136 IWineMsiRemotePackage
*remote_package
;
138 remote_package
= (IWineMsiRemotePackage
*)msi_get_remote( hInstall
);
140 return ERROR_INVALID_HANDLE
;
142 hr
= IWineMsiRemotePackage_Sequence( remote_package
, (BSTR
*)szTable
, iSequenceMode
);
144 IWineMsiRemotePackage_Release( remote_package
);
148 if (HRESULT_FACILITY(hr
) == FACILITY_WIN32
)
149 return HRESULT_CODE(hr
);
151 return ERROR_FUNCTION_FAILED
;
154 return ERROR_SUCCESS
;
157 ret
= MSI_Sequence( package
, szTable
, iSequenceMode
);
158 msiobj_release( &package
->hdr
);
163 UINT
msi_strcpy_to_awstring( LPCWSTR str
, awstring
*awbuf
, DWORD
*sz
)
165 UINT len
, r
= ERROR_SUCCESS
;
167 if (awbuf
->str
.w
&& !sz
)
168 return ERROR_INVALID_PARAMETER
;
175 len
= lstrlenW( str
);
177 lstrcpynW( awbuf
->str
.w
, str
, *sz
);
181 len
= WideCharToMultiByte( CP_ACP
, 0, str
, -1, NULL
, 0, NULL
, NULL
);
184 WideCharToMultiByte( CP_ACP
, 0, str
, -1, awbuf
->str
.a
, *sz
, NULL
, NULL
);
185 if ( awbuf
->str
.a
&& *sz
&& (len
>= *sz
) )
186 awbuf
->str
.a
[*sz
- 1] = 0;
189 if (awbuf
->str
.w
&& len
>= *sz
)
195 /***********************************************************************
196 * MsiGetTargetPath (internal)
198 static UINT WINAPI
MSI_GetTargetPath( MSIHANDLE hInstall
, LPCWSTR szFolder
,
199 awstring
*szPathBuf
, DWORD
* pcchPathBuf
)
203 UINT r
= ERROR_FUNCTION_FAILED
;
206 return ERROR_INVALID_PARAMETER
;
208 package
= msihandle2msiinfo( hInstall
, MSIHANDLETYPE_PACKAGE
);
212 IWineMsiRemotePackage
*remote_package
;
216 remote_package
= (IWineMsiRemotePackage
*)msi_get_remote( hInstall
);
218 return ERROR_INVALID_HANDLE
;
221 hr
= IWineMsiRemotePackage_GetTargetPath( remote_package
, (BSTR
*)szFolder
,
227 value
= msi_alloc(len
* sizeof(WCHAR
));
230 r
= ERROR_OUTOFMEMORY
;
234 hr
= IWineMsiRemotePackage_GetTargetPath( remote_package
, (BSTR
*)szFolder
,
235 (BSTR
*)value
, &len
);
239 r
= msi_strcpy_to_awstring( value
, szPathBuf
, pcchPathBuf
);
242 IWineMsiRemotePackage_Release( remote_package
);
247 if (HRESULT_FACILITY(hr
) == FACILITY_WIN32
)
248 return HRESULT_CODE(hr
);
250 return ERROR_FUNCTION_FAILED
;
256 path
= resolve_folder( package
, szFolder
, FALSE
, FALSE
, TRUE
, NULL
);
257 msiobj_release( &package
->hdr
);
260 return ERROR_DIRECTORY
;
262 r
= msi_strcpy_to_awstring( path
, szPathBuf
, pcchPathBuf
);
267 /***********************************************************************
268 * MsiGetTargetPathA (MSI.@)
270 UINT WINAPI
MsiGetTargetPathA( MSIHANDLE hInstall
, LPCSTR szFolder
,
271 LPSTR szPathBuf
, DWORD
* pcchPathBuf
)
277 TRACE("%s %p %p\n", debugstr_a(szFolder
), szPathBuf
, pcchPathBuf
);
279 szwFolder
= strdupAtoW(szFolder
);
280 if (szFolder
&& !szwFolder
)
281 return ERROR_FUNCTION_FAILED
;
283 path
.unicode
= FALSE
;
284 path
.str
.a
= szPathBuf
;
286 r
= MSI_GetTargetPath( hInstall
, szwFolder
, &path
, pcchPathBuf
);
288 msi_free( szwFolder
);
293 /***********************************************************************
294 * MsiGetTargetPathW (MSI.@)
296 UINT WINAPI
MsiGetTargetPathW( MSIHANDLE hInstall
, LPCWSTR szFolder
,
297 LPWSTR szPathBuf
, DWORD
* pcchPathBuf
)
301 TRACE("%s %p %p\n", debugstr_w(szFolder
), szPathBuf
, pcchPathBuf
);
304 path
.str
.w
= szPathBuf
;
306 return MSI_GetTargetPath( hInstall
, szFolder
, &path
, pcchPathBuf
);
309 /***********************************************************************
310 * MsiGetSourcePath (internal)
312 static UINT
MSI_GetSourcePath( MSIHANDLE hInstall
, LPCWSTR szFolder
,
313 awstring
*szPathBuf
, DWORD
* pcchPathBuf
)
317 UINT r
= ERROR_FUNCTION_FAILED
;
319 TRACE("%s %p %p\n", debugstr_w(szFolder
), szPathBuf
, pcchPathBuf
);
322 return ERROR_INVALID_PARAMETER
;
324 package
= msihandle2msiinfo( hInstall
, MSIHANDLETYPE_PACKAGE
);
328 IWineMsiRemotePackage
*remote_package
;
332 remote_package
= (IWineMsiRemotePackage
*)msi_get_remote( hInstall
);
334 return ERROR_INVALID_HANDLE
;
337 hr
= IWineMsiRemotePackage_GetSourcePath( remote_package
, (BSTR
*)szFolder
,
343 value
= msi_alloc(len
* sizeof(WCHAR
));
346 r
= ERROR_OUTOFMEMORY
;
350 hr
= IWineMsiRemotePackage_GetSourcePath( remote_package
, (BSTR
*)szFolder
,
351 (BSTR
*)value
, &len
);
355 r
= msi_strcpy_to_awstring( value
, szPathBuf
, pcchPathBuf
);
358 IWineMsiRemotePackage_Release( remote_package
);
363 if (HRESULT_FACILITY(hr
) == FACILITY_WIN32
)
364 return HRESULT_CODE(hr
);
366 return ERROR_FUNCTION_FAILED
;
372 if (szPathBuf
->str
.w
&& !pcchPathBuf
)
374 msiobj_release( &package
->hdr
);
375 return ERROR_INVALID_PARAMETER
;
378 path
= resolve_folder(package
, szFolder
, TRUE
, FALSE
, TRUE
, NULL
);
379 msiobj_release( &package
->hdr
);
381 TRACE("path = %s\n",debugstr_w(path
));
383 return ERROR_DIRECTORY
;
385 r
= msi_strcpy_to_awstring( path
, szPathBuf
, pcchPathBuf
);
390 /***********************************************************************
391 * MsiGetSourcePathA (MSI.@)
393 UINT WINAPI
MsiGetSourcePathA( MSIHANDLE hInstall
, LPCSTR szFolder
,
394 LPSTR szPathBuf
, DWORD
* pcchPathBuf
)
400 TRACE("%s %p %p\n", szFolder
, debugstr_a(szPathBuf
), pcchPathBuf
);
403 str
.str
.a
= szPathBuf
;
405 folder
= strdupAtoW( szFolder
);
406 r
= MSI_GetSourcePath( hInstall
, folder
, &str
, pcchPathBuf
);
412 /***********************************************************************
413 * MsiGetSourcePathW (MSI.@)
415 UINT WINAPI
MsiGetSourcePathW( MSIHANDLE hInstall
, LPCWSTR szFolder
,
416 LPWSTR szPathBuf
, DWORD
* pcchPathBuf
)
420 TRACE("%s %p %p\n", debugstr_w(szFolder
), szPathBuf
, pcchPathBuf
);
423 str
.str
.w
= szPathBuf
;
425 return MSI_GetSourcePath( hInstall
, szFolder
, &str
, pcchPathBuf
);
428 /***********************************************************************
429 * MsiSetTargetPathA (MSI.@)
431 UINT WINAPI
MsiSetTargetPathA( MSIHANDLE hInstall
, LPCSTR szFolder
,
432 LPCSTR szFolderPath
)
434 LPWSTR szwFolder
= NULL
, szwFolderPath
= NULL
;
435 UINT rc
= ERROR_OUTOFMEMORY
;
437 if ( !szFolder
|| !szFolderPath
)
438 return ERROR_INVALID_PARAMETER
;
440 szwFolder
= strdupAtoW(szFolder
);
441 szwFolderPath
= strdupAtoW(szFolderPath
);
442 if (!szwFolder
|| !szwFolderPath
)
445 rc
= MsiSetTargetPathW( hInstall
, szwFolder
, szwFolderPath
);
449 msi_free(szwFolderPath
);
455 * Ok my original interpretation of this was wrong. And it looks like msdn has
456 * changed a bit also. The given folder path does not have to actually already
457 * exist, it just cannot be read only and must be a legal folder path.
459 UINT
MSI_SetTargetPathW(MSIPACKAGE
*package
, LPCWSTR szFolder
,
460 LPCWSTR szFolderPath
)
468 TRACE("%p %s %s\n",package
, debugstr_w(szFolder
),debugstr_w(szFolderPath
));
470 attrib
= GetFileAttributesW(szFolderPath
);
471 /* native MSI tests writeability by making temporary files at each drive */
472 if ( attrib
!= INVALID_FILE_ATTRIBUTES
&&
473 (attrib
& FILE_ATTRIBUTE_OFFLINE
||
474 attrib
& FILE_ATTRIBUTE_READONLY
))
475 return ERROR_FUNCTION_FAILED
;
477 path
= resolve_folder(package
,szFolder
,FALSE
,FALSE
,FALSE
,&folder
);
479 return ERROR_DIRECTORY
;
481 msi_free(folder
->Property
);
482 folder
->Property
= build_directory_name(2, szFolderPath
, NULL
);
484 if (lstrcmpiW(path
, folder
->Property
) == 0)
487 * Resolved Target has not really changed, so just
488 * set this folder and do not recalculate everything.
490 msi_free(folder
->ResolvedTarget
);
491 folder
->ResolvedTarget
= NULL
;
492 path2
= resolve_folder(package
,szFolder
,FALSE
,TRUE
,FALSE
,NULL
);
499 LIST_FOR_EACH_ENTRY( f
, &package
->folders
, MSIFOLDER
, entry
)
501 msi_free(f
->ResolvedTarget
);
502 f
->ResolvedTarget
=NULL
;
505 LIST_FOR_EACH_ENTRY( f
, &package
->folders
, MSIFOLDER
, entry
)
507 path2
= resolve_folder(package
, f
->Directory
, FALSE
, TRUE
, FALSE
, NULL
);
511 LIST_FOR_EACH_ENTRY( file
, &package
->files
, MSIFILE
, entry
)
513 MSICOMPONENT
*comp
= file
->Component
;
519 p
= resolve_folder(package
, comp
->Directory
, FALSE
, FALSE
, FALSE
, NULL
);
520 msi_free(file
->TargetPath
);
522 file
->TargetPath
= build_directory_name(2, p
, file
->FileName
);
528 return ERROR_SUCCESS
;
531 /***********************************************************************
532 * MsiSetTargetPathW (MSI.@)
534 UINT WINAPI
MsiSetTargetPathW(MSIHANDLE hInstall
, LPCWSTR szFolder
,
535 LPCWSTR szFolderPath
)
540 TRACE("%s %s\n",debugstr_w(szFolder
),debugstr_w(szFolderPath
));
542 if ( !szFolder
|| !szFolderPath
)
543 return ERROR_INVALID_PARAMETER
;
545 package
= msihandle2msiinfo(hInstall
, MSIHANDLETYPE_PACKAGE
);
549 IWineMsiRemotePackage
*remote_package
;
551 remote_package
= (IWineMsiRemotePackage
*)msi_get_remote( hInstall
);
553 return ERROR_INVALID_HANDLE
;
555 hr
= IWineMsiRemotePackage_SetTargetPath( remote_package
, (BSTR
*)szFolder
, (BSTR
*)szFolderPath
);
557 IWineMsiRemotePackage_Release( remote_package
);
561 if (HRESULT_FACILITY(hr
) == FACILITY_WIN32
)
562 return HRESULT_CODE(hr
);
564 return ERROR_FUNCTION_FAILED
;
567 return ERROR_SUCCESS
;
570 ret
= MSI_SetTargetPathW( package
, szFolder
, szFolderPath
);
571 msiobj_release( &package
->hdr
);
575 /***********************************************************************
578 * Returns an internal installer state (if it is running in a mode iRunMode)
581 * hInstall [I] Handle to the installation
582 * hRunMode [I] Checking run mode
583 * MSIRUNMODE_ADMIN Administrative mode
584 * MSIRUNMODE_ADVERTISE Advertisement mode
585 * MSIRUNMODE_MAINTENANCE Maintenance mode
586 * MSIRUNMODE_ROLLBACKENABLED Rollback is enabled
587 * MSIRUNMODE_LOGENABLED Log file is writing
588 * MSIRUNMODE_OPERATIONS Operations in progress??
589 * MSIRUNMODE_REBOOTATEND We need to reboot after installation completed
590 * MSIRUNMODE_REBOOTNOW We need to reboot to continue the installation
591 * MSIRUNMODE_CABINET Files from cabinet are installed
592 * MSIRUNMODE_SOURCESHORTNAMES Long names in source files is suppressed
593 * MSIRUNMODE_TARGETSHORTNAMES Long names in destination files is suppressed
594 * MSIRUNMODE_RESERVED11 Reserved
595 * MSIRUNMODE_WINDOWS9X Running under Windows95/98
596 * MSIRUNMODE_ZAWENABLED Demand installation is supported
597 * MSIRUNMODE_RESERVED14 Reserved
598 * MSIRUNMODE_RESERVED15 Reserved
599 * MSIRUNMODE_SCHEDULED called from install script
600 * MSIRUNMODE_ROLLBACK called from rollback script
601 * MSIRUNMODE_COMMIT called from commit script
605 * Not in the state: FALSE
608 BOOL WINAPI
MsiGetMode(MSIHANDLE hInstall
, MSIRUNMODE iRunMode
)
613 package
= msihandle2msiinfo(hInstall
, MSIHANDLETYPE_PACKAGE
);
618 IWineMsiRemotePackage
*remote_package
;
620 remote_package
= (IWineMsiRemotePackage
*)msi_get_remote(hInstall
);
624 hr
= IWineMsiRemotePackage_GetMode(remote_package
, iRunMode
, &ret
);
625 IWineMsiRemotePackage_Release(remote_package
);
635 case MSIRUNMODE_WINDOWS9X
:
636 if (GetVersion() & 0x80000000)
640 case MSIRUNMODE_RESERVED11
:
641 case MSIRUNMODE_RESERVED14
:
642 case MSIRUNMODE_RESERVED15
:
645 case MSIRUNMODE_SCHEDULED
:
646 r
= package
->scheduled_action_running
;
649 case MSIRUNMODE_ROLLBACK
:
650 r
= package
->rollback_action_running
;
653 case MSIRUNMODE_COMMIT
:
654 r
= package
->commit_action_running
;
658 FIXME("%ld %d\n", hInstall
, iRunMode
);
665 /***********************************************************************
668 BOOL WINAPI
MsiSetMode(MSIHANDLE hInstall
, MSIRUNMODE iRunMode
, BOOL fState
)
672 case MSIRUNMODE_RESERVED11
:
673 case MSIRUNMODE_WINDOWS9X
:
674 case MSIRUNMODE_RESERVED14
:
675 case MSIRUNMODE_RESERVED15
:
678 FIXME("%ld %d %d\n", hInstall
, iRunMode
, fState
);
683 /***********************************************************************
684 * MsiSetFeatureStateA (MSI.@)
686 * According to the docs, when this is called it immediately recalculates
687 * all the component states as well
689 UINT WINAPI
MsiSetFeatureStateA(MSIHANDLE hInstall
, LPCSTR szFeature
,
692 LPWSTR szwFeature
= NULL
;
695 szwFeature
= strdupAtoW(szFeature
);
698 return ERROR_FUNCTION_FAILED
;
700 rc
= MsiSetFeatureStateW(hInstall
,szwFeature
, iState
);
702 msi_free(szwFeature
);
709 UINT WINAPI
MSI_SetFeatureStateW(MSIPACKAGE
* package
, LPCWSTR szFeature
,
712 UINT rc
= ERROR_SUCCESS
;
713 MSIFEATURE
*feature
, *child
;
715 TRACE("%s %i\n", debugstr_w(szFeature
), iState
);
717 feature
= get_loaded_feature(package
,szFeature
);
719 return ERROR_UNKNOWN_FEATURE
;
721 if (iState
== INSTALLSTATE_ADVERTISED
&&
722 feature
->Attributes
& msidbFeatureAttributesDisallowAdvertise
)
723 return ERROR_FUNCTION_FAILED
;
725 msi_feature_set_state( feature
, iState
);
727 ACTION_UpdateComponentStates(package
,szFeature
);
729 /* update all the features that are children of this feature */
730 LIST_FOR_EACH_ENTRY( child
, &package
->features
, MSIFEATURE
, entry
)
732 if (lstrcmpW(szFeature
, child
->Feature_Parent
) == 0)
733 MSI_SetFeatureStateW(package
, child
->Feature
, iState
);
739 /***********************************************************************
740 * MsiSetFeatureStateW (MSI.@)
742 UINT WINAPI
MsiSetFeatureStateW(MSIHANDLE hInstall
, LPCWSTR szFeature
,
746 UINT rc
= ERROR_SUCCESS
;
748 TRACE("%s %i\n",debugstr_w(szFeature
), iState
);
750 package
= msihandle2msiinfo(hInstall
, MSIHANDLETYPE_PACKAGE
);
754 IWineMsiRemotePackage
*remote_package
;
756 remote_package
= (IWineMsiRemotePackage
*)msi_get_remote(hInstall
);
758 return ERROR_INVALID_HANDLE
;
760 hr
= IWineMsiRemotePackage_SetFeatureState(remote_package
, (BSTR
*)szFeature
, iState
);
762 IWineMsiRemotePackage_Release(remote_package
);
766 if (HRESULT_FACILITY(hr
) == FACILITY_WIN32
)
767 return HRESULT_CODE(hr
);
769 return ERROR_FUNCTION_FAILED
;
772 return ERROR_SUCCESS
;
775 rc
= MSI_SetFeatureStateW(package
,szFeature
,iState
);
777 msiobj_release( &package
->hdr
);
781 /***********************************************************************
782 * MsiGetFeatureStateA (MSI.@)
784 UINT WINAPI
MsiGetFeatureStateA(MSIHANDLE hInstall
, LPCSTR szFeature
,
785 INSTALLSTATE
*piInstalled
, INSTALLSTATE
*piAction
)
787 LPWSTR szwFeature
= NULL
;
790 szwFeature
= strdupAtoW(szFeature
);
792 rc
= MsiGetFeatureStateW(hInstall
,szwFeature
,piInstalled
, piAction
);
794 msi_free( szwFeature
);
799 UINT
MSI_GetFeatureStateW(MSIPACKAGE
*package
, LPCWSTR szFeature
,
800 INSTALLSTATE
*piInstalled
, INSTALLSTATE
*piAction
)
804 feature
= get_loaded_feature(package
,szFeature
);
806 return ERROR_UNKNOWN_FEATURE
;
809 *piInstalled
= feature
->Installed
;
812 *piAction
= feature
->Action
;
814 TRACE("returning %i %i\n", feature
->Installed
, feature
->Action
);
816 return ERROR_SUCCESS
;
819 /***********************************************************************
820 * MsiGetFeatureStateW (MSI.@)
822 UINT WINAPI
MsiGetFeatureStateW(MSIHANDLE hInstall
, LPCWSTR szFeature
,
823 INSTALLSTATE
*piInstalled
, INSTALLSTATE
*piAction
)
828 TRACE("%ld %s %p %p\n", hInstall
, debugstr_w(szFeature
), piInstalled
, piAction
);
830 package
= msihandle2msiinfo(hInstall
, MSIHANDLETYPE_PACKAGE
);
834 IWineMsiRemotePackage
*remote_package
;
836 remote_package
= (IWineMsiRemotePackage
*)msi_get_remote(hInstall
);
838 return ERROR_INVALID_HANDLE
;
840 hr
= IWineMsiRemotePackage_GetFeatureState(remote_package
, (BSTR
*)szFeature
,
841 piInstalled
, piAction
);
845 if (HRESULT_FACILITY(hr
) == FACILITY_WIN32
)
846 return HRESULT_CODE(hr
);
848 return ERROR_FUNCTION_FAILED
;
851 return ERROR_SUCCESS
;
854 ret
= MSI_GetFeatureStateW(package
, szFeature
, piInstalled
, piAction
);
855 msiobj_release( &package
->hdr
);
859 /***********************************************************************
860 * MsiGetFeatureCostA (MSI.@)
862 UINT WINAPI
MsiGetFeatureCostA(MSIHANDLE hInstall
, LPCSTR szFeature
,
863 MSICOSTTREE iCostTree
, INSTALLSTATE iState
, INT
*piCost
)
865 FIXME("(%ld %s %i %i %p): stub\n", hInstall
, debugstr_a(szFeature
),
866 iCostTree
, iState
, piCost
);
867 if (piCost
) *piCost
= 0;
868 return ERROR_SUCCESS
;
871 /***********************************************************************
872 * MsiGetFeatureCostW (MSI.@)
874 UINT WINAPI
MsiGetFeatureCostW(MSIHANDLE hInstall
, LPCWSTR szFeature
,
875 MSICOSTTREE iCostTree
, INSTALLSTATE iState
, INT
*piCost
)
877 FIXME("(%ld %s %i %i %p): stub\n", hInstall
, debugstr_w(szFeature
),
878 iCostTree
, iState
, piCost
);
879 if (piCost
) *piCost
= 0;
880 return ERROR_SUCCESS
;
883 /***********************************************************************
884 * MsiSetComponentStateA (MSI.@)
886 UINT WINAPI
MsiSetComponentStateA(MSIHANDLE hInstall
, LPCSTR szComponent
,
890 LPWSTR szwComponent
= strdupAtoW(szComponent
);
892 rc
= MsiSetComponentStateW(hInstall
, szwComponent
, iState
);
894 msi_free(szwComponent
);
899 /***********************************************************************
900 * MsiGetComponentStateA (MSI.@)
902 UINT WINAPI
MsiGetComponentStateA(MSIHANDLE hInstall
, LPCSTR szComponent
,
903 INSTALLSTATE
*piInstalled
, INSTALLSTATE
*piAction
)
905 LPWSTR szwComponent
= NULL
;
908 szwComponent
= strdupAtoW(szComponent
);
910 rc
= MsiGetComponentStateW(hInstall
,szwComponent
,piInstalled
, piAction
);
912 msi_free( szwComponent
);
917 static UINT
MSI_SetComponentStateW(MSIPACKAGE
*package
, LPCWSTR szComponent
,
922 TRACE("%p %s %d\n", package
, debugstr_w(szComponent
), iState
);
924 comp
= get_loaded_component(package
, szComponent
);
926 return ERROR_UNKNOWN_COMPONENT
;
928 comp
->Installed
= iState
;
930 return ERROR_SUCCESS
;
933 UINT
MSI_GetComponentStateW(MSIPACKAGE
*package
, LPCWSTR szComponent
,
934 INSTALLSTATE
*piInstalled
, INSTALLSTATE
*piAction
)
938 TRACE("%p %s %p %p\n", package
, debugstr_w(szComponent
),
939 piInstalled
, piAction
);
941 comp
= get_loaded_component(package
,szComponent
);
943 return ERROR_UNKNOWN_COMPONENT
;
946 *piInstalled
= comp
->Installed
;
949 *piAction
= comp
->Action
;
951 TRACE("states (%i, %i)\n", comp
->Installed
, comp
->Action
);
953 return ERROR_SUCCESS
;
956 /***********************************************************************
957 * MsiSetComponentStateW (MSI.@)
959 UINT WINAPI
MsiSetComponentStateW(MSIHANDLE hInstall
, LPCWSTR szComponent
,
965 package
= msihandle2msiinfo(hInstall
, MSIHANDLETYPE_PACKAGE
);
969 IWineMsiRemotePackage
*remote_package
;
971 remote_package
= (IWineMsiRemotePackage
*)msi_get_remote(hInstall
);
973 return ERROR_INVALID_HANDLE
;
975 hr
= IWineMsiRemotePackage_SetComponentState(remote_package
, (BSTR
*)szComponent
, iState
);
977 IWineMsiRemotePackage_Release(remote_package
);
981 if (HRESULT_FACILITY(hr
) == FACILITY_WIN32
)
982 return HRESULT_CODE(hr
);
984 return ERROR_FUNCTION_FAILED
;
987 return ERROR_SUCCESS
;
990 ret
= MSI_SetComponentStateW(package
, szComponent
, iState
);
991 msiobj_release(&package
->hdr
);
995 /***********************************************************************
996 * MsiGetComponentStateW (MSI.@)
998 UINT WINAPI
MsiGetComponentStateW(MSIHANDLE hInstall
, LPCWSTR szComponent
,
999 INSTALLSTATE
*piInstalled
, INSTALLSTATE
*piAction
)
1001 MSIPACKAGE
* package
;
1004 TRACE("%ld %s %p %p\n", hInstall
, debugstr_w(szComponent
),
1005 piInstalled
, piAction
);
1007 package
= msihandle2msiinfo(hInstall
, MSIHANDLETYPE_PACKAGE
);
1011 IWineMsiRemotePackage
*remote_package
;
1013 remote_package
= (IWineMsiRemotePackage
*)msi_get_remote(hInstall
);
1014 if (!remote_package
)
1015 return ERROR_INVALID_HANDLE
;
1017 hr
= IWineMsiRemotePackage_GetComponentState(remote_package
, (BSTR
*)szComponent
,
1018 piInstalled
, piAction
);
1022 if (HRESULT_FACILITY(hr
) == FACILITY_WIN32
)
1023 return HRESULT_CODE(hr
);
1025 return ERROR_FUNCTION_FAILED
;
1028 return ERROR_SUCCESS
;
1031 ret
= MSI_GetComponentStateW( package
, szComponent
, piInstalled
, piAction
);
1032 msiobj_release( &package
->hdr
);
1036 /***********************************************************************
1037 * MsiGetLanguage (MSI.@)
1039 LANGID WINAPI
MsiGetLanguage(MSIHANDLE hInstall
)
1041 MSIPACKAGE
* package
;
1043 static const WCHAR szProductLanguage
[] =
1044 {'P','r','o','d','u','c','t','L','a','n','g','u','a','g','e',0};
1046 package
= msihandle2msiinfo(hInstall
, MSIHANDLETYPE_PACKAGE
);
1051 IWineMsiRemotePackage
*remote_package
;
1053 remote_package
= (IWineMsiRemotePackage
*)msi_get_remote(hInstall
);
1054 if (!remote_package
)
1055 return ERROR_INVALID_HANDLE
;
1057 hr
= IWineMsiRemotePackage_GetLanguage(remote_package
, &lang
);
1065 langid
= msi_get_property_int( package
, szProductLanguage
, 0 );
1066 msiobj_release( &package
->hdr
);
1070 UINT
MSI_SetInstallLevel( MSIPACKAGE
*package
, int iInstallLevel
)
1072 static const WCHAR szInstallLevel
[] = {
1073 'I','N','S','T','A','L','L','L','E','V','E','L',0 };
1074 static const WCHAR fmt
[] = { '%','d',0 };
1078 TRACE("%p %i\n", package
, iInstallLevel
);
1080 if (iInstallLevel
<1 || iInstallLevel
>32767)
1081 return ERROR_INVALID_PARAMETER
;
1083 sprintfW( level
, fmt
, iInstallLevel
);
1084 r
= MSI_SetPropertyW( package
, szInstallLevel
, level
);
1085 if ( r
== ERROR_SUCCESS
)
1087 r
= MSI_SetFeatureStates( package
);
1093 /***********************************************************************
1094 * MsiSetInstallLevel (MSI.@)
1096 UINT WINAPI
MsiSetInstallLevel(MSIHANDLE hInstall
, int iInstallLevel
)
1098 MSIPACKAGE
* package
;
1101 TRACE("%ld %i\n", hInstall
, iInstallLevel
);
1103 package
= msihandle2msiinfo(hInstall
, MSIHANDLETYPE_PACKAGE
);
1107 IWineMsiRemotePackage
*remote_package
;
1109 remote_package
= (IWineMsiRemotePackage
*)msi_get_remote(hInstall
);
1110 if (!remote_package
)
1111 return ERROR_INVALID_HANDLE
;
1113 hr
= IWineMsiRemotePackage_SetInstallLevel(remote_package
, iInstallLevel
);
1115 IWineMsiRemotePackage_Release(remote_package
);
1119 if (HRESULT_FACILITY(hr
) == FACILITY_WIN32
)
1120 return HRESULT_CODE(hr
);
1122 return ERROR_FUNCTION_FAILED
;
1125 return ERROR_SUCCESS
;
1128 r
= MSI_SetInstallLevel( package
, iInstallLevel
);
1130 msiobj_release( &package
->hdr
);
1135 /***********************************************************************
1136 * MsiGetFeatureValidStatesW (MSI.@)
1138 UINT WINAPI
MsiGetFeatureValidStatesW(MSIHANDLE hInstall
, LPCWSTR szFeature
,
1139 DWORD
* pInstallState
)
1141 if(pInstallState
) *pInstallState
= 1<<INSTALLSTATE_LOCAL
;
1142 FIXME("%ld %s %p stub returning %d\n",
1143 hInstall
, debugstr_w(szFeature
), pInstallState
, pInstallState
? *pInstallState
: 0);
1145 return ERROR_SUCCESS
;
1148 /***********************************************************************
1149 * MsiGetFeatureValidStatesA (MSI.@)
1151 UINT WINAPI
MsiGetFeatureValidStatesA(MSIHANDLE hInstall
, LPCSTR szFeature
,
1152 DWORD
* pInstallState
)
1155 LPWSTR szwFeature
= strdupAtoW(szFeature
);
1157 ret
= MsiGetFeatureValidStatesW(hInstall
, szwFeature
, pInstallState
);
1159 msi_free(szwFeature
);