1 #include "msihelper.hxx"
6 bool GetMsiProp(MSIHANDLE handle
, LPCTSTR name
, /*out*/std::wstring
& value
)
9 LPTSTR dummy
= TEXT("");
10 if (MsiGetProperty(handle
, name
, dummy
, &sz
) == ERROR_MORE_DATA
)
13 DWORD nbytes
= sz
* sizeof(TCHAR
);
14 LPTSTR buff
= reinterpret_cast<LPTSTR
>(_alloca(nbytes
));
15 ZeroMemory(buff
, nbytes
);
16 MsiGetProperty(handle
, name
, buff
, &sz
);
23 void SetMsiProp(MSIHANDLE handle
, LPCTSTR name
)
25 MsiSetProperty(handle
, name
, TEXT("1"));
28 void UnsetMsiProp(MSIHANDLE handle
, LPCTSTR name
)
30 MsiSetProperty(handle
, name
, TEXT(""));
33 bool IsSetMsiProp(MSIHANDLE handle
, LPCTSTR name
)
36 GetMsiProp(handle
, name
, val
);
37 return (val
== TEXT("1"));
40 bool IsMsiPropNotEmpty(MSIHANDLE handle
, LPCTSTR name
)
43 GetMsiProp(handle
, name
, val
);
44 return (val
!= TEXT(""));
47 bool IsAllUserInstallation(MSIHANDLE handle
)
49 return IsSetMsiProp(handle
, TEXT("ALLUSERS"));
52 std::wstring
GetOfficeInstallationPath(MSIHANDLE handle
)
54 std::wstring progpath
;
55 GetMsiProp(handle
, TEXT("OFFICEINSTALLLOCATION"), progpath
);
59 std::wstring
GetOfficeExecutablePath(MSIHANDLE handle
)
61 std::wstring exepath
= GetOfficeInstallationPath(handle
);
62 exepath
+= TEXT("program\\soffice.exe");
66 std::wstring
GetProductName(MSIHANDLE handle
)
68 std::wstring prodname
;
69 GetMsiProp(handle
, TEXT("ProductName"), prodname
);
73 bool IsModuleInstalled(MSIHANDLE handle
, LPCTSTR name
)
75 INSTALLSTATE current_state
;
76 INSTALLSTATE future_state
;
77 MsiGetFeatureState(handle
, name
, ¤t_state
, &future_state
);
78 return (current_state
== INSTALLSTATE_LOCAL
);
81 bool IsModuleSelectedForInstallation(MSIHANDLE handle
, LPCTSTR name
)
83 INSTALLSTATE current_state
;
84 INSTALLSTATE future_state
;
85 MsiGetFeatureState(handle
, name
, ¤t_state
, &future_state
);
86 return (future_state
== INSTALLSTATE_LOCAL
);
89 bool IsModuleSelectedForDeinstallation(MSIHANDLE handle
, LPCTSTR name
)
91 INSTALLSTATE current_state
;
92 INSTALLSTATE future_state
;
93 MsiGetFeatureState(handle
, name
, ¤t_state
, &future_state
);
94 return ((current_state
== INSTALLSTATE_LOCAL
) && (future_state
== INSTALLSTATE_ABSENT
));
97 bool IsCompleteDeinstallation(MSIHANDLE handle
)
100 GetMsiProp(handle
, TEXT("REMOVE"), rm
);
101 return (rm
== TEXT("ALL"));