Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

717 lines
35 KiB

  1. /*****************************************************************************\
  2. * *
  3. * MsiQuery.h - Interface to running installer for custom actions and tools *
  4. * *
  5. * Version 2.0 *
  6. * *
  7. * NOTES: All buffers sizes are TCHAR count, null included only on input *
  8. * Return argument pointers may be null if not interested in value *
  9. * Returned handles of all types must be closed: MsiCloseHandle(h) *
  10. * Functions with UINT return type return a system error code *
  11. * Designated functions will set or clear the last error record, *
  12. * which is then accessible with MsiGetLastErrorRecord. However, *
  13. * the following argument errors do not register an error record: *
  14. * ERROR_INVALID_HANDLE, ERROR_INVALID_PARAMETER, ERROR_MORE_DATA. *
  15. * *
  16. * Copyright (c) Microsoft Corporation. All rights reserved. *
  17. * *
  18. \*****************************************************************************/
  19. #ifndef _MSIQUERY_H_
  20. #define _MSIQUERY_H_
  21. #include "msi.h" // INSTALLSTATE
  22. #define MSI_NULL_INTEGER 0x80000000 // integer value reserved for null
  23. // MsiOpenDatabase persist predefine values, otherwise output database path is used
  24. #define MSIDBOPEN_READONLY (LPCTSTR)0 // database open read-only, no persistent changes
  25. #define MSIDBOPEN_TRANSACT (LPCTSTR)1 // database read/write in transaction mode
  26. #define MSIDBOPEN_DIRECT (LPCTSTR)2 // database direct read/write without transaction
  27. #define MSIDBOPEN_CREATE (LPCTSTR)3 // create new database, transact mode read/write
  28. #define MSIDBOPEN_CREATEDIRECT (LPCTSTR)4 // create new database, direct mode read/write
  29. #define MSIDBOPEN_PATCHFILE 32/sizeof(*MSIDBOPEN_READONLY) // add flag to indicate patch file
  30. typedef enum tagMSIDBSTATE
  31. {
  32. MSIDBSTATE_ERROR =-1, // invalid database handle
  33. MSIDBSTATE_READ = 0, // database open read-only, no persistent changes
  34. MSIDBSTATE_WRITE = 1, // database readable and updatable
  35. } MSIDBSTATE;
  36. typedef enum tagMSIMODIFY
  37. {
  38. MSIMODIFY_SEEK =-1, // reposition to current record primary key
  39. MSIMODIFY_REFRESH = 0, // refetch current record data
  40. MSIMODIFY_INSERT = 1, // insert new record, fails if matching key exists
  41. MSIMODIFY_UPDATE = 2, // update existing non-key data of fetched record
  42. MSIMODIFY_ASSIGN = 3, // insert record, replacing any existing record
  43. MSIMODIFY_REPLACE = 4, // update record, delete old if primary key edit
  44. MSIMODIFY_MERGE = 5, // fails if record with duplicate key not identical
  45. MSIMODIFY_DELETE = 6, // remove row referenced by this record from table
  46. MSIMODIFY_INSERT_TEMPORARY = 7, // insert a temporary record
  47. MSIMODIFY_VALIDATE = 8, // validate a fetched record
  48. MSIMODIFY_VALIDATE_NEW = 9, // validate a new record
  49. MSIMODIFY_VALIDATE_FIELD = 10, // validate field(s) of an incomplete record
  50. MSIMODIFY_VALIDATE_DELETE = 11, // validate before deleting record
  51. } MSIMODIFY;
  52. typedef enum tagMSICOLINFO
  53. {
  54. MSICOLINFO_NAMES = 0, // return column names
  55. MSICOLINFO_TYPES = 1, // return column definitions, datatype code followed by width
  56. } MSICOLINFO;
  57. typedef enum tagMSICONDITION
  58. {
  59. MSICONDITION_FALSE = 0, // expression evaluates to False
  60. MSICONDITION_TRUE = 1, // expression evaluates to True
  61. MSICONDITION_NONE = 2, // no expression present
  62. MSICONDITION_ERROR = 3, // syntax error in expression
  63. } MSICONDITION;
  64. typedef enum tagMSICOSTTREE
  65. {
  66. MSICOSTTREE_SELFONLY = 0,
  67. MSICOSTTREE_CHILDREN = 1,
  68. MSICOSTTREE_PARENTS = 2,
  69. MSICOSTTREE_RESERVED = 3, // Reserved for future use
  70. } MSICOSTTREE;
  71. typedef enum tagMSIDBERROR
  72. {
  73. MSIDBERROR_INVALIDARG = -3, // invalid argument
  74. MSIDBERROR_MOREDATA = -2, // buffer too small
  75. MSIDBERROR_FUNCTIONERROR = -1, // function error
  76. MSIDBERROR_NOERROR = 0, // no error
  77. MSIDBERROR_DUPLICATEKEY = 1, // new record duplicates primary keys of existing record in table
  78. MSIDBERROR_REQUIRED = 2, // non-nullable column, no null values allowed
  79. MSIDBERROR_BADLINK = 3, // corresponding record in foreign table not found
  80. MSIDBERROR_OVERFLOW = 4, // data greater than maximum value allowed
  81. MSIDBERROR_UNDERFLOW = 5, // data less than minimum value allowed
  82. MSIDBERROR_NOTINSET = 6, // data not a member of the values permitted in the set
  83. MSIDBERROR_BADVERSION = 7, // invalid version string
  84. MSIDBERROR_BADCASE = 8, // invalid case, must be all upper-case or all lower-case
  85. MSIDBERROR_BADGUID = 9, // invalid GUID
  86. MSIDBERROR_BADWILDCARD = 10, // invalid wildcardfilename or use of wildcards
  87. MSIDBERROR_BADIDENTIFIER = 11, // bad identifier
  88. MSIDBERROR_BADLANGUAGE = 12, // bad language Id(s)
  89. MSIDBERROR_BADFILENAME = 13, // bad filename
  90. MSIDBERROR_BADPATH = 14, // bad path
  91. MSIDBERROR_BADCONDITION = 15, // bad conditional statement
  92. MSIDBERROR_BADFORMATTED = 16, // bad format string
  93. MSIDBERROR_BADTEMPLATE = 17, // bad template string
  94. MSIDBERROR_BADDEFAULTDIR = 18, // bad string in DefaultDir column of Directory table
  95. MSIDBERROR_BADREGPATH = 19, // bad registry path string
  96. MSIDBERROR_BADCUSTOMSOURCE = 20, // bad string in CustomSource column of CustomAction table
  97. MSIDBERROR_BADPROPERTY = 21, // bad property string
  98. MSIDBERROR_MISSINGDATA = 22, // _Validation table missing reference to column
  99. MSIDBERROR_BADCATEGORY = 23, // Category column of _Validation table for column is invalid
  100. MSIDBERROR_BADKEYTABLE = 24, // table in KeyTable column of _Validation table could not be found/loaded
  101. MSIDBERROR_BADMAXMINVALUES = 25, // value in MaxValue column of _Validation table is less than value in MinValue column
  102. MSIDBERROR_BADCABINET = 26, // bad cabinet name
  103. MSIDBERROR_BADSHORTCUT = 27, // bad shortcut target
  104. MSIDBERROR_STRINGOVERFLOW = 28, // string overflow (greater than length allowed in column def)
  105. MSIDBERROR_BADLOCALIZEATTRIB = 29 // invalid localization attribute (primary keys cannot be localized)
  106. } MSIDBERROR;
  107. typedef enum tagMSIRUNMODE
  108. {
  109. MSIRUNMODE_ADMIN = 0, // admin mode install, else product install
  110. MSIRUNMODE_ADVERTISE = 1, // installing advertisements, else installing or updating product
  111. MSIRUNMODE_MAINTENANCE = 2, // modifying an existing installation, else new installation
  112. MSIRUNMODE_ROLLBACKENABLED = 3, // rollback is enabled
  113. MSIRUNMODE_LOGENABLED = 4, // log file active, enabled prior to install session
  114. MSIRUNMODE_OPERATIONS = 5, // spooling execute operations, else in determination phase
  115. MSIRUNMODE_REBOOTATEND = 6, // reboot needed after successful installation (settable)
  116. MSIRUNMODE_REBOOTNOW = 7, // reboot needed to continue installation (settable)
  117. MSIRUNMODE_CABINET = 8, // installing files from cabinets and files using Media table
  118. MSIRUNMODE_SOURCESHORTNAMES= 9, // source LongFileNames suppressed via PID_MSISOURCE summary property
  119. MSIRUNMODE_TARGETSHORTNAMES= 10, // target LongFileNames suppressed via SHORTFILENAMES property
  120. MSIRUNMODE_RESERVED11 = 11, // future use
  121. MSIRUNMODE_WINDOWS9X = 12, // operating systems is Windows9?, else Windows NT
  122. MSIRUNMODE_ZAWENABLED = 13, // operating system supports demand installation
  123. MSIRUNMODE_RESERVED14 = 14, // future use
  124. MSIRUNMODE_RESERVED15 = 15, // future use
  125. MSIRUNMODE_SCHEDULED = 16, // custom action call from install script execution
  126. MSIRUNMODE_ROLLBACK = 17, // custom action call from rollback execution script
  127. MSIRUNMODE_COMMIT = 18, // custom action call from commit execution script
  128. } MSIRUNMODE;
  129. #define INSTALLMESSAGE_TYPEMASK = 0xFF000000L // mask for type code
  130. // Note: INSTALLMESSAGE_ERROR, INSTALLMESSAGE_WARNING, INSTALLMESSAGE_USER are to or'd
  131. // with a message box style to indicate the buttons to display and return:
  132. // MB_OK,MB_OKCANCEL,MB_ABORTRETRYIGNORE,MB_YESNOCANCEL,MB_YESNO,MB_RETRYCANCEL
  133. // the default button (MB_DEFBUTTON1 is normal default):
  134. // MB_DEFBUTTON1, MB_DEFBUTTON2, MB_DEFBUTTON3
  135. // and optionally an icon style:
  136. // MB_ICONERROR, MB_ICONQUESTION, MB_ICONWARNING, MB_ICONINFORMATION
  137. typedef enum tagMSITRANSFORM_ERROR
  138. {
  139. MSITRANSFORM_ERROR_ADDEXISTINGROW = 0x00000001,
  140. MSITRANSFORM_ERROR_DELMISSINGROW = 0x00000002,
  141. MSITRANSFORM_ERROR_ADDEXISTINGTABLE = 0x00000004,
  142. MSITRANSFORM_ERROR_DELMISSINGTABLE = 0x00000008,
  143. MSITRANSFORM_ERROR_UPDATEMISSINGROW = 0x00000010,
  144. MSITRANSFORM_ERROR_CHANGECODEPAGE = 0x00000020,
  145. MSITRANSFORM_ERROR_VIEWTRANSFORM = 0x00000100,
  146. } MSITRANSFORM_ERROR;
  147. typedef enum tagMSITRANSFORM_VALIDATE
  148. {
  149. MSITRANSFORM_VALIDATE_LANGUAGE = 0x00000001,
  150. MSITRANSFORM_VALIDATE_PRODUCT = 0x00000002,
  151. MSITRANSFORM_VALIDATE_PLATFORM = 0x00000004,
  152. MSITRANSFORM_VALIDATE_MAJORVERSION = 0x00000008,
  153. MSITRANSFORM_VALIDATE_MINORVERSION = 0x00000010,
  154. MSITRANSFORM_VALIDATE_UPDATEVERSION = 0x00000020,
  155. MSITRANSFORM_VALIDATE_NEWLESSBASEVERSION = 0x00000040,
  156. MSITRANSFORM_VALIDATE_NEWLESSEQUALBASEVERSION = 0x00000080,
  157. MSITRANSFORM_VALIDATE_NEWEQUALBASEVERSION = 0x00000100,
  158. MSITRANSFORM_VALIDATE_NEWGREATEREQUALBASEVERSION = 0x00000200,
  159. MSITRANSFORM_VALIDATE_NEWGREATERBASEVERSION = 0x00000400,
  160. MSITRANSFORM_VALIDATE_UPGRADECODE = 0x00000800,
  161. } MSITRANSFORM_VALIDATE;
  162. #ifdef __cplusplus
  163. extern "C" {
  164. #endif
  165. // --------------------------------------------------------------------------
  166. // Installer database access functions
  167. // --------------------------------------------------------------------------
  168. // Prepare a database query, creating a view object
  169. // Returns ERROR_SUCCESS if successful, and the view handle is returned,
  170. // else ERROR_INVALID_HANDLE, ERROR_INVALID_HANDLE_STATE, ERROR_BAD_QUERY_SYNTAX, ERROR_GEN_FAILURE
  171. // Execution of this function sets the error record, accessible via MsiGetLastErrorRecord
  172. UINT WINAPI MsiDatabaseOpenView%(MSIHANDLE hDatabase,
  173. LPCTSTR% szQuery, // SQL query to be prepared
  174. MSIHANDLE* phView); // returned view if TRUE
  175. // Returns the MSIDBERROR enum and name of the column corresponding to the error
  176. // Similar to a GetLastError function, but for the view. NOT the same as MsiGetLastErrorRecord
  177. // Returns errors of MsiViewModify.
  178. MSIDBERROR WINAPI MsiViewGetError%(MSIHANDLE hView,
  179. LPTSTR% szColumnNameBuffer, // buffer to hold column name
  180. DWORD* pcchBuf); // size of buffer
  181. // Exectute the view query, supplying parameters as required
  182. // Returns ERROR_SUCCESS, ERROR_INVALID_HANDLE, ERROR_INVALID_HANDLE_STATE, ERROR_GEN_FAILURE
  183. // Execution of this function sets the error record, accessible via MsiGetLastErrorRecord
  184. UINT WINAPI MsiViewExecute(MSIHANDLE hView,
  185. MSIHANDLE hRecord); // optional parameter record, or 0 if none
  186. // Fetch the next sequential record from the view
  187. // Result is ERROR_SUCCESS if a row is found, and its handle is returned
  188. // else ERROR_NO_MORE_ITEMS if no records remain, and a null handle is returned
  189. // else result is error: ERROR_INVALID_HANDLE_STATE, ERROR_INVALID_HANDLE, ERROR_GEN_FAILURE
  190. UINT WINAPI MsiViewFetch(MSIHANDLE hView,
  191. MSIHANDLE *phRecord); // returned data record if fetch succeeds
  192. // Modify a database record, parameters must match types in query columns
  193. // Returns ERROR_SUCCESS, ERROR_INVALID_HANDLE, ERROR_INVALID_HANDLE_STATE, ERROR_GEN_FAILURE, ERROR_ACCESS_DENIED
  194. // Execution of this function sets the error record, accessible via MsiGetLastErrorRecord
  195. UINT WINAPI MsiViewModify(MSIHANDLE hView,
  196. MSIMODIFY eModifyMode, // modify action to perform
  197. MSIHANDLE hRecord); // record obtained from fetch, or new record
  198. // Return the column names or specifications for the current view
  199. // Returns ERROR_SUCCESS, ERROR_INVALID_HANDLE, ERROR_INVALID_PARAMETER, or ERROR_INVALID_HANDLE_STATE
  200. UINT WINAPI MsiViewGetColumnInfo(MSIHANDLE hView,
  201. MSICOLINFO eColumnInfo, // retrieve columns names or definitions
  202. MSIHANDLE *phRecord); // returned data record containing all names or definitions
  203. // Release the result set for an executed view, to allow re-execution
  204. // Only needs to be called if not all records have been fetched
  205. // Returns ERROR_SUCCESS, ERROR_INVALID_HANDLE, ERROR_INVALID_HANDLE_STATE
  206. UINT WINAPI MsiViewClose(MSIHANDLE hView);
  207. // Return a record containing the names of all primary key columns for a given table
  208. // Returns an MSIHANDLE for a record containing the name of each column.
  209. // The field count of the record corresponds to the number of primary key columns.
  210. // Field [0] of the record contains the table name.
  211. // Returns ERROR_SUCCESS, ERROR_INVALID_HANDLE, ERROR_INVALID_TABLE
  212. UINT WINAPI MsiDatabaseGetPrimaryKeys%(MSIHANDLE hDatabase,
  213. LPCTSTR% szTableName, // the name of a specific table <case-sensitive>
  214. MSIHANDLE *phRecord); // returned record if ERROR_SUCCESS
  215. // Return an enum defining the state of the table (temporary, unknown, or persistent).
  216. // Returns MSICONDITION_ERROR, MSICONDITION_FALSE, MSICONDITION_TRUE, MSICONDITION_NONE
  217. MSICONDITION WINAPI MsiDatabaseIsTablePersistent%(MSIHANDLE hDatabase,
  218. LPCTSTR% szTableName); // the name of a specific table
  219. // --------------------------------------------------------------------------
  220. // Summary information stream management functions
  221. // --------------------------------------------------------------------------
  222. // Integer Property IDs: 1, 14, 15, 16, 19
  223. // DateTime Property IDs: 10, 11, 12, 13
  224. // Text Property IDs: 2, 3, 4, 5, 6, 7, 8, 9, 18
  225. // Unsupported Propery IDs: 0 (PID_DICTIONARY), 17 (PID_THUMBNAIL)
  226. // Obtain a handle for the _SummaryInformation stream for an MSI database
  227. // Execution of this function sets the error record, accessible via MsiGetLastErrorRecord
  228. UINT WINAPI MsiGetSummaryInformation%(MSIHANDLE hDatabase, // 0 if not open
  229. LPCTSTR% szDatabasePath, // path to database, 0 if database handle supplied
  230. UINT uiUpdateCount, // maximium number of updated values, 0 to open read-only
  231. MSIHANDLE *phSummaryInfo); // returned handle to summary information data
  232. // Obtain the number of existing properties in the SummaryInformation stream
  233. UINT WINAPI MsiSummaryInfoGetPropertyCount(MSIHANDLE hSummaryInfo,
  234. UINT *puiPropertyCount); // pointer to location to return total property count
  235. // Set a single summary information property
  236. // Returns ERROR_SUCCESS, ERROR_INVALID_HANDLE, ERROR_UNKNOWN_PROPERTY
  237. UINT WINAPI MsiSummaryInfoSetProperty%(MSIHANDLE hSummaryInfo,
  238. UINT uiProperty, // property ID, one of allowed values for summary information
  239. UINT uiDataType, // VT_I4, VT_LPSTR, VT_FILETIME, or VT_EMPTY
  240. INT iValue, // integer value, used only if integer property
  241. FILETIME *pftValue, // pointer to filetime value, used only if datetime property
  242. LPCTSTR% szValue); // text value, used only if string property
  243. // Get a single property from the summary information
  244. // Returns ERROR_SUCCESS, ERROR_INVALID_HANDLE, ERROR_UNKNOWN_PROPERTY
  245. UINT WINAPI MsiSummaryInfoGetProperty%(MSIHANDLE hSummaryInfo,
  246. UINT uiProperty, // property ID, one of allowed values for summary information
  247. UINT *puiDataType, // returned type: VT_I4, VT_LPSTR, VT_FILETIME, VT_EMPTY
  248. INT *piValue, // returned integer property data
  249. FILETIME *pftValue, // returned datetime property data
  250. LPTSTR% szValueBuf, // buffer to return string property data
  251. DWORD *pcchValueBuf); // in/out buffer character count
  252. // Write back changed information to summary information stream
  253. UINT WINAPI MsiSummaryInfoPersist(MSIHANDLE hSummaryInfo);
  254. // --------------------------------------------------------------------------
  255. // Installer database management functions - not used by custom actions
  256. // --------------------------------------------------------------------------
  257. // Open an installer database, specifying the persistance mode, which is a pointer.
  258. // Predefined persist values are reserved pointer values, requiring pointer arithmetic.
  259. // Execution of this function sets the error record, accessible via MsiGetLastErrorRecord
  260. UINT WINAPI MsiOpenDatabase%(
  261. LPCTSTR% szDatabasePath, // path to database, 0 to create temporary database
  262. LPCTSTR% szPersist, // output database path or one of predefined values
  263. MSIHANDLE* phDatabase); // location to return database handle
  264. // Import an MSI text archive table into an open database
  265. // Execution of this function sets the error record, accessible via MsiGetLastErrorRecord
  266. UINT WINAPI MsiDatabaseImport%(MSIHANDLE hDatabase,
  267. LPCTSTR% szFolderPath, // folder containing archive files
  268. LPCTSTR% szFileName); // table archive file to be imported
  269. // Export an MSI table from an open database to a text archive file
  270. // Execution of this function sets the error record, accessible via MsiGetLastErrorRecord
  271. UINT WINAPI MsiDatabaseExport%(MSIHANDLE hDatabase,
  272. LPCTSTR% szTableName, // name of table in database <case-sensitive>
  273. LPCTSTR% szFolderPath, // folder containing archive files
  274. LPCTSTR% szFileName); // name of exported table archive file
  275. // Merge two database together, allowing duplicate rows
  276. // Execution of this function sets the error record, accessible via MsiGetLastErrorRecord
  277. UINT WINAPI MsiDatabaseMerge%(MSIHANDLE hDatabase,
  278. MSIHANDLE hDatabaseMerge, // database to be merged into hDatabase
  279. LPCTSTR% szTableName); // name of non-persistent table to receive errors
  280. // Generate a transform file of differences between two databases
  281. // Execution of this function sets the error record, accessible via MsiGetLastErrorRecord
  282. UINT WINAPI MsiDatabaseGenerateTransform%(MSIHANDLE hDatabase,
  283. MSIHANDLE hDatabaseReference, // base database to reference changes
  284. LPCTSTR% szTransformFile, // name of generated transform file
  285. int iReserved1, // reserved argument, not used
  286. int iReserved2); // reserved argument, not used
  287. // Apply a transform file containing database difference
  288. // Execution of this function sets the error record, accessible via MsiGetLastErrorRecord
  289. UINT WINAPI MsiDatabaseApplyTransform%(MSIHANDLE hDatabase,
  290. LPCTSTR% szTransformFile, // name of transform file
  291. int iErrorConditions); // errors to suppress, bits from MSITRANSFORM_ERROR
  292. // Create summary information of existing transform to include validation and error conditions
  293. // Execution of this function sets the error record, accessible via MsiGetLastErrorRecord
  294. UINT WINAPI MsiCreateTransformSummaryInfo%(MSIHANDLE hDatabase,
  295. MSIHANDLE hDatabaseReference, // base database to reference changes
  296. LPCTSTR% szTransformFile, // name of generated transform file
  297. int iErrorConditions, // errors to suppress when applied, from MSITRANSFORM_ERROR
  298. int iValidation); // properties validated when applied, MSITRANSFORM_VALIDATE
  299. // Write out all persistent table data, ignored if database opened read-only
  300. // Execution of this function sets the error record, accessible via MsiGetLastErrorRecord
  301. UINT WINAPI MsiDatabaseCommit(MSIHANDLE hDatabase);
  302. // Return the update state of a database
  303. MSIDBSTATE WINAPI MsiGetDatabaseState(MSIHANDLE hDatabase);
  304. // --------------------------------------------------------------------------
  305. // Record object functions
  306. // --------------------------------------------------------------------------
  307. // Create a new record object with the requested number of fields
  308. // Field 0, not included in count, is used for format strings and op codes
  309. // All fields are initialized to null
  310. // Returns a handle to the created record, or 0 if memory could not be allocated
  311. MSIHANDLE WINAPI MsiCreateRecord(
  312. UINT cParams); // the number of data fields
  313. // Report whether a record field is NULL
  314. // Returns TRUE if the field is null or does not exist
  315. // Returns FALSE if the field contains data, or the handle is invalid
  316. BOOL WINAPI MsiRecordIsNull(MSIHANDLE hRecord,
  317. UINT iField);
  318. // Return the length of a record field
  319. // Returns 0 if field is NULL or non-existent
  320. // Returns sizeof(int) if integer data
  321. // Returns character count if string data (not counting null terminator)
  322. // Returns bytes count if stream data
  323. UINT WINAPI MsiRecordDataSize(MSIHANDLE hRecord,
  324. UINT iField);
  325. // Set a record field to an integer value
  326. // Returns ERROR_SUCCESS, ERROR_INVALID_HANDLE, ERROR_INVALID_FIELD
  327. UINT WINAPI MsiRecordSetInteger(MSIHANDLE hRecord,
  328. UINT iField,
  329. int iValue);
  330. // Copy a string into the designated field
  331. // A null string pointer and an empty string both set the field to null
  332. // Returns ERROR_SUCCESS, ERROR_INVALID_HANDLE, ERROR_INVALID_FIELD
  333. UINT WINAPI MsiRecordSetString%(MSIHANDLE hRecord,
  334. UINT iField,
  335. LPCTSTR% szValue);
  336. // Return the integer value from a record field
  337. // Returns the value MSI_NULL_INTEGER if the field is null
  338. // or if the field is a string that cannot be converted to an integer
  339. int WINAPI MsiRecordGetInteger(MSIHANDLE hRecord,
  340. UINT iField);
  341. // Return the string value of a record field
  342. // Integer fields will be converted to a string
  343. // Null and non-existent fields will report a value of 0
  344. // Fields containing stream data will return ERROR_INVALID_DATATYPE
  345. // Returns ERROR_SUCCESS, ERROR_MORE_DATA,
  346. // ERROR_INVALID_HANDLE, ERROR_INVALID_FIELD, ERROR_BAD_ARGUMENTS
  347. UINT WINAPI MsiRecordGetString%(MSIHANDLE hRecord,
  348. UINT iField,
  349. LPTSTR% szValueBuf, // buffer for returned value
  350. DWORD *pcchValueBuf); // in/out buffer character count
  351. // Returns the number of fields allocated in the record
  352. // Does not count field 0, used for formatting and op codes
  353. UINT WINAPI MsiRecordGetFieldCount(MSIHANDLE hRecord);
  354. // Set a record stream field from a file
  355. // The contents of the specified file will be read into a stream object
  356. // The stream will be persisted if the record is inserted into the database
  357. // Execution of this function sets the error record, accessible via MsiGetLastErrorRecord
  358. UINT WINAPI MsiRecordSetStream%(MSIHANDLE hRecord,
  359. UINT iField,
  360. LPCTSTR% szFilePath); // path to file containing stream data
  361. // Read bytes from a record stream field into a buffer
  362. // Must set the in/out argument to the requested byte count to read
  363. // The number of bytes transferred is returned through the argument
  364. // If no more bytes are available, ERROR_SUCCESS is still returned
  365. UINT WINAPI MsiRecordReadStream(MSIHANDLE hRecord,
  366. UINT iField,
  367. char *szDataBuf, // buffer to receive bytes from stream
  368. DWORD *pcbDataBuf); // in/out buffer byte count
  369. // Clears all data fields in a record to NULL
  370. UINT WINAPI MsiRecordClearData(MSIHANDLE hRecord);
  371. // --------------------------------------------------------------------------
  372. // Functions to access a running installation, called from custom actions
  373. // The install handle is the single argument passed to custom actions
  374. // --------------------------------------------------------------------------
  375. // Return a handle to the database currently in use by this installer instance
  376. MSIHANDLE WINAPI MsiGetActiveDatabase(MSIHANDLE hInstall); // returns handle to database, 0 if none active
  377. // Set the value for an installer property
  378. // If the property is not defined, it will be created
  379. // If the value is null or an empty string, the property will be removed
  380. // Returns ERROR_SUCCESS, ERROR_INVALID_HANDLE, ERROR_BAD_ARGUMENTS
  381. UINT WINAPI MsiSetProperty%(MSIHANDLE hInstall,
  382. LPCTSTR% szName, // property identifier, case-sensitive
  383. LPCTSTR% szValue); // property value, null to undefine property
  384. // Get the value for an installer property
  385. // If the property is not defined, it is equivalent to a 0-length value, not error
  386. // Returns ERROR_SUCCESS, ERROR_MORE_DATA, ERROR_INVALID_HANDLE, ERROR_BAD_ARGUMENTS
  387. UINT WINAPI MsiGetProperty%(MSIHANDLE hInstall,
  388. LPCTSTR% szName, // property identifier, case-sensitive
  389. LPTSTR% szValueBuf, // buffer for returned property value
  390. DWORD *pcchValueBuf); // in/out buffer character count
  391. // Return the numeric language for the currently running install
  392. // Returns 0 if an install not running
  393. LANGID WINAPI MsiGetLanguage(MSIHANDLE hInstall);
  394. // Return one of the boolean internal installer states
  395. // Returns FALSE if the handle is not active or if the mode is not implemented
  396. BOOL WINAPI MsiGetMode(MSIHANDLE hInstall,
  397. MSIRUNMODE eRunMode); // particular mode for which the state is returned
  398. // Set an internal install session boolean mode - Note: most modes are read-only
  399. // Returns ERROR_SUCCESS if the mode can be set to the desired state
  400. // Returns ERROR_ACCESS_DENIED if the mode is not settable
  401. // Returns ERROR_INVALID_HANDLE if the handle is not an active install session
  402. UINT WINAPI MsiSetMode(MSIHANDLE hInstall,
  403. MSIRUNMODE eRunMode, // particular mode for which state is to be set
  404. BOOL fState); // new state for bit flag
  405. // Format record data using a format string containing field markers and/or properties
  406. // Record field 0 must contain the format string
  407. // Other fields must contain data that may be referenced by the format string.
  408. UINT WINAPI MsiFormatRecord%(MSIHANDLE hInstall, // non-zero for property expansion
  409. MSIHANDLE hRecord, // handle to record, field 0 contains format string
  410. LPTSTR% szResultBuf, // buffer to return formatted string
  411. DWORD *pcchResultBuf); // in/out buffer character count
  412. // Execute another action, either built-in, custom, or UI wizard
  413. // Returns ERROR_FUNCTION_NOT_CALLED if action not found
  414. // Returns ERROR_SUCCESS if action completed succesfully
  415. // Returns ERROR_INSTALL_USEREXIT if user cancelled during action
  416. // Returns ERROR_INSTALL_FAILURE if action failed
  417. // Returns ERROR_INSTALL_SUSPEND if user suspended installation
  418. // Returns ERROR_MORE_DATA if action wishes to skip remaining actions
  419. // Returns ERROR_INVALID_HANDLE_STATE if install session not active
  420. // Returns ERROR_INVALID_DATA if failure calling custom action
  421. // Returns ERROR_INVALID_HANDLE or ERROR_INVALID_PARAMETER if arguments invalid
  422. UINT WINAPI MsiDoAction%(MSIHANDLE hInstall,
  423. LPCTSTR% szAction); // name of action to call, case-sensitive
  424. // Execute another action sequence, as descibed in the specified table
  425. // Returns the same error codes as MsiDoAction
  426. UINT WINAPI MsiSequence%(MSIHANDLE hInstall,
  427. LPCTSTR% szTable, // name of table containing action sequence
  428. INT iSequenceMode); // for future use, must be 0 in MSI 1.0
  429. // Send an error record to the installer for processing.
  430. // If field 0 (template) is not set, field 1 must be set to the error code,
  431. // corresponding the the error message in the Error database table,
  432. // and the message will be formatted using the template from the Error table
  433. // before passing it to the UI handler for display.
  434. // Returns Win32 button codes: IDOK IDCANCEL IDABORT IDRETRY IDIGNORE IDYES IDNO
  435. // or 0 if no action taken, or -1 if invalid argument or handle
  436. int WINAPI MsiProcessMessage(MSIHANDLE hInstall,
  437. INSTALLMESSAGE eMessageType, // type of message
  438. MSIHANDLE hRecord); // record containing message format and data
  439. // Evaluate a conditional expression containing property names and values
  440. MSICONDITION WINAPI MsiEvaluateCondition%(MSIHANDLE hInstall,
  441. LPCTSTR% szCondition);
  442. // Get the installed state and requested action state of a feature
  443. // Execution of this function sets the error record, accessible via MsiGetLastErrorRecord
  444. UINT WINAPI MsiGetFeatureState%(MSIHANDLE hInstall,
  445. LPCTSTR% szFeature, // feature name within product
  446. INSTALLSTATE *piInstalled, // returned current install state
  447. INSTALLSTATE *piAction); // action taken during install session
  448. // Request a feature to be set to a specified state
  449. // Execution of this function sets the error record, accessible via MsiGetLastErrorRecord
  450. UINT WINAPI MsiSetFeatureState%(MSIHANDLE hInstall,
  451. LPCTSTR% szFeature, // feature name within product
  452. INSTALLSTATE iState); // requested state for feature
  453. #if (_WIN32_MSI >= 110)
  454. // Set the attribute bits of a specified feature at runtime.
  455. // Execution of this function sets the error record, accessible via MsiGetLastErrorRecord
  456. UINT WINAPI MsiSetFeatureAttributes%(MSIHANDLE hInstall,
  457. LPCTSTR% szFeature, // feature name within product
  458. DWORD dwAttributes); // attributes bits to set for this feature
  459. #endif //(_WIN32_MSI >= 110)
  460. // Get the installed state and requested action state of a component
  461. // Execution of this function sets the error record, accessible via MsiGetLastErrorRecord
  462. UINT WINAPI MsiGetComponentState%(MSIHANDLE hInstall,
  463. LPCTSTR% szComponent, // component name within product
  464. INSTALLSTATE *piInstalled, // returned current install state
  465. INSTALLSTATE *piAction); // action taken during install session
  466. // Request a component to be set to a specified state
  467. // Execution of this function sets the error record, accessible via MsiGetLastErrorRecord
  468. UINT WINAPI MsiSetComponentState%(MSIHANDLE hInstall,
  469. LPCTSTR% szComponent, // component name within product
  470. INSTALLSTATE iState); // requested state for component
  471. // Return the disk cost for a feature and related features
  472. // Can specify either current feature state or proposed state
  473. // Can specify extent of related features to cost
  474. // Note that adding costs for several features may produce an
  475. // excessively large cost due to shared components and parents.
  476. // Execution of this function sets the error record, accessible via MsiGetLastErrorRecord
  477. UINT WINAPI MsiGetFeatureCost%(MSIHANDLE hInstall,
  478. LPCTSTR% szFeature, // name of feature
  479. MSICOSTTREE iCostTree, // portion of tree to cost
  480. INSTALLSTATE iState, // requested state, or INSTALLSTATE_UNKNOWN
  481. INT *piCost); // returned cost, in units of 512 bytes
  482. #if (_WIN32_MSI >= 150)
  483. // Enumerates the costs and temporary costs per drives for
  484. // szComponent. If szComponent is set to NULL, it enumerates
  485. // the above costs for the engine, per drives.
  486. //
  487. // The enumeration is 0-based, i.e. it returns the data for
  488. // the first drive when called w/ dwIndex set to 0.
  489. //
  490. // Can specify either current feature state or proposed state.
  491. //
  492. // Execution of this function sets the error record, accessible
  493. // via MsiGetLastErrorRecord.
  494. UINT WINAPI MsiEnumComponentCosts%(MSIHANDLE hInstall,
  495. LPCTSTR% szComponent, // name of component
  496. DWORD dwIndex, // 0-based index into the list of drives
  497. INSTALLSTATE iState, // requested state, or INSTALLSTATE_UNKNOWN
  498. LPTSTR% szDriveBuf, // buffer for returned value
  499. DWORD *pcchDriveBuf, // in/out buffer character count
  500. INT *piCost, // returned cost, in units of 512 bytes
  501. INT *piTempCost); // returned temporary cost, in units of 512 bytes
  502. #endif // (_WIN32_MSI >= 150)
  503. // Set the install level for a full product installation (not a feature request)
  504. // Setting the value to 0 initialized components and features to the default level
  505. // Execution of this function sets the error record, accessible via MsiGetLastErrorRecord
  506. UINT WINAPI MsiSetInstallLevel(MSIHANDLE hInstall,
  507. int iInstallLevel);
  508. // Get the valid install states for a feature, represented by bit flags
  509. // For each valid install state, a bit is set of value: (1 << INSTALLSTATE)
  510. // Execution of this function sets the error record, accessible via MsiGetLastErrorRecord
  511. UINT WINAPI MsiGetFeatureValidStates%(MSIHANDLE hInstall,
  512. LPCTSTR% szFeature,
  513. DWORD *dwInstallStates);
  514. // Return the full source path for a folder in the Directory table
  515. // Execution of this function sets the error record, accessible via MsiGetLastErrorRecord
  516. UINT WINAPI MsiGetSourcePath%(MSIHANDLE hInstall,
  517. LPCTSTR% szFolder, // folder identifier, primary key into Directory table
  518. LPTSTR% szPathBuf, // buffer to return full path
  519. DWORD *pcchPathBuf); // in/out buffer character count
  520. // Return the full target path for a folder in the Directory table
  521. // Execution of this function sets the error record, accessible via MsiGetLastErrorRecord
  522. UINT WINAPI MsiGetTargetPath%(MSIHANDLE hInstall,
  523. LPCTSTR% szFolder, // folder identifier, primary key into Directory table
  524. LPTSTR% szPathBuf, // buffer to return full path
  525. DWORD *pcchPathBuf); // in/out buffer character count
  526. // Set the full target path for a folder in the Directory table
  527. // Execution of this function sets the error record, accessible via MsiGetLastErrorRecord
  528. UINT WINAPI MsiSetTargetPath%(MSIHANDLE hInstall,
  529. LPCTSTR% szFolder, // folder identifier, primary key into Directory table
  530. LPCTSTR% szFolderPath); // full path for folder, ending in directory separator
  531. // Check to see if sufficent disk space is present for the current installation
  532. // Returns ERROR_SUCCESS, ERROR_DISK_FULL, ERROR_INVALID_HANDLE_STATE, or ERROR_INVALID_HANDLE
  533. UINT WINAPI MsiVerifyDiskSpace(MSIHANDLE hInstall);
  534. // --------------------------------------------------------------------------
  535. // Functions for rendering UI dialogs from the database representations.
  536. // Purpose is for product development, not for use during installation.
  537. // --------------------------------------------------------------------------
  538. // Enable UI in preview mode to facilitate authoring of UI dialogs.
  539. // The preview mode will end when the handle is closed.
  540. UINT WINAPI MsiEnableUIPreview(MSIHANDLE hDatabase,
  541. MSIHANDLE* phPreview); // returned handle for UI preview capability
  542. // Display any UI dialog as modeless and inactive.
  543. // Supplying a null name will remove any current dialog.
  544. UINT WINAPI MsiPreviewDialog%(MSIHANDLE hPreview,
  545. LPCTSTR% szDialogName); // dialog to display, Dialog table key
  546. // Display a billboard within a host control in the displayed dialog.
  547. // Supplying a null billboard name will remove any billboard displayed.
  548. UINT WINAPI MsiPreviewBillboard%(MSIHANDLE hPreview,
  549. LPCTSTR% szControlName, // name of control that accepts billboards
  550. LPCTSTR% szBillboard); // name of billboard to display
  551. // --------------------------------------------------------------------------
  552. // Error handling not associated with any particular object
  553. // --------------------------------------------------------------------------
  554. // Return a record handle to the last function that generated an error record
  555. // Only specified functions will set the error record, or clear it if success
  556. // Field 1 of the record will contain the internal MSI error code
  557. // Other fields will contain data specific to the particular error
  558. // The error record is released internally after this function is executed
  559. MSIHANDLE WINAPI MsiGetLastErrorRecord(); // returns 0 if no cached record
  560. #ifdef __cplusplus
  561. }
  562. #endif
  563. #endif // _MSIQUERY_H_