| Left: | ||
| Right: |
| OLD | NEW |
|---|---|
| (Empty) | |
| 1 /** | |
| 2 * \file database.h MSI database | |
| 3 */ | |
| 4 | |
| 5 #include "database.h" | |
| 6 #include "msiquery.h" | |
| 7 | |
| 8 //------------------------------------------------------------------------------ ----------- | |
| 9 // Database | |
| 10 //------------------------------------------------------------------------------ ----------- | |
| 11 /** | |
| 12 * \par Implementation Notes | |
| 13 * An MSI database handle is an overloaded type, used both for installation d atabases and one opened outside an installation. | |
| 14 * Hence this base constructor initializes with that handle. | |
| 15 * | |
| 16 * \sa MSDN "Obtaining a Database Handle" | |
| 17 * http://msdn.microsoft.com/en-us/library/windows/desktop/aa370541(v=vs.85). aspx | |
| 18 */ | |
| 19 Database::Database( MSIHANDLE handle ) | |
| 20 : handle( handle ) | |
| 21 { | |
| 22 } | |
| 23 | |
| 24 Database::~Database() | |
| 25 { | |
| 26 MsiCloseHandle( handle ) ; | |
| 27 } | |
|
Wladimir Palant
2013/10/29 08:49:26
I cannot really imagine the situation where our cu
Eric
2013/10/29 14:00:58
Before I get into everything, let me start off by
Wladimir Palant
2013/10/29 15:06:38
Ok, I understand it that we will need a tool to ge
| |
| 28 | |
| 29 //------------------------------------------------------------------------------ ----------- | |
| 30 // Installation_Database | |
| 31 //------------------------------------------------------------------------------ ----------- | |
| 32 | |
| 33 /** | |
| 34 * Helper function for Installation_Database constructor. | |
| 35 * | |
| 36 * \par Resource Allocator | |
| 37 * Return value of this function, a handle, must be released in order to avoi d a resource leak. | |
| 38 * Passing it as an argument to the Database constructor is adequate. | |
| 39 */ | |
| 40 MSIHANDLE get_active_database( Immediate_Session & session ) | |
| 41 { | |
| 42 MSIHANDLE h = MsiGetActiveDatabase( session.handle ) ; | |
| 43 if ( h == 0 ) | |
| 44 { | |
| 45 throw std::runtime_error( "Failed to retrieve active databases" ) ; | |
| 46 } | |
| 47 return h ; | |
| 48 } | |
| 49 | |
| 50 /** | |
| 51 * \par Implementation Notes | |
| 52 * The only thing this constructor needs to do is to initialize the base clas s. | |
| 53 */ | |
| 54 Installation_Database::Installation_Database( Immediate_Session & session ) | |
| 55 : Database( get_active_database( session ) ) | |
| 56 { | |
| 57 // empty body | |
| 58 } | |
| OLD | NEW |