20template<
class _Traits,
class _Ax>
21static UINT
MsiGetPropertyA(_In_ MSIHANDLE hInstall, _In_z_ LPCSTR szName, _Inout_ std::basic_string<char, _Traits, _Ax> &sValue)
26 DWORD dwSize = _countof(szStackBuffer);
31 if (uiResult == ERROR_SUCCESS) {
33 sValue.assign(szStackBuffer, dwSize);
35 }
else if (uiResult == ERROR_MORE_DATA) {
37 std::unique_ptr<char[]> szBuffer(
new char[++dwSize]);
39 sValue.assign(szBuffer.get(), uiResult == ERROR_SUCCESS ? dwSize : 0);
52template<
class _Traits,
class _Ax>
53static UINT
MsiGetPropertyW(_In_ MSIHANDLE hInstall, _In_z_ LPCWSTR szName, _Inout_ std::basic_string<wchar_t, _Traits, _Ax> &sValue)
56 DWORD dwSize = _countof(szStackBuffer);
61 if (uiResult == ERROR_SUCCESS) {
63 sValue.assign(szStackBuffer, dwSize);
65 }
else if (uiResult == ERROR_MORE_DATA) {
67 std::unique_ptr<wchar_t[]> szBuffer(
new wchar_t[++dwSize]);
69 sValue.assign(szBuffer.get(), uiResult == ERROR_SUCCESS ? dwSize : 0);
78template<
class _Traits,
class _Ax>
79static UINT
MsiRecordGetStringA(_In_ MSIHANDLE hRecord, _In_
unsigned int iField, _Inout_ std::basic_string<char, _Traits, _Ax> &sValue)
84 DWORD dwSize = _countof(szStackBuffer);
89 if (uiResult == ERROR_SUCCESS) {
91 sValue.assign(szStackBuffer, dwSize);
93 }
else if (uiResult == ERROR_MORE_DATA) {
95 std::unique_ptr<char[]> szBuffer(
new char[++dwSize]);
97 sValue.assign(szBuffer.get(), uiResult == ERROR_SUCCESS ? dwSize : 0);
110template<
class _Traits,
class _Ax>
111static UINT
MsiRecordGetStringW(_In_ MSIHANDLE hRecord, _In_
unsigned int iField, _Inout_ std::basic_string<wchar_t, _Traits, _Ax> &sValue)
114 DWORD dwSize = _countof(szStackBuffer);
119 if (uiResult == ERROR_SUCCESS) {
121 sValue.assign(szStackBuffer, dwSize);
122 return ERROR_SUCCESS;
123 }
else if (uiResult == ERROR_MORE_DATA) {
125 std::unique_ptr<wchar_t[]> szBuffer(
new wchar_t[++dwSize]);
127 sValue.assign(szBuffer.get(), uiResult == ERROR_SUCCESS ? dwSize : 0);
136template<
class _Traits,
class _Ax>
137static UINT
MsiFormatRecordA(_In_opt_ MSIHANDLE hInstall, _In_ MSIHANDLE hRecord, _Inout_ std::basic_string<char, _Traits, _Ax> &sValue)
142 DWORD dwSize = _countof(szStackBuffer);
147 if (uiResult == ERROR_SUCCESS) {
149 sValue.assign(szStackBuffer, dwSize);
150 return ERROR_SUCCESS;
151 }
else if (uiResult == ERROR_MORE_DATA) {
153 std::unique_ptr<char[]> szBuffer(
new char[++dwSize]);
155 sValue.assign(szBuffer.get(), uiResult == ERROR_SUCCESS ? dwSize : 0);
168template<
class _Traits,
class _Ax>
169static UINT
MsiFormatRecordW(_In_opt_ MSIHANDLE hInstall, _In_ MSIHANDLE hRecord, _Inout_ std::basic_string<wchar_t, _Traits, _Ax> &sValue)
172 DWORD dwSize = _countof(szStackBuffer);
177 if (uiResult == ERROR_SUCCESS) {
179 sValue.assign(szStackBuffer, dwSize);
180 return ERROR_SUCCESS;
181 }
else if (uiResult == ERROR_MORE_DATA) {
183 std::unique_ptr<wchar_t[]> szBuffer(
new wchar_t[++dwSize]);
185 sValue.assign(szBuffer.get(), uiResult == ERROR_SUCCESS ? dwSize : 0);
198template<
class _Ty,
class _Ax>
199static UINT
MsiRecordReadStream(_In_ MSIHANDLE hRecord, _In_
unsigned int iField, _Inout_ std::vector<_Ty, _Ax> &binData)
208 if (uiResult == ERROR_SUCCESS) {
209 binData.resize((dwSize +
sizeof(_Ty) - 1) /
sizeof(_Ty));
210 return ::MsiRecordReadStream(hRecord, iField,
reinterpret_cast<char*
>(binData.data()), &dwSize);
218template<
class _Traits,
class _Ax>
219static UINT
MsiGetTargetPathA(_In_ MSIHANDLE hInstall, _In_z_ LPCSTR szFolder, _Out_ std::basic_string<char, _Traits, _Ax> &sValue)
224 DWORD dwSize = _countof(szStackBuffer);
229 if (uiResult == ERROR_SUCCESS) {
231 sValue.assign(szStackBuffer, dwSize);
232 return ERROR_SUCCESS;
233 }
else if (uiResult == ERROR_MORE_DATA) {
235 std::unique_ptr<char[]> szBuffer(
new char[++dwSize]);
237 sValue.assign(szBuffer.get(), uiResult == ERROR_SUCCESS ? dwSize : 0);
250template<
class _Traits,
class _Ax>
251static UINT
MsiGetTargetPathW(_In_ MSIHANDLE hInstall, _In_z_ LPCWSTR szFolder, _Inout_ std::basic_string<wchar_t, _Traits, _Ax> &sValue)
254 DWORD dwSize = _countof(szStackBuffer);
259 if (uiResult == ERROR_SUCCESS) {
261 sValue.assign(szStackBuffer, dwSize);
262 return ERROR_SUCCESS;
263 }
else if (uiResult == ERROR_MORE_DATA) {
265 std::unique_ptr<wchar_t[]> szBuffer(
new wchar_t[++dwSize]);
267 sValue.assign(szBuffer.get(), uiResult == ERROR_SUCCESS ? dwSize : 0);
276template<
class _Traits,
class _Ax>
277static INSTALLSTATE
MsiGetComponentPathA(_In_z_ LPCSTR szProduct, _In_z_ LPCSTR szComponent, _Inout_ std::basic_string<char, _Traits, _Ax> &sValue)
280 DWORD dwSize = _countof(szStackBuffer);
285 if (state >= INSTALLSTATE_BROKEN) {
287 sValue.assign(szStackBuffer, dwSize);
289 }
else if (state == INSTALLSTATE_MOREDATA) {
291 std::unique_ptr<char[]> szBuffer(
new char[++dwSize]);
293 sValue.assign(szBuffer.get(), state >= INSTALLSTATE_BROKEN ? dwSize : 0);
306template<
class _Traits,
class _Ax>
307static INSTALLSTATE
MsiGetComponentPathW(_In_z_ LPCWSTR szProduct, _In_z_ LPCWSTR szComponent, _Inout_ std::basic_string<wchar_t, _Traits, _Ax> &sValue)
310 DWORD dwSize = _countof(szStackBuffer);
315 if (state >= INSTALLSTATE_BROKEN) {
317 sValue.assign(szStackBuffer, dwSize);
319 }
else if (state == INSTALLSTATE_MOREDATA) {
321 std::unique_ptr<wchar_t[]> szBuffer(
new wchar_t[++dwSize]);
323 sValue.assign(szBuffer.get(), state >= INSTALLSTATE_BROKEN ? dwSize : 0);
#define WINSTD_STACK_BUFFER_BYTES
Size of the stack buffer in bytes used for initial system function call.
Definition Common.h:94
static UINT MsiFormatRecordW(MSIHANDLE hInstall, MSIHANDLE hRecord, std::basic_string< wchar_t, _Traits, _Ax > &sValue)
Formats record field data and properties using a format string and stores it in a std::wstring string...
Definition MSI.h:169
static UINT MsiGetPropertyW(MSIHANDLE hInstall, LPCWSTR szName, std::basic_string< wchar_t, _Traits, _Ax > &sValue)
Gets the value for an installer property and stores it in a std::wstring string.
Definition MSI.h:53
static UINT MsiGetTargetPathA(MSIHANDLE hInstall, LPCSTR szFolder, std::basic_string< char, _Traits, _Ax > &sValue)
Returns the full target path for a folder in the Directory table and stores it in a std::wstring stri...
Definition MSI.h:219
static INSTALLSTATE MsiGetComponentPathA(LPCSTR szProduct, LPCSTR szComponent, std::basic_string< char, _Traits, _Ax > &sValue)
Returns the full path to an installed component. If the key path for the component is a registry key ...
Definition MSI.h:277
static UINT MsiRecordGetStringW(MSIHANDLE hRecord, unsigned int iField, std::basic_string< wchar_t, _Traits, _Ax > &sValue)
Returns the string value of a record field and stores it in a std::wstring string.
Definition MSI.h:111
static UINT MsiGetTargetPathW(MSIHANDLE hInstall, LPCWSTR szFolder, std::basic_string< wchar_t, _Traits, _Ax > &sValue)
Returns the full target path for a folder in the Directory table and stores it in a std::wstring stri...
Definition MSI.h:251
static UINT MsiGetPropertyA(MSIHANDLE hInstall, LPCSTR szName, std::basic_string< char, _Traits, _Ax > &sValue)
Gets the value for an installer property and stores it in a std::wstring string.
Definition MSI.h:21
static UINT MsiFormatRecordA(MSIHANDLE hInstall, MSIHANDLE hRecord, std::basic_string< char, _Traits, _Ax > &sValue)
Formats record field data and properties using a format string and stores it in a std::wstring string...
Definition MSI.h:137
static UINT MsiRecordReadStream(MSIHANDLE hRecord, unsigned int iField, std::vector< _Ty, _Ax > &binData)
Reads bytes from a record stream field into a std::vector buffer.
Definition MSI.h:199
static INSTALLSTATE MsiGetComponentPathW(LPCWSTR szProduct, LPCWSTR szComponent, std::basic_string< wchar_t, _Traits, _Ax > &sValue)
Returns the full path to an installed component. If the key path for the component is a registry key ...
Definition MSI.h:307
static UINT MsiRecordGetStringA(MSIHANDLE hRecord, unsigned int iField, std::basic_string< char, _Traits, _Ax > &sValue)
Returns the string value of a record field and stores it in a std::wstring string.
Definition MSI.h:79