| OLD | NEW |
| 1 /** | 1 /** |
| 2 * \file property.cpp Implementation of Property class etc. | 2 * \file property.cpp Implementation of Property class etc. |
| 3 */ | 3 */ |
| 4 | 4 |
| 5 #include "installer-lib.h" | 5 #include "installer-lib.h" |
| 6 #include "property.h" | 6 #include "property.h" |
| 7 #include "session.h" | 7 #include "session.h" |
| 8 #include <msiquery.h> | 8 #include <msiquery.h> |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 * The center of the implementation is the <a href="http://msdn.microsoft.com/en-
us/library/windows/desktop/aa370134%28v=vs.85%29.aspx">MsiGetProperty function</
a>. | 21 * The center of the implementation is the <a href="http://msdn.microsoft.com/en-
us/library/windows/desktop/aa370134%28v=vs.85%29.aspx">MsiGetProperty function</
a>. |
| 22 */ | 22 */ |
| 23 Property::operator std::wstring() const | 23 Property::operator std::wstring() const |
| 24 { | 24 { |
| 25 /* | 25 /* |
| 26 * The first call gets the size, but also the actual value if it's short enough
. | 26 * The first call gets the size, but also the actual value if it's short enough
. |
| 27 * A second call, if necessary, allocates a sufficiently-long buffer and then g
ets the full value. | 27 * A second call, if necessary, allocates a sufficiently-long buffer and then g
ets the full value. |
| 28 * We use only a modest fixed-size buffer for the first step, because we handle
arbitrary-length property values in a second step. | 28 * We use only a modest fixed-size buffer for the first step, because we handle
arbitrary-length property values in a second step. |
| 29 */ | 29 */ |
| 30 // This buffer allocates on the stack, so we don't want it too large; 64 chara
cters is enough for most properties anyway. | 30 // This buffer allocates on the stack, so we don't want it too large; 64 chara
cters is enough for most properties anyway. |
| 31 WCHAR buffer1[64] = { L'\0' }; | 31 WCHAR buffer1[64] = {L'\0'}; |
| 32 DWORD length = sizeof(buffer1) / sizeof(WCHAR); | 32 DWORD length = sizeof(buffer1) / sizeof(WCHAR); |
| 33 UINT x = MsiGetPropertyW(handle, name.c_str(), buffer1, & length); | 33 UINT x = MsiGetPropertyW(handle, name.c_str(), buffer1, & length); |
| 34 switch (x) | 34 switch (x) |
| 35 { | 35 { |
| 36 case ERROR_SUCCESS: | 36 case ERROR_SUCCESS: |
| 37 // This call might succeed, which means the return value was short enough
to fit into the buffer. | 37 // This call might succeed, which means the return value was short enough
to fit into the buffer. |
| 38 return std::wstring(buffer1, length); | 38 return std::wstring(buffer1, length); |
| 39 case ERROR_MORE_DATA: | 39 case ERROR_MORE_DATA: |
| 40 // Do nothing yet. | 40 // Do nothing yet. |
| 41 break; | 41 break; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 60 * The center of the implementation is the <a href="http://msdn.microsoft.com/en-
us/library/windows/desktop/aa370391%28v=vs.85%29.aspx">MsiSetProperty function</
a>. | 60 * The center of the implementation is the <a href="http://msdn.microsoft.com/en-
us/library/windows/desktop/aa370391%28v=vs.85%29.aspx">MsiSetProperty function</
a>. |
| 61 */ | 61 */ |
| 62 void Property::operator=(const std::wstring& value) | 62 void Property::operator=(const std::wstring& value) |
| 63 { | 63 { |
| 64 UINT x = MsiSetPropertyW(handle, name.c_str(), value.c_str()); | 64 UINT x = MsiSetPropertyW(handle, name.c_str(), value.c_str()); |
| 65 if (x != ERROR_SUCCESS) | 65 if (x != ERROR_SUCCESS) |
| 66 { | 66 { |
| 67 throw WindowsApiError("MsiSetPropertyW", x); | 67 throw WindowsApiError("MsiSetPropertyW", x); |
| 68 } | 68 } |
| 69 } | 69 } |
| OLD | NEW |