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"
37 #include "msiserver.h"
38 #include "wine/unicode.h"
40 WINE_DEFAULT_DEBUG_CHANNEL(msi
);
42 /***********************************************************************
43 * MsiDoActionA (MSI.@)
45 UINT WINAPI
MsiDoActionA( MSIHANDLE hInstall
, LPCSTR szAction
)
50 TRACE("%s\n", debugstr_a(szAction
));
52 szwAction
= strdupAtoW(szAction
);
53 if (szAction
&& !szwAction
)
54 return ERROR_FUNCTION_FAILED
;
56 ret
= MsiDoActionW( hInstall
, szwAction
);
57 msi_free( szwAction
);
61 /***********************************************************************
62 * MsiDoActionW (MSI.@)
64 UINT WINAPI
MsiDoActionW( MSIHANDLE hInstall
, LPCWSTR szAction
)
69 TRACE("%s\n",debugstr_w(szAction
));
72 return ERROR_INVALID_PARAMETER
;
74 package
= msihandle2msiinfo( hInstall
, MSIHANDLETYPE_PACKAGE
);
79 IWineMsiRemotePackage
*remote_package
;
81 remote_package
= (IWineMsiRemotePackage
*)msi_get_remote( hInstall
);
83 return ERROR_INVALID_HANDLE
;
85 action
= SysAllocString( szAction
);
88 IWineMsiRemotePackage_Release( remote_package
);
89 return ERROR_OUTOFMEMORY
;
92 hr
= IWineMsiRemotePackage_DoAction( remote_package
, action
);
94 SysFreeString( action
);
95 IWineMsiRemotePackage_Release( remote_package
);
99 if (HRESULT_FACILITY(hr
) == FACILITY_WIN32
)
100 return HRESULT_CODE(hr
);
102 return ERROR_FUNCTION_FAILED
;
105 return ERROR_SUCCESS
;
108 ret
= ACTION_PerformUIAction( package
, szAction
, -1 );
109 msiobj_release( &package
->hdr
);
114 /***********************************************************************
115 * MsiSequenceA (MSI.@)
117 UINT WINAPI
MsiSequenceA( MSIHANDLE hInstall
, LPCSTR szTable
, INT iSequenceMode
)
122 TRACE("%s\n", debugstr_a(szTable
));
124 szwTable
= strdupAtoW(szTable
);
125 if (szTable
&& !szwTable
)
126 return ERROR_FUNCTION_FAILED
;
128 ret
= MsiSequenceW( hInstall
, szwTable
, iSequenceMode
);
129 msi_free( szwTable
);
133 /***********************************************************************
134 * MsiSequenceW (MSI.@)
136 UINT WINAPI
MsiSequenceW( MSIHANDLE hInstall
, LPCWSTR szTable
, INT iSequenceMode
)
141 TRACE("%s\n", debugstr_w(szTable
));
143 package
= msihandle2msiinfo( hInstall
, MSIHANDLETYPE_PACKAGE
);
148 IWineMsiRemotePackage
*remote_package
;
150 remote_package
= (IWineMsiRemotePackage
*)msi_get_remote( hInstall
);
152 return ERROR_INVALID_HANDLE
;
154 table
= SysAllocString( szTable
);
157 IWineMsiRemotePackage_Release( remote_package
);
158 return ERROR_OUTOFMEMORY
;
161 hr
= IWineMsiRemotePackage_Sequence( remote_package
, table
, iSequenceMode
);
163 SysFreeString( table
);
164 IWineMsiRemotePackage_Release( remote_package
);
168 if (HRESULT_FACILITY(hr
) == FACILITY_WIN32
)
169 return HRESULT_CODE(hr
);
171 return ERROR_FUNCTION_FAILED
;
174 return ERROR_SUCCESS
;
177 ret
= MSI_Sequence( package
, szTable
, iSequenceMode
);
178 msiobj_release( &package
->hdr
);
183 UINT
msi_strcpy_to_awstring( LPCWSTR str
, awstring
*awbuf
, DWORD
*sz
)
185 UINT len
, r
= ERROR_SUCCESS
;
187 if (awbuf
->str
.w
&& !sz
)
188 return ERROR_INVALID_PARAMETER
;
195 len
= lstrlenW( str
);
197 lstrcpynW( awbuf
->str
.w
, str
, *sz
);
201 len
= WideCharToMultiByte( CP_ACP
, 0, str
, -1, NULL
, 0, NULL
, NULL
);
204 WideCharToMultiByte( CP_ACP
, 0, str
, -1, awbuf
->str
.a
, *sz
, NULL
, NULL
);
205 if ( awbuf
->str
.a
&& *sz
&& (len
>= *sz
) )
206 awbuf
->str
.a
[*sz
- 1] = 0;
209 if (awbuf
->str
.w
&& len
>= *sz
)
215 /***********************************************************************
216 * MsiGetTargetPath (internal)
218 static UINT
MSI_GetTargetPath( MSIHANDLE hInstall
, LPCWSTR szFolder
,
219 awstring
*szPathBuf
, LPDWORD pcchPathBuf
)
223 UINT r
= ERROR_FUNCTION_FAILED
;
226 return ERROR_INVALID_PARAMETER
;
228 package
= msihandle2msiinfo( hInstall
, MSIHANDLETYPE_PACKAGE
);
232 IWineMsiRemotePackage
*remote_package
;
237 remote_package
= (IWineMsiRemotePackage
*)msi_get_remote( hInstall
);
239 return ERROR_INVALID_HANDLE
;
241 folder
= SysAllocString( szFolder
);
244 IWineMsiRemotePackage_Release( remote_package
);
245 return ERROR_OUTOFMEMORY
;
249 hr
= IWineMsiRemotePackage_GetTargetPath( remote_package
, folder
,
255 value
= msi_alloc(len
* sizeof(WCHAR
));
258 r
= ERROR_OUTOFMEMORY
;
262 hr
= IWineMsiRemotePackage_GetTargetPath( remote_package
, folder
,
263 (BSTR
*)value
, &len
);
267 r
= msi_strcpy_to_awstring( value
, szPathBuf
, pcchPathBuf
);
270 IWineMsiRemotePackage_Release( remote_package
);
271 SysFreeString( folder
);
276 if (HRESULT_FACILITY(hr
) == FACILITY_WIN32
)
277 return HRESULT_CODE(hr
);
279 return ERROR_FUNCTION_FAILED
;
285 path
= resolve_folder( package
, szFolder
, FALSE
, FALSE
, TRUE
, NULL
);
286 msiobj_release( &package
->hdr
);
289 return ERROR_DIRECTORY
;
291 r
= msi_strcpy_to_awstring( path
, szPathBuf
, pcchPathBuf
);
296 /***********************************************************************
297 * MsiGetTargetPathA (MSI.@)
299 UINT WINAPI
MsiGetTargetPathA( MSIHANDLE hInstall
, LPCSTR szFolder
,
300 LPSTR szPathBuf
, LPDWORD pcchPathBuf
)
306 TRACE("%s %p %p\n", debugstr_a(szFolder
), szPathBuf
, pcchPathBuf
);
308 szwFolder
= strdupAtoW(szFolder
);
309 if (szFolder
&& !szwFolder
)
310 return ERROR_FUNCTION_FAILED
;
312 path
.unicode
= FALSE
;
313 path
.str
.a
= szPathBuf
;
315 r
= MSI_GetTargetPath( hInstall
, szwFolder
, &path
, pcchPathBuf
);
317 msi_free( szwFolder
);
322 /***********************************************************************
323 * MsiGetTargetPathW (MSI.@)
325 UINT WINAPI
MsiGetTargetPathW( MSIHANDLE hInstall
, LPCWSTR szFolder
,
326 LPWSTR szPathBuf
, LPDWORD pcchPathBuf
)
330 TRACE("%s %p %p\n", debugstr_w(szFolder
), szPathBuf
, pcchPathBuf
);
333 path
.str
.w
= szPathBuf
;
335 return MSI_GetTargetPath( hInstall
, szFolder
, &path
, pcchPathBuf
);
338 /***********************************************************************
339 * MsiGetSourcePath (internal)
341 static UINT
MSI_GetSourcePath( MSIHANDLE hInstall
, LPCWSTR szFolder
,
342 awstring
*szPathBuf
, LPDWORD pcchPathBuf
)
346 UINT r
= ERROR_FUNCTION_FAILED
;
348 TRACE("%s %p %p\n", debugstr_w(szFolder
), szPathBuf
, pcchPathBuf
);
351 return ERROR_INVALID_PARAMETER
;
353 package
= msihandle2msiinfo( hInstall
, MSIHANDLETYPE_PACKAGE
);
357 IWineMsiRemotePackage
*remote_package
;
362 remote_package
= (IWineMsiRemotePackage
*)msi_get_remote( hInstall
);
364 return ERROR_INVALID_HANDLE
;
366 folder
= SysAllocString( szFolder
);
369 IWineMsiRemotePackage_Release( remote_package
);
370 return ERROR_OUTOFMEMORY
;
374 hr
= IWineMsiRemotePackage_GetSourcePath( remote_package
, folder
,
380 value
= msi_alloc(len
* sizeof(WCHAR
));
383 r
= ERROR_OUTOFMEMORY
;
387 hr
= IWineMsiRemotePackage_GetSourcePath( remote_package
, folder
,
388 (BSTR
*)value
, &len
);
392 r
= msi_strcpy_to_awstring( value
, szPathBuf
, pcchPathBuf
);
395 IWineMsiRemotePackage_Release( remote_package
);
396 SysFreeString( folder
);
401 if (HRESULT_FACILITY(hr
) == FACILITY_WIN32
)
402 return HRESULT_CODE(hr
);
404 return ERROR_FUNCTION_FAILED
;
410 if (szPathBuf
->str
.w
&& !pcchPathBuf
)
412 msiobj_release( &package
->hdr
);
413 return ERROR_INVALID_PARAMETER
;
416 path
= resolve_folder(package
, szFolder
, TRUE
, FALSE
, TRUE
, NULL
);
417 msiobj_release( &package
->hdr
);
419 TRACE("path = %s\n",debugstr_w(path
));
421 return ERROR_DIRECTORY
;
423 r
= msi_strcpy_to_awstring( path
, szPathBuf
, pcchPathBuf
);
428 /***********************************************************************
429 * MsiGetSourcePathA (MSI.@)
431 UINT WINAPI
MsiGetSourcePathA( MSIHANDLE hInstall
, LPCSTR szFolder
,
432 LPSTR szPathBuf
, LPDWORD pcchPathBuf
)
438 TRACE("%s %p %p\n", szFolder
, debugstr_a(szPathBuf
), pcchPathBuf
);
441 str
.str
.a
= szPathBuf
;
443 folder
= strdupAtoW( szFolder
);
444 r
= MSI_GetSourcePath( hInstall
, folder
, &str
, pcchPathBuf
);
450 /***********************************************************************
451 * MsiGetSourcePathW (MSI.@)
453 UINT WINAPI
MsiGetSourcePathW( MSIHANDLE hInstall
, LPCWSTR szFolder
,
454 LPWSTR szPathBuf
, LPDWORD pcchPathBuf
)
458 TRACE("%s %p %p\n", debugstr_w(szFolder
), szPathBuf
, pcchPathBuf
);
461 str
.str
.w
= szPathBuf
;
463 return MSI_GetSourcePath( hInstall
, szFolder
, &str
, pcchPathBuf
);
466 /***********************************************************************
467 * MsiSetTargetPathA (MSI.@)
469 UINT WINAPI
MsiSetTargetPathA( MSIHANDLE hInstall
, LPCSTR szFolder
,
470 LPCSTR szFolderPath
)
472 LPWSTR szwFolder
= NULL
, szwFolderPath
= NULL
;
473 UINT rc
= ERROR_OUTOFMEMORY
;
475 if ( !szFolder
|| !szFolderPath
)
476 return ERROR_INVALID_PARAMETER
;
478 szwFolder
= strdupAtoW(szFolder
);
479 szwFolderPath
= strdupAtoW(szFolderPath
);
480 if (!szwFolder
|| !szwFolderPath
)
483 rc
= MsiSetTargetPathW( hInstall
, szwFolder
, szwFolderPath
);
487 msi_free(szwFolderPath
);
493 * Ok my original interpretation of this was wrong. And it looks like msdn has
494 * changed a bit also. The given folder path does not have to actually already
495 * exist, it just cannot be read only and must be a legal folder path.
497 UINT
MSI_SetTargetPathW(MSIPACKAGE
*package
, LPCWSTR szFolder
,
498 LPCWSTR szFolderPath
)
506 TRACE("%p %s %s\n",package
, debugstr_w(szFolder
),debugstr_w(szFolderPath
));
508 attrib
= GetFileAttributesW(szFolderPath
);
509 /* native MSI tests writeability by making temporary files at each drive */
510 if ( attrib
!= INVALID_FILE_ATTRIBUTES
&&
511 (attrib
& FILE_ATTRIBUTE_OFFLINE
||
512 attrib
& FILE_ATTRIBUTE_READONLY
))
513 return ERROR_FUNCTION_FAILED
;
515 path
= resolve_folder(package
,szFolder
,FALSE
,FALSE
,FALSE
,&folder
);
517 return ERROR_DIRECTORY
;
519 msi_free(folder
->Property
);
520 folder
->Property
= build_directory_name(2, szFolderPath
, NULL
);
522 if (lstrcmpiW(path
, folder
->Property
) == 0)
525 * Resolved Target has not really changed, so just
526 * set this folder and do not recalculate everything.
528 msi_free(folder
->ResolvedTarget
);
529 folder
->ResolvedTarget
= NULL
;
530 path2
= resolve_folder(package
,szFolder
,FALSE
,TRUE
,FALSE
,NULL
);
537 LIST_FOR_EACH_ENTRY( f
, &package
->folders
, MSIFOLDER
, entry
)
539 msi_free(f
->ResolvedTarget
);
540 f
->ResolvedTarget
=NULL
;
543 LIST_FOR_EACH_ENTRY( f
, &package
->folders
, MSIFOLDER
, entry
)
545 path2
= resolve_folder(package
, f
->Directory
, FALSE
, TRUE
, FALSE
, NULL
);
549 LIST_FOR_EACH_ENTRY( file
, &package
->files
, MSIFILE
, entry
)
551 MSICOMPONENT
*comp
= file
->Component
;
557 p
= resolve_folder(package
, comp
->Directory
, FALSE
, FALSE
, FALSE
, NULL
);
558 msi_free(file
->TargetPath
);
560 file
->TargetPath
= build_directory_name(2, p
, file
->FileName
);
566 return ERROR_SUCCESS
;
569 /***********************************************************************
570 * MsiSetTargetPathW (MSI.@)
572 UINT WINAPI
MsiSetTargetPathW(MSIHANDLE hInstall
, LPCWSTR szFolder
,
573 LPCWSTR szFolderPath
)
578 TRACE("%s %s\n",debugstr_w(szFolder
),debugstr_w(szFolderPath
));
580 if ( !szFolder
|| !szFolderPath
)
581 return ERROR_INVALID_PARAMETER
;
583 package
= msihandle2msiinfo(hInstall
, MSIHANDLETYPE_PACKAGE
);
588 IWineMsiRemotePackage
*remote_package
;
590 remote_package
= (IWineMsiRemotePackage
*)msi_get_remote( hInstall
);
592 return ERROR_INVALID_HANDLE
;
594 folder
= SysAllocString( szFolder
);
595 path
= SysAllocString( szFolderPath
);
596 if (!folder
|| !path
)
598 SysFreeString(folder
);
600 IWineMsiRemotePackage_Release( remote_package
);
601 return ERROR_OUTOFMEMORY
;
604 hr
= IWineMsiRemotePackage_SetTargetPath( remote_package
, folder
, path
);
606 SysFreeString(folder
);
608 IWineMsiRemotePackage_Release( remote_package
);
612 if (HRESULT_FACILITY(hr
) == FACILITY_WIN32
)
613 return HRESULT_CODE(hr
);
615 return ERROR_FUNCTION_FAILED
;
618 return ERROR_SUCCESS
;
621 ret
= MSI_SetTargetPathW( package
, szFolder
, szFolderPath
);
622 msiobj_release( &package
->hdr
);
626 /***********************************************************************
629 * Returns an internal installer state (if it is running in a mode iRunMode)
632 * hInstall [I] Handle to the installation
633 * hRunMode [I] Checking run mode
634 * MSIRUNMODE_ADMIN Administrative mode
635 * MSIRUNMODE_ADVERTISE Advertisement mode
636 * MSIRUNMODE_MAINTENANCE Maintenance mode
637 * MSIRUNMODE_ROLLBACKENABLED Rollback is enabled
638 * MSIRUNMODE_LOGENABLED Log file is writing
639 * MSIRUNMODE_OPERATIONS Operations in progress??
640 * MSIRUNMODE_REBOOTATEND We need to reboot after installation completed
641 * MSIRUNMODE_REBOOTNOW We need to reboot to continue the installation
642 * MSIRUNMODE_CABINET Files from cabinet are installed
643 * MSIRUNMODE_SOURCESHORTNAMES Long names in source files is suppressed
644 * MSIRUNMODE_TARGETSHORTNAMES Long names in destination files is suppressed
645 * MSIRUNMODE_RESERVED11 Reserved
646 * MSIRUNMODE_WINDOWS9X Running under Windows95/98
647 * MSIRUNMODE_ZAWENABLED Demand installation is supported
648 * MSIRUNMODE_RESERVED14 Reserved
649 * MSIRUNMODE_RESERVED15 Reserved
650 * MSIRUNMODE_SCHEDULED called from install script
651 * MSIRUNMODE_ROLLBACK called from rollback script
652 * MSIRUNMODE_COMMIT called from commit script
656 * Not in the state: FALSE
659 BOOL WINAPI
MsiGetMode(MSIHANDLE hInstall
, MSIRUNMODE iRunMode
)
664 package
= msihandle2msiinfo(hInstall
, MSIHANDLETYPE_PACKAGE
);
669 IWineMsiRemotePackage
*remote_package
;
671 remote_package
= (IWineMsiRemotePackage
*)msi_get_remote(hInstall
);
675 hr
= IWineMsiRemotePackage_GetMode(remote_package
, iRunMode
, &ret
);
676 IWineMsiRemotePackage_Release(remote_package
);
686 case MSIRUNMODE_WINDOWS9X
:
687 if (GetVersion() & 0x80000000)
691 case MSIRUNMODE_OPERATIONS
:
692 case MSIRUNMODE_RESERVED11
:
693 case MSIRUNMODE_RESERVED14
:
694 case MSIRUNMODE_RESERVED15
:
697 case MSIRUNMODE_SCHEDULED
:
698 r
= package
->scheduled_action_running
;
701 case MSIRUNMODE_ROLLBACK
:
702 r
= package
->rollback_action_running
;
705 case MSIRUNMODE_COMMIT
:
706 r
= package
->commit_action_running
;
710 FIXME("%d %d\n", hInstall
, iRunMode
);
717 /***********************************************************************
720 UINT WINAPI
MsiSetMode(MSIHANDLE hInstall
, MSIRUNMODE iRunMode
, BOOL fState
)
725 TRACE("%d %d %d\n", hInstall
, iRunMode
, fState
);
727 package
= msihandle2msiinfo( hInstall
, MSIHANDLETYPE_PACKAGE
);
731 IWineMsiRemotePackage
*remote_package
;
733 remote_package
= (IWineMsiRemotePackage
*)msi_get_remote( hInstall
);
737 hr
= IWineMsiRemotePackage_SetMode( remote_package
, iRunMode
, fState
);
738 IWineMsiRemotePackage_Release( remote_package
);
742 if (HRESULT_FACILITY(hr
) == FACILITY_WIN32
)
743 return HRESULT_CODE(hr
);
745 return ERROR_FUNCTION_FAILED
;
748 return ERROR_SUCCESS
;
753 case MSIRUNMODE_REBOOTATEND
:
754 package
->need_reboot
= 1;
758 case MSIRUNMODE_REBOOTNOW
:
759 FIXME("unimplemented run mode\n");
760 r
= ERROR_FUNCTION_FAILED
;
764 r
= ERROR_ACCESS_DENIED
;
770 /***********************************************************************
771 * MsiSetFeatureStateA (MSI.@)
773 * According to the docs, when this is called it immediately recalculates
774 * all the component states as well
776 UINT WINAPI
MsiSetFeatureStateA(MSIHANDLE hInstall
, LPCSTR szFeature
,
779 LPWSTR szwFeature
= NULL
;
782 szwFeature
= strdupAtoW(szFeature
);
785 return ERROR_FUNCTION_FAILED
;
787 rc
= MsiSetFeatureStateW(hInstall
,szwFeature
, iState
);
789 msi_free(szwFeature
);
796 UINT WINAPI
MSI_SetFeatureStateW(MSIPACKAGE
* package
, LPCWSTR szFeature
,
799 UINT rc
= ERROR_SUCCESS
;
800 MSIFEATURE
*feature
, *child
;
802 TRACE("%s %i\n", debugstr_w(szFeature
), iState
);
804 feature
= get_loaded_feature(package
,szFeature
);
806 return ERROR_UNKNOWN_FEATURE
;
808 if (iState
== INSTALLSTATE_ADVERTISED
&&
809 feature
->Attributes
& msidbFeatureAttributesDisallowAdvertise
)
810 return ERROR_FUNCTION_FAILED
;
812 msi_feature_set_state(package
, feature
, iState
);
814 ACTION_UpdateComponentStates(package
,szFeature
);
816 /* update all the features that are children of this feature */
817 LIST_FOR_EACH_ENTRY( child
, &package
->features
, MSIFEATURE
, entry
)
819 if (lstrcmpW(szFeature
, child
->Feature_Parent
) == 0)
820 MSI_SetFeatureStateW(package
, child
->Feature
, iState
);
826 /***********************************************************************
827 * MsiSetFeatureStateW (MSI.@)
829 UINT WINAPI
MsiSetFeatureStateW(MSIHANDLE hInstall
, LPCWSTR szFeature
,
833 UINT rc
= ERROR_SUCCESS
;
835 TRACE("%s %i\n",debugstr_w(szFeature
), iState
);
837 package
= msihandle2msiinfo(hInstall
, MSIHANDLETYPE_PACKAGE
);
842 IWineMsiRemotePackage
*remote_package
;
844 remote_package
= (IWineMsiRemotePackage
*)msi_get_remote(hInstall
);
846 return ERROR_INVALID_HANDLE
;
848 feature
= SysAllocString(szFeature
);
851 IWineMsiRemotePackage_Release(remote_package
);
852 return ERROR_OUTOFMEMORY
;
855 hr
= IWineMsiRemotePackage_SetFeatureState(remote_package
, feature
, iState
);
857 SysFreeString(feature
);
858 IWineMsiRemotePackage_Release(remote_package
);
862 if (HRESULT_FACILITY(hr
) == FACILITY_WIN32
)
863 return HRESULT_CODE(hr
);
865 return ERROR_FUNCTION_FAILED
;
868 return ERROR_SUCCESS
;
871 rc
= MSI_SetFeatureStateW(package
,szFeature
,iState
);
873 msiobj_release( &package
->hdr
);
877 /***********************************************************************
878 * MsiGetFeatureStateA (MSI.@)
880 UINT WINAPI
MsiGetFeatureStateA(MSIHANDLE hInstall
, LPCSTR szFeature
,
881 INSTALLSTATE
*piInstalled
, INSTALLSTATE
*piAction
)
883 LPWSTR szwFeature
= NULL
;
886 szwFeature
= strdupAtoW(szFeature
);
888 rc
= MsiGetFeatureStateW(hInstall
,szwFeature
,piInstalled
, piAction
);
890 msi_free( szwFeature
);
895 UINT
MSI_GetFeatureStateW(MSIPACKAGE
*package
, LPCWSTR szFeature
,
896 INSTALLSTATE
*piInstalled
, INSTALLSTATE
*piAction
)
900 feature
= get_loaded_feature(package
,szFeature
);
902 return ERROR_UNKNOWN_FEATURE
;
905 *piInstalled
= feature
->Installed
;
908 *piAction
= feature
->Action
;
910 TRACE("returning %i %i\n", feature
->Installed
, feature
->Action
);
912 return ERROR_SUCCESS
;
915 /***********************************************************************
916 * MsiGetFeatureStateW (MSI.@)
918 UINT WINAPI
MsiGetFeatureStateW(MSIHANDLE hInstall
, LPCWSTR szFeature
,
919 INSTALLSTATE
*piInstalled
, INSTALLSTATE
*piAction
)
924 TRACE("%d %s %p %p\n", hInstall
, debugstr_w(szFeature
), piInstalled
, piAction
);
926 package
= msihandle2msiinfo(hInstall
, MSIHANDLETYPE_PACKAGE
);
931 IWineMsiRemotePackage
*remote_package
;
933 remote_package
= (IWineMsiRemotePackage
*)msi_get_remote(hInstall
);
935 return ERROR_INVALID_HANDLE
;
937 feature
= SysAllocString(szFeature
);
940 IWineMsiRemotePackage_Release(remote_package
);
941 return ERROR_OUTOFMEMORY
;
944 hr
= IWineMsiRemotePackage_GetFeatureState(remote_package
, feature
,
945 piInstalled
, piAction
);
947 SysFreeString(feature
);
948 IWineMsiRemotePackage_Release(remote_package
);
952 if (HRESULT_FACILITY(hr
) == FACILITY_WIN32
)
953 return HRESULT_CODE(hr
);
955 return ERROR_FUNCTION_FAILED
;
958 return ERROR_SUCCESS
;
961 ret
= MSI_GetFeatureStateW(package
, szFeature
, piInstalled
, piAction
);
962 msiobj_release( &package
->hdr
);
966 /***********************************************************************
967 * MsiGetFeatureCostA (MSI.@)
969 UINT WINAPI
MsiGetFeatureCostA(MSIHANDLE hInstall
, LPCSTR szFeature
,
970 MSICOSTTREE iCostTree
, INSTALLSTATE iState
, LPINT piCost
)
972 LPWSTR szwFeature
= NULL
;
975 szwFeature
= strdupAtoW(szFeature
);
977 rc
= MsiGetFeatureCostW(hInstall
, szwFeature
, iCostTree
, iState
, piCost
);
979 msi_free(szwFeature
);
984 UINT
MSI_GetFeatureCost(MSIPACKAGE
*package
, MSIFEATURE
*feature
,
985 MSICOSTTREE iCostTree
, INSTALLSTATE iState
,
988 FIXME("(%s %i %i %p): not implemented yet\n",
989 debugstr_w(feature
->Feature
), iCostTree
, iState
, piCost
);
990 if (piCost
) *piCost
= 0;
991 return ERROR_SUCCESS
;
994 /***********************************************************************
995 * MsiGetFeatureCostW (MSI.@)
997 UINT WINAPI
MsiGetFeatureCostW(MSIHANDLE hInstall
, LPCWSTR szFeature
,
998 MSICOSTTREE iCostTree
, INSTALLSTATE iState
, LPINT piCost
)
1000 MSIPACKAGE
*package
;
1001 MSIFEATURE
*feature
;
1004 TRACE("(%d %s %i %i %p)\n", hInstall
, debugstr_w(szFeature
),
1005 iCostTree
, iState
, piCost
);
1007 package
= msihandle2msiinfo(hInstall
, MSIHANDLETYPE_PACKAGE
);
1012 IWineMsiRemotePackage
*remote_package
;
1014 remote_package
= (IWineMsiRemotePackage
*)msi_get_remote(hInstall
);
1015 if (!remote_package
)
1016 return ERROR_INVALID_HANDLE
;
1018 feature
= SysAllocString(szFeature
);
1021 IWineMsiRemotePackage_Release(remote_package
);
1022 return ERROR_OUTOFMEMORY
;
1025 hr
= IWineMsiRemotePackage_GetFeatureCost(remote_package
, feature
,
1026 iCostTree
, iState
, piCost
);
1028 SysFreeString(feature
);
1029 IWineMsiRemotePackage_Release(remote_package
);
1033 if (HRESULT_FACILITY(hr
) == FACILITY_WIN32
)
1034 return HRESULT_CODE(hr
);
1036 return ERROR_FUNCTION_FAILED
;
1039 return ERROR_SUCCESS
;
1042 feature
= get_loaded_feature(package
, szFeature
);
1045 ret
= MSI_GetFeatureCost(package
, feature
, iCostTree
, iState
, piCost
);
1047 ret
= ERROR_UNKNOWN_FEATURE
;
1049 msiobj_release( &package
->hdr
);
1053 /***********************************************************************
1054 * MsiSetComponentStateA (MSI.@)
1056 UINT WINAPI
MsiSetComponentStateA(MSIHANDLE hInstall
, LPCSTR szComponent
,
1057 INSTALLSTATE iState
)
1060 LPWSTR szwComponent
= strdupAtoW(szComponent
);
1062 rc
= MsiSetComponentStateW(hInstall
, szwComponent
, iState
);
1064 msi_free(szwComponent
);
1069 /***********************************************************************
1070 * MsiGetComponentStateA (MSI.@)
1072 UINT WINAPI
MsiGetComponentStateA(MSIHANDLE hInstall
, LPCSTR szComponent
,
1073 INSTALLSTATE
*piInstalled
, INSTALLSTATE
*piAction
)
1075 LPWSTR szwComponent
= NULL
;
1078 szwComponent
= strdupAtoW(szComponent
);
1080 rc
= MsiGetComponentStateW(hInstall
,szwComponent
,piInstalled
, piAction
);
1082 msi_free( szwComponent
);
1087 static UINT
MSI_SetComponentStateW(MSIPACKAGE
*package
, LPCWSTR szComponent
,
1088 INSTALLSTATE iState
)
1092 TRACE("%p %s %d\n", package
, debugstr_w(szComponent
), iState
);
1094 comp
= get_loaded_component(package
, szComponent
);
1096 return ERROR_UNKNOWN_COMPONENT
;
1098 comp
->Installed
= iState
;
1100 return ERROR_SUCCESS
;
1103 UINT
MSI_GetComponentStateW(MSIPACKAGE
*package
, LPCWSTR szComponent
,
1104 INSTALLSTATE
*piInstalled
, INSTALLSTATE
*piAction
)
1108 TRACE("%p %s %p %p\n", package
, debugstr_w(szComponent
),
1109 piInstalled
, piAction
);
1111 comp
= get_loaded_component(package
,szComponent
);
1113 return ERROR_UNKNOWN_COMPONENT
;
1116 *piInstalled
= comp
->Installed
;
1119 *piAction
= comp
->Action
;
1121 TRACE("states (%i, %i)\n", comp
->Installed
, comp
->Action
);
1123 return ERROR_SUCCESS
;
1126 /***********************************************************************
1127 * MsiSetComponentStateW (MSI.@)
1129 UINT WINAPI
MsiSetComponentStateW(MSIHANDLE hInstall
, LPCWSTR szComponent
,
1130 INSTALLSTATE iState
)
1132 MSIPACKAGE
* package
;
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 component
= SysAllocString(szComponent
);
1149 IWineMsiRemotePackage_Release(remote_package
);
1150 return ERROR_OUTOFMEMORY
;
1153 hr
= IWineMsiRemotePackage_SetComponentState(remote_package
, component
, iState
);
1155 SysFreeString(component
);
1156 IWineMsiRemotePackage_Release(remote_package
);
1160 if (HRESULT_FACILITY(hr
) == FACILITY_WIN32
)
1161 return HRESULT_CODE(hr
);
1163 return ERROR_FUNCTION_FAILED
;
1166 return ERROR_SUCCESS
;
1169 ret
= MSI_SetComponentStateW(package
, szComponent
, iState
);
1170 msiobj_release(&package
->hdr
);
1174 /***********************************************************************
1175 * MsiGetComponentStateW (MSI.@)
1177 UINT WINAPI
MsiGetComponentStateW(MSIHANDLE hInstall
, LPCWSTR szComponent
,
1178 INSTALLSTATE
*piInstalled
, INSTALLSTATE
*piAction
)
1180 MSIPACKAGE
* package
;
1183 TRACE("%d %s %p %p\n", hInstall
, debugstr_w(szComponent
),
1184 piInstalled
, piAction
);
1186 package
= msihandle2msiinfo(hInstall
, MSIHANDLETYPE_PACKAGE
);
1191 IWineMsiRemotePackage
*remote_package
;
1193 remote_package
= (IWineMsiRemotePackage
*)msi_get_remote(hInstall
);
1194 if (!remote_package
)
1195 return ERROR_INVALID_HANDLE
;
1197 component
= SysAllocString(szComponent
);
1200 IWineMsiRemotePackage_Release(remote_package
);
1201 return ERROR_OUTOFMEMORY
;
1204 hr
= IWineMsiRemotePackage_GetComponentState(remote_package
, component
,
1205 piInstalled
, piAction
);
1207 SysFreeString(component
);
1208 IWineMsiRemotePackage_Release(remote_package
);
1212 if (HRESULT_FACILITY(hr
) == FACILITY_WIN32
)
1213 return HRESULT_CODE(hr
);
1215 return ERROR_FUNCTION_FAILED
;
1218 return ERROR_SUCCESS
;
1221 ret
= MSI_GetComponentStateW( package
, szComponent
, piInstalled
, piAction
);
1222 msiobj_release( &package
->hdr
);
1226 /***********************************************************************
1227 * MsiGetLanguage (MSI.@)
1229 LANGID WINAPI
MsiGetLanguage(MSIHANDLE hInstall
)
1231 MSIPACKAGE
* package
;
1233 static const WCHAR szProductLanguage
[] =
1234 {'P','r','o','d','u','c','t','L','a','n','g','u','a','g','e',0};
1236 package
= msihandle2msiinfo(hInstall
, MSIHANDLETYPE_PACKAGE
);
1241 IWineMsiRemotePackage
*remote_package
;
1243 remote_package
= (IWineMsiRemotePackage
*)msi_get_remote(hInstall
);
1244 if (!remote_package
)
1245 return ERROR_INVALID_HANDLE
;
1247 hr
= IWineMsiRemotePackage_GetLanguage(remote_package
, &lang
);
1255 langid
= msi_get_property_int( package
, szProductLanguage
, 0 );
1256 msiobj_release( &package
->hdr
);
1260 UINT
MSI_SetInstallLevel( MSIPACKAGE
*package
, int iInstallLevel
)
1262 static const WCHAR szInstallLevel
[] = {
1263 'I','N','S','T','A','L','L','L','E','V','E','L',0 };
1264 static const WCHAR fmt
[] = { '%','d',0 };
1268 TRACE("%p %i\n", package
, iInstallLevel
);
1270 if (iInstallLevel
> 32767)
1271 return ERROR_INVALID_PARAMETER
;
1273 if (iInstallLevel
< 1)
1274 return MSI_SetFeatureStates( package
);
1276 sprintfW( level
, fmt
, iInstallLevel
);
1277 r
= MSI_SetPropertyW( package
, szInstallLevel
, level
);
1278 if ( r
== ERROR_SUCCESS
)
1279 r
= MSI_SetFeatureStates( package
);
1284 /***********************************************************************
1285 * MsiSetInstallLevel (MSI.@)
1287 UINT WINAPI
MsiSetInstallLevel(MSIHANDLE hInstall
, int iInstallLevel
)
1289 MSIPACKAGE
* package
;
1292 TRACE("%d %i\n", hInstall
, iInstallLevel
);
1294 package
= msihandle2msiinfo(hInstall
, MSIHANDLETYPE_PACKAGE
);
1298 IWineMsiRemotePackage
*remote_package
;
1300 remote_package
= (IWineMsiRemotePackage
*)msi_get_remote(hInstall
);
1301 if (!remote_package
)
1302 return ERROR_INVALID_HANDLE
;
1304 hr
= IWineMsiRemotePackage_SetInstallLevel(remote_package
, iInstallLevel
);
1306 IWineMsiRemotePackage_Release(remote_package
);
1310 if (HRESULT_FACILITY(hr
) == FACILITY_WIN32
)
1311 return HRESULT_CODE(hr
);
1313 return ERROR_FUNCTION_FAILED
;
1316 return ERROR_SUCCESS
;
1319 r
= MSI_SetInstallLevel( package
, iInstallLevel
);
1321 msiobj_release( &package
->hdr
);
1326 /***********************************************************************
1327 * MsiGetFeatureValidStatesW (MSI.@)
1329 UINT WINAPI
MsiGetFeatureValidStatesW(MSIHANDLE hInstall
, LPCWSTR szFeature
,
1330 LPDWORD pInstallState
)
1332 if(pInstallState
) *pInstallState
= 1<<INSTALLSTATE_LOCAL
;
1333 FIXME("%d %s %p stub returning %d\n",
1334 hInstall
, debugstr_w(szFeature
), pInstallState
, pInstallState
? *pInstallState
: 0);
1336 return ERROR_SUCCESS
;
1339 /***********************************************************************
1340 * MsiGetFeatureValidStatesA (MSI.@)
1342 UINT WINAPI
MsiGetFeatureValidStatesA(MSIHANDLE hInstall
, LPCSTR szFeature
,
1343 LPDWORD pInstallState
)
1346 LPWSTR szwFeature
= strdupAtoW(szFeature
);
1348 ret
= MsiGetFeatureValidStatesW(hInstall
, szwFeature
, pInstallState
);
1350 msi_free(szwFeature
);