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 22 matching lines...) Expand all Loading... |
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 ; |
42 default: | 42 default: |
43 throw windows_api_error( "MsiGetPropertyW", x, "fixed buffer" ) ; | 43 throw WindowsApiError( "MsiGetPropertyW", x, "fixed buffer" ) ; |
44 } | 44 } |
45 // Assert we received ERROR_MORE_DATA | 45 // Assert we received ERROR_MORE_DATA |
46 // unique_ptr handles deallocation transparently | 46 // unique_ptr handles deallocation transparently |
47 std::unique_ptr< WCHAR[] > buffer2( new WCHAR[ length ] ) ; | 47 std::unique_ptr< WCHAR[] > buffer2( new WCHAR[ length ] ) ; |
48 x = MsiGetPropertyW( handle, name.c_str(), buffer2.get(), & length ) ; | 48 x = MsiGetPropertyW( handle, name.c_str(), buffer2.get(), & length ) ; |
49 switch ( x ) | 49 switch ( x ) |
50 { | 50 { |
51 case ERROR_SUCCESS: | 51 case ERROR_SUCCESS: |
52 return std::wstring( buffer2.get(), length ) ; | 52 return std::wstring( buffer2.get(), length ) ; |
53 default: | 53 default: |
54 throw windows_api_error( "MsiGetPropertyW", x, "allocated buffer" ) ; | 54 throw WindowsApiError( "MsiGetPropertyW", x, "allocated buffer" ) ; |
55 } | 55 } |
56 } | 56 } |
57 | 57 |
58 /** | 58 /** |
59 * \par Implementation | 59 * \par Implementation |
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 windows_api_error( "MsiSetPropertyW", x ) ; | 67 throw WindowsApiError( "MsiSetPropertyW", x ) ; |
68 } | 68 } |
69 } | 69 } |
OLD | NEW |