24template<
class _Traits,
class _Ax>
25static UINT
MsiGetPropertyA(_In_ MSIHANDLE hInstall, _In_z_ LPCSTR szName, _Inout_ std::basic_string<char, _Traits, _Ax> &sValue)
30 DWORD dwSize = _countof(szStackBuffer);
35 if (uiResult == ERROR_SUCCESS) {
37 sValue.assign(szStackBuffer, dwSize);
39 }
else if (uiResult == ERROR_MORE_DATA) {
41 std::unique_ptr<char[]> szBuffer(
new char[++dwSize]);
43 sValue.assign(szBuffer.get(), uiResult == ERROR_SUCCESS ? dwSize : 0);
56template<
class _Traits,
class _Ax>
57static UINT
MsiGetPropertyW(_In_ MSIHANDLE hInstall, _In_z_ LPCWSTR szName, _Inout_ std::basic_string<wchar_t, _Traits, _Ax> &sValue)
60 DWORD dwSize = _countof(szStackBuffer);
65 if (uiResult == ERROR_SUCCESS) {
67 sValue.assign(szStackBuffer, dwSize);
69 }
else if (uiResult == ERROR_MORE_DATA) {
71 std::unique_ptr<wchar_t[]> szBuffer(
new wchar_t[++dwSize]);
73 sValue.assign(szBuffer.get(), uiResult == ERROR_SUCCESS ? dwSize : 0);
82template<
class _Traits,
class _Ax>
83static UINT
MsiRecordGetStringA(_In_ MSIHANDLE hRecord, _In_
unsigned int iField, _Inout_ std::basic_string<char, _Traits, _Ax> &sValue)
88 DWORD dwSize = _countof(szStackBuffer);
93 if (uiResult == ERROR_SUCCESS) {
95 sValue.assign(szStackBuffer, dwSize);
97 }
else if (uiResult == ERROR_MORE_DATA) {
99 std::unique_ptr<char[]> szBuffer(
new char[++dwSize]);
101 sValue.assign(szBuffer.get(), uiResult == ERROR_SUCCESS ? dwSize : 0);
114template<
class _Traits,
class _Ax>
115static UINT
MsiRecordGetStringW(_In_ MSIHANDLE hRecord, _In_
unsigned int iField, _Inout_ std::basic_string<wchar_t, _Traits, _Ax> &sValue)
118 DWORD dwSize = _countof(szStackBuffer);
123 if (uiResult == ERROR_SUCCESS) {
125 sValue.assign(szStackBuffer, dwSize);
126 return ERROR_SUCCESS;
127 }
else if (uiResult == ERROR_MORE_DATA) {
129 std::unique_ptr<wchar_t[]> szBuffer(
new wchar_t[++dwSize]);
131 sValue.assign(szBuffer.get(), uiResult == ERROR_SUCCESS ? dwSize : 0);
140template<
class _Traits,
class _Ax>
141static UINT
MsiFormatRecordA(_In_ MSIHANDLE hInstall, _In_ MSIHANDLE hRecord, _Inout_ std::basic_string<char, _Traits, _Ax> &sValue)
146 DWORD dwSize = _countof(szStackBuffer);
151 if (uiResult == ERROR_SUCCESS) {
153 sValue.assign(szStackBuffer, dwSize);
154 return ERROR_SUCCESS;
155 }
else if (uiResult == ERROR_MORE_DATA) {
157 std::unique_ptr<char[]> szBuffer(
new char[++dwSize]);
159 sValue.assign(szBuffer.get(), uiResult == ERROR_SUCCESS ? dwSize : 0);
172template<
class _Traits,
class _Ax>
173static UINT
MsiFormatRecordW(_In_ MSIHANDLE hInstall, _In_ MSIHANDLE hRecord, _Inout_ std::basic_string<wchar_t, _Traits, _Ax> &sValue)
176 DWORD dwSize = _countof(szStackBuffer);
181 if (uiResult == ERROR_SUCCESS) {
183 sValue.assign(szStackBuffer, dwSize);
184 return ERROR_SUCCESS;
185 }
else if (uiResult == ERROR_MORE_DATA) {
187 std::unique_ptr<wchar_t[]> szBuffer(
new wchar_t[++dwSize]);
189 sValue.assign(szBuffer.get(), uiResult == ERROR_SUCCESS ? dwSize : 0);
202template<
class _Ty,
class _Ax>
203static UINT
MsiRecordReadStream(_In_ MSIHANDLE hRecord, _In_
unsigned int iField, _Inout_ std::vector<_Ty, _Ax> &binData)
212 if (uiResult == ERROR_SUCCESS) {
213 binData.resize((dwSize +
sizeof(_Ty) - 1) /
sizeof(_Ty));
222template<
class _Traits,
class _Ax>
223static UINT
MsiGetTargetPathA(_In_ MSIHANDLE hInstall, _In_z_ LPCSTR szFolder, _Out_ std::basic_string<char, _Traits, _Ax> &sValue)
228 DWORD dwSize = _countof(szStackBuffer);
233 if (uiResult == ERROR_SUCCESS) {
235 sValue.assign(szStackBuffer, dwSize);
236 return ERROR_SUCCESS;
237 }
else if (uiResult == ERROR_MORE_DATA) {
239 std::unique_ptr<char[]> szBuffer(
new char[++dwSize]);
241 sValue.assign(szBuffer.get(), uiResult == ERROR_SUCCESS ? dwSize : 0);
254template<
class _Traits,
class _Ax>
255static UINT
MsiGetTargetPathW(_In_ MSIHANDLE hInstall, _In_z_ LPCWSTR szFolder, _Inout_ std::basic_string<wchar_t, _Traits, _Ax> &sValue)
258 DWORD dwSize = _countof(szStackBuffer);
263 if (uiResult == ERROR_SUCCESS) {
265 sValue.assign(szStackBuffer, dwSize);
266 return ERROR_SUCCESS;
267 }
else if (uiResult == ERROR_MORE_DATA) {
269 std::unique_ptr<wchar_t[]> szBuffer(
new wchar_t[++dwSize]);
271 sValue.assign(szBuffer.get(), uiResult == ERROR_SUCCESS ? dwSize : 0);
280template<
class _Traits,
class _Ax>
281static INSTALLSTATE
MsiGetComponentPathA(_In_z_ LPCSTR szProduct, _In_z_ LPCSTR szComponent, _Inout_ std::basic_string<char, _Traits, _Ax> &sValue)
284 DWORD dwSize = _countof(szStackBuffer);
289 if (state >= INSTALLSTATE_BROKEN) {
291 sValue.assign(szStackBuffer, dwSize);
293 }
else if (state == INSTALLSTATE_MOREDATA) {
295 std::unique_ptr<char[]> szBuffer(
new char[++dwSize]);
297 sValue.assign(szBuffer.get(), state >= INSTALLSTATE_BROKEN ? dwSize : 0);
310template<
class _Traits,
class _Ax>
311static INSTALLSTATE
MsiGetComponentPathW(_In_z_ LPCWSTR szProduct, _In_z_ LPCWSTR szComponent, _Inout_ std::basic_string<wchar_t, _Traits, _Ax> &sValue)
314 DWORD dwSize = _countof(szStackBuffer);
319 if (state >= INSTALLSTATE_BROKEN) {
321 sValue.assign(szStackBuffer, dwSize);
323 }
else if (state == INSTALLSTATE_MOREDATA) {
325 std::unique_ptr<wchar_t[]> szBuffer(
new wchar_t[++dwSize]);
327 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:101
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:173
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:57
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:223
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:281
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:115
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:255
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:25
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:141
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:203
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:311
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:83