1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 #include "msihelper.hxx"
7 bool GetMsiProp(MSIHANDLE handle
, LPCTSTR name
, /*out*/std::wstring
& value
)
10 LPTSTR dummy
= TEXT("");
11 if (MsiGetProperty(handle
, name
, dummy
, &sz
) == ERROR_MORE_DATA
)
14 DWORD nbytes
= sz
* sizeof(TCHAR
);
15 LPTSTR buff
= reinterpret_cast<LPTSTR
>(_alloca(nbytes
));
16 ZeroMemory(buff
, nbytes
);
17 MsiGetProperty(handle
, name
, buff
, &sz
);
24 void SetMsiProp(MSIHANDLE handle
, LPCTSTR name
)
26 MsiSetProperty(handle
, name
, TEXT("1"));
29 void UnsetMsiProp(MSIHANDLE handle
, LPCTSTR name
)
31 MsiSetProperty(handle
, name
, TEXT(""));
34 bool IsSetMsiProp(MSIHANDLE handle
, LPCTSTR name
)
37 GetMsiProp(handle
, name
, val
);
38 return (val
== TEXT("1"));
41 bool IsMsiPropNotEmpty(MSIHANDLE handle
, LPCTSTR name
)
44 GetMsiProp(handle
, name
, val
);
45 return (val
!= TEXT(""));
48 bool IsAllUserInstallation(MSIHANDLE handle
)
50 return IsSetMsiProp(handle
, TEXT("ALLUSERS"));
53 std::wstring
GetOfficeInstallationPath(MSIHANDLE handle
)
55 std::wstring progpath
;
56 GetMsiProp(handle
, TEXT("INSTALLLOCATION"), progpath
);
60 std::wstring
GetOfficeExecutablePath(MSIHANDLE handle
)
62 std::wstring exepath
= GetOfficeInstallationPath(handle
);
63 exepath
+= TEXT("program\\soffice.exe");
67 std::wstring
GetProductName(MSIHANDLE handle
)
69 std::wstring prodname
;
70 GetMsiProp(handle
, TEXT("ProductName"), prodname
);
74 bool IsModuleInstalled(MSIHANDLE handle
, LPCTSTR name
)
76 INSTALLSTATE current_state
;
77 INSTALLSTATE future_state
;
78 MsiGetFeatureState(handle
, name
, ¤t_state
, &future_state
);
79 return (current_state
== INSTALLSTATE_LOCAL
);
82 bool IsModuleSelectedForInstallation(MSIHANDLE handle
, LPCTSTR name
)
84 INSTALLSTATE current_state
;
85 INSTALLSTATE future_state
;
86 MsiGetFeatureState(handle
, name
, ¤t_state
, &future_state
);
87 return (future_state
== INSTALLSTATE_LOCAL
);
90 bool IsModuleSelectedForDeinstallation(MSIHANDLE handle
, LPCTSTR name
)
92 INSTALLSTATE current_state
;
93 INSTALLSTATE future_state
;
94 MsiGetFeatureState(handle
, name
, ¤t_state
, &future_state
);
95 return ((current_state
== INSTALLSTATE_LOCAL
) && (future_state
== INSTALLSTATE_ABSENT
));
98 bool IsCompleteDeinstallation(MSIHANDLE handle
)
101 GetMsiProp(handle
, TEXT("REMOVE"), rm
);
102 return (rm
== TEXT("ALL"));
105 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */