home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 2000 May / PCP163A.iso / Runimage / Cbuilder4 / Include / MSI.H < prev    next >
Encoding:
C/C++ Source or Header  |  1999-01-26  |  35.9 KB  |  823 lines

  1. /*****************************************************************************\
  2. *                                                                             *
  3. * msi.h - - Interface for external access to Installer Service                *
  4. *                                                                             *
  5. * Version 0.20                                                                *
  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. *                                                                             *
  10. * Copyright (c) 1997, Microsoft Corp.      All rights reserved.               *
  11. *                                                                             *
  12. \*****************************************************************************/
  13.  
  14. #ifndef _MSI_H_
  15. #pragma option push -b -a8 -pc -A- /*P_O_Push_S*/
  16. #define _MSI_H_
  17.  
  18. // --------------------------------------------------------------------------
  19. // Installer generic handle definitions
  20. // --------------------------------------------------------------------------
  21.  
  22. typedef unsigned long MSIHANDLE;     // abstract generic handle, 0 == no handle
  23.  
  24. #ifdef __cplusplus
  25. extern "C" {
  26. #endif
  27.  
  28. // Close a open handle of any type
  29. // All handles obtained from API calls must be closed when no longer needed
  30. // Normally succeeds, returning TRUE. 
  31.  
  32. UINT WINAPI MsiCloseHandle(MSIHANDLE hAny);
  33.  
  34. // Close all handles open in the process, a diagnostic call
  35. // This should NOT be used as a cleanup mechanism -- use PMSIHANDLE class
  36. // Can be called at termination to assure that all handles have been closed
  37. // Returns 0 if all handles have been close, else number of open handles
  38.  
  39. UINT WINAPI MsiCloseAllHandles();
  40.  
  41. #ifdef __cplusplus
  42. }
  43. #endif
  44.  
  45. #ifdef __cplusplus
  46.  
  47. // C++ wrapper object to automatically free handle when going out of scope
  48.  
  49. class PMSIHANDLE
  50. {
  51.     MSIHANDLE m_h;
  52.  public:
  53.     PMSIHANDLE():m_h(0){}
  54.     PMSIHANDLE(MSIHANDLE h):m_h(h){}
  55.   ~PMSIHANDLE(){if (m_h!=0) MsiCloseHandle(m_h);}
  56.     void operator =(MSIHANDLE h) {if (m_h) MsiCloseHandle(m_h); m_h=h;}
  57.     operator MSIHANDLE() {return m_h;}
  58.     MSIHANDLE* operator &() {if (m_h) MsiCloseHandle(m_h); m_h = 0; return &m_h;}
  59. };
  60. #endif  //__cplusplus
  61.  
  62. // Install message type for callback is a combination of the following:
  63. //  A message box style:      MB_*, where MB_OK is the default
  64. //  A message box icon type:  MB_ICON*, where no icon is the default
  65. //  A default button:         MB_DEFBUTTON?, where MB_DEFBUTTON1 is the default
  66. //  One of the following install message types, no default
  67. typedef enum tagINSTALLMESSAGE
  68. {
  69.     INSTALLMESSAGE_OUTOFMEMORY = 0x00000000L, // out of memory message
  70.     INSTALLMESSAGE_ERROR       = 0x01000000L, // formatted error message
  71.     INSTALLMESSAGE_WARNING     = 0x02000000L, // formatted warning message
  72.     INSTALLMESSAGE_USER        = 0x03000000L, // user request message
  73.     INSTALLMESSAGE_INFO        = 0x04000000L, // informative message for log
  74.     INSTALLMESSAGE_DIAGNOSTIC  = 0x05000000L, // debug notification, display if no log
  75.     INSTALLMESSAGE_COMMONDATA  = 0x06000000L, // product info for dialog: language Id, dialog caption
  76.     INSTALLMESSAGE_RESERVED    = 0x07000000L, // reserved for future use
  77.     INSTALLMESSAGE_ACTIONSTART = 0x08000000L, // start of action: action name & description
  78.     INSTALLMESSAGE_ACTIONDATA  = 0x09000000L, // formatted data associated with individual action item
  79.     INSTALLMESSAGE_PROGRESS    = 0x0A000000L, // progress gauge info: units so far, total
  80.     INSTALLMESSAGE_ACTIONDONE  = 0x0B000000L, // end of action sequence, exit modeless dialog
  81. } INSTALLMESSAGE;
  82.  
  83. // external error handler supplied to installation API functions
  84.  
  85. typedef int (*INSTALLUI_HANDLERA)(LPVOID pvContext, UINT iMessageType, LPCSTR szMessage);
  86. typedef int (*INSTALLUI_HANDLERW)(LPVOID pvContext, UINT iMessageType, LPCWSTR szMessage);
  87. #ifdef UNICODE
  88. #define INSTALLUI_HANDLER  INSTALLUI_HANDLERW
  89. #else
  90. #define INSTALLUI_HANDLER  INSTALLUI_HANDLERA
  91. #endif // !UNICODE
  92.  
  93. typedef enum tagINSTALLUILEVEL
  94. {
  95.     INSTALLUILEVEL_NOCHANGE = 0,   // UI level is unchanged
  96.     INSTALLUILEVEL_DEFAULT  = 1,   // default UI is used
  97.     INSTALLUILEVEL_NONE     = 2,   // completely silent installation
  98.     INSTALLUILEVEL_BASIC    = 3,   // simple progress and error handling
  99.     INSTALLUILEVEL_REDUCED  = 4,   // authored UI, wizard dialogs suppressed
  100.     INSTALLUILEVEL_FULL     = 5,   // authored UI with wizards, progress, errors
  101.     
  102. } INSTALLUILEVEL;
  103.  
  104. typedef enum tagINSTALLSTATE
  105. {
  106.     INSTALLSTATE_BADCONFIG    = -6,  // configuration data corrupt
  107.     INSTALLSTATE_INCOMPLETE   = -5,  // installation suspended or in progress
  108.     INSTALLSTATE_SOURCEABSENT = -4,  // run from source, source is unavailable
  109.     INSTALLSTATE_MOREDATA     = -3,  // return buffer overflow
  110.     INSTALLSTATE_INVALIDARG   = -2,  // invalid function argument
  111.     INSTALLSTATE_UNKNOWN      = -1,  // unrecognized product or feature
  112.     INSTALLSTATE_BROKEN       =  0,  // broken
  113.     INSTALLSTATE_ADVERTISED   =  1,  // advertised
  114.     INSTALLSTATE_ABSENT       =  2,  // uninstalled
  115.     INSTALLSTATE_LOCAL        =  3,  // installed on local drive
  116.     INSTALLSTATE_SOURCE       =  4,  // run from source, CD or net
  117.     INSTALLSTATE_DEFAULT      =  5,  // use default, local or source
  118. } INSTALLSTATE;
  119.  
  120. typedef enum tagUSERINFOSTATE
  121. {
  122.     USERINFOSTATE_MOREDATA   = -3,  // return buffer overflow
  123.     USERINFOSTATE_INVALIDARG = -2,  // invalid function argument
  124.     USERINFOSTATE_UNKNOWN    = -1,  // unrecognized product
  125.     USERINFOSTATE_ABSENT     =  0,  // user info and PID not initialized
  126.     USERINFOSTATE_PRESENT    =  1,  // user info and PID initialized
  127. } USERINFOSTATE;
  128.  
  129. typedef enum tagINSTALLLEVEL
  130. {
  131.     INSTALLLEVEL_DEFAULT = 0,      // install authored default
  132.     INSTALLLEVEL_MINIMUM = 1,      // install only required features
  133.     INSTALLLEVEL_MAXIMUM = 0xFFFF, // install all features
  134. } INSTALLLEVEL;                   // intermediate levels dependent on authoring
  135.  
  136. typedef enum tagREINSTALLMODE  // bit flags
  137. {
  138.     REINSTALLMODE_REPAIR           = 0x00000001,  // repair any defects encountered
  139.     REINSTALLMODE_FILEMISSING      = 0x00000002,  // Reinstall only if file is missing
  140.     REINSTALLMODE_FILEOLDERVERSION = 0x00000004,  // Reinstall if file is missing, or older version
  141.     REINSTALLMODE_FILEEQUALVERSION = 0x00000008,  // Reinstall if file is missing, or equal or older version
  142.     REINSTALLMODE_FILEEXACT        = 0x00000010,  // Reinstall if file is missing, or not exact version
  143.     REINSTALLMODE_FILEVERIFY       = 0x00000020,  // checksum executables, reinstall if missing or corrupt
  144.     REINSTALLMODE_FILEREPLACE      = 0x00000040,  // Reinstall all files, regardless of version
  145.     REINSTALLMODE_MACHINEDATA      = 0x00000080,  // insure required machine reg entries
  146.     REINSTALLMODE_USERDATA         = 0x00000100,  // insure required user reg entries
  147.     REINSTALLMODE_SHORTCUT         = 0x00000200,  // validate shortcuts and progman items
  148. } REINSTALLMODE;
  149.  
  150. typedef enum tagINSTALLOGMODE  // bit flags
  151. {
  152.     INSTALLLOGMODE_OUTOFMEMORY  = (1 << (INSTALLMESSAGE_OUTOFMEMORY >> 24)),
  153.     INSTALLLOGMODE_ERROR        = (1 << (INSTALLMESSAGE_ERROR       >> 24)),
  154.     INSTALLLOGMODE_WARNING      = (1 << (INSTALLMESSAGE_WARNING     >> 24)),
  155.     INSTALLLOGMODE_USER         = (1 << (INSTALLMESSAGE_USER        >> 24)),
  156.     INSTALLLOGMODE_INFO         = (1 << (INSTALLMESSAGE_INFO        >> 24)),
  157.     INSTALLLOGMODE_DIAGNOSTIC   = (1 << (INSTALLMESSAGE_DIAGNOSTIC  >> 24)),
  158.     INSTALLLOGMODE_COMMONDATA   = (1 << (INSTALLMESSAGE_COMMONDATA  >> 24)),
  159.     INSTALLLOGMODE_RESERVED     = (1 << (INSTALLMESSAGE_RESERVED    >> 24)),
  160.     INSTALLLOGMODE_ACTIONSTART  = (1 << (INSTALLMESSAGE_ACTIONSTART >> 24)),
  161.     INSTALLLOGMODE_ACTIONDATA   = (1 << (INSTALLMESSAGE_ACTIONDATA  >> 24)),
  162.     INSTALLLOGMODE_PROPERTYDUMP = (1 << (INSTALLMESSAGE_PROGRESS    >> 24)),
  163. } INSTALLLOGMODE;
  164.  
  165. typedef enum tagINSTALLFEATUREATTRIBUTE // bit flags
  166. {
  167.     INSTALLFEATUREATTRIBUTE_FAVORLOCAL   = 0x00000001,
  168.     INSTALLFEATUREATTRIBUTE_FAVORSOURCE  = 0x00000002,
  169.     INSTALLFEATUREATTRIBUTE_FOLLOWPARENT = 0x00000004,
  170. } INSTALLFEATUREATTRIBUTE;
  171.  
  172.  
  173. typedef enum tagINSTALLSOURCEACTION
  174. {
  175.     INSTALLSOURCEACTION_ADD          =  1,  // add source to list
  176.     INSTALLSOURCEACTION_REMOVE       =  2,  // remove source from list
  177.     INSTALLSOURCEACTION_REMOVEALL    =  3,  // flush entire sourcelist key
  178.     INSTALLSOURCEACTION_REMOVEALLNET =  4,  // flush all network sources
  179.     INSTALLSOURCEACTION_REMOVEALLURL =  5,  // flush all URL sources
  180.     INSTALLSOURCEACTION_ENABLECD     =  6,  // enable searching on CD sources
  181.     INSTALLSOURCEACTION_DISABLECD    =  7,  // disable searching on CD sources
  182. } INSTALLSOURCEACTION;
  183.  
  184.  
  185. #define MAX_FEATURE_CHARS  38   // maximum chars in feature name (same as string GUID)
  186.  
  187.  
  188. // Product info attributes: advertised information
  189.  
  190. #define INSTALLPROPERTY_TRANSFORMS            __TEXT("Transforms")
  191. #define INSTALLPROPERTY_LANGUAGE              __TEXT("Language")
  192. #define INSTALLPROPERTY_PRODUCTNAME           __TEXT("ProductName")
  193.  
  194. // Product info attributes: installed information
  195.  
  196. #define INSTALLPROPERTY_INSTALLEDPRODUCTNAME  __TEXT("InstalledProductName")
  197. #define INSTALLPROPERTY_VERSIONSTRING         __TEXT("VersionString")
  198. #define INSTALLPROPERTY_HELPLINK              __TEXT("HelpLink")
  199. #define INSTALLPROPERTY_HELPTELEPHONE         __TEXT("HelpTelephone")
  200. #define INSTALLPROPERTY_INSTALLLOCATION       __TEXT("InstallLocation")
  201. #define INSTALLPROPERTY_INSTALLSOURCE         __TEXT("InstallSource")
  202. #define INSTALLPROPERTY_INSTALLDATE           __TEXT("InstallDate")
  203. #define INSTALLPROPERTY_PUBLISHER             __TEXT("Publisher")
  204. #define INSTALLPROPERTY_LOCALPACKAGE          __TEXT("LocalPackage")
  205. #define INSTALLPROPERTY_URLINFOABOUT          __TEXT("URLInfoAbout")
  206. #define INSTALLPROPERTY_URLUPDATEINFO         __TEXT("URLUpdateInfo")
  207. #define INSTALLPROPERTY_VERSIONMINOR          __TEXT("VersionMinor")
  208. #define INSTALLPROPERTY_VERSIONMAJOR          __TEXT("VersionMajor")
  209.  
  210.  
  211.  
  212. #ifdef __cplusplus
  213. extern "C" {
  214. #endif
  215.  
  216. // --------------------------------------------------------------------------
  217. // Functions to set the UI handling and logging. The UI will be used for error,
  218. // progress, and log messages for all subsequent calls to Installer Service
  219. // API functions that require UI.
  220. // --------------------------------------------------------------------------
  221.  
  222. // Enable internal UI
  223.  
  224. INSTALLUILEVEL WINAPI MsiSetInternalUI(
  225.     INSTALLUILEVEL  dwUILevel,     // UI level
  226.     HWND  *phWnd);                   // handle of owner window
  227.  
  228. // Enable external UI
  229.  
  230. INSTALLUI_HANDLERA WINAPI MsiSetExternalUIA(
  231.     INSTALLUI_HANDLERA puiHandler,   // for progress and error handling 
  232.     DWORD              dwMessageFilter, // bit flags designating messages to handle
  233.     LPVOID             pvContext);   // application context
  234. INSTALLUI_HANDLERW WINAPI MsiSetExternalUIW(
  235.     INSTALLUI_HANDLERW puiHandler,   // for progress and error handling 
  236.     DWORD              dwMessageFilter, // bit flags designating messages to handle
  237.     LPVOID             pvContext);   // application context
  238. #ifdef UNICODE
  239. #define MsiSetExternalUI  MsiSetExternalUIW
  240. #else
  241. #define MsiSetExternalUI  MsiSetExternalUIA
  242. #endif // !UNICODE
  243.  
  244.  
  245. // Enable logging to a file or extern UI handler for the client process,
  246. // with control over which log messages are passed to the file or handler
  247.  
  248. UINT WINAPI MsiEnableLogA(
  249.     DWORD     dwLogMode,   // bit flags designating operations to report
  250.     LPCSTR  szLogFile,   // log file, or NULL to direct to external handler
  251.     BOOL      fAppend);    // TRUE to append to existing file, FALSE to replace
  252. UINT WINAPI MsiEnableLogW(
  253.     DWORD     dwLogMode,   // bit flags designating operations to report
  254.     LPCWSTR  szLogFile,   // log file, or NULL to direct to external handler
  255.     BOOL      fAppend);    // TRUE to append to existing file, FALSE to replace
  256. #ifdef UNICODE
  257. #define MsiEnableLog  MsiEnableLogW
  258. #else
  259. #define MsiEnableLog  MsiEnableLogA
  260. #endif // !UNICODE
  261.  
  262. // --------------------------------------------------------------------------
  263. // Functions to query and configure a product as a whole.
  264. // A component descriptor string may be used instead of the product code.
  265. // --------------------------------------------------------------------------
  266.  
  267. // Return the installed state for a product
  268.  
  269. INSTALLSTATE WINAPI MsiQueryProductStateA(
  270.     LPCSTR  szProduct);
  271. INSTALLSTATE WINAPI MsiQueryProductStateW(
  272.     LPCWSTR  szProduct);
  273. #ifdef UNICODE
  274. #define MsiQueryProductState  MsiQueryProductStateW
  275. #else
  276. #define MsiQueryProductState  MsiQueryProductStateA
  277. #endif // !UNICODE
  278.  
  279. // Return product info
  280.  
  281. UINT WINAPI MsiGetProductInfoA(
  282.     LPCSTR   szProduct,      // product code, string GUID, or descriptor
  283.     LPCSTR   szAttribute,    // attribute name, case-sensitive
  284.     LPSTR    lpValueBuf,     // returned value, NULL if not desired
  285.     DWORD      *pcchValueBuf); // in/out buffer character count
  286. UINT WINAPI MsiGetProductInfoW(
  287.     LPCWSTR   szProduct,      // product code, string GUID, or descriptor
  288.     LPCWSTR   szAttribute,    // attribute name, case-sensitive
  289.     LPWSTR    lpValueBuf,     // returned value, NULL if not desired
  290.     DWORD      *pcchValueBuf); // in/out buffer character count
  291. #ifdef UNICODE
  292. #define MsiGetProductInfo  MsiGetProductInfoW
  293. #else
  294. #define MsiGetProductInfo  MsiGetProductInfoA
  295. #endif // !UNICODE
  296.  
  297. // Install a new product.
  298. // Either may be NULL, but the DATABASE property must be specfied
  299.  
  300. UINT WINAPI MsiInstallProductA(
  301.     LPCSTR      szPackagePath,    // location of package to install
  302.     LPCSTR      szCommandLine);   // command line <property settings>
  303. UINT WINAPI MsiInstallProductW(
  304.     LPCWSTR      szPackagePath,    // location of package to install
  305.     LPCWSTR      szCommandLine);   // command line <property settings>
  306. #ifdef UNICODE
  307. #define MsiInstallProduct  MsiInstallProductW
  308. #else
  309. #define MsiInstallProduct  MsiInstallProductA
  310. #endif // !UNICODE
  311.  
  312. // Install/uninstall an advertised or installed product
  313. // No action if installed and INSTALLSTATE_DEFAULT specified
  314.  
  315. UINT WINAPI MsiConfigureProductA(
  316.     LPCSTR      szProduct,        // product code OR descriptor
  317.     int          iInstallLevel,    // how much of the product to install
  318.     INSTALLSTATE eInstallState);   // local/source/default/absent/lock/uncache
  319. UINT WINAPI MsiConfigureProductW(
  320.     LPCWSTR      szProduct,        // product code OR descriptor
  321.     int          iInstallLevel,    // how much of the product to install
  322.     INSTALLSTATE eInstallState);   // local/source/default/absent/lock/uncache
  323. #ifdef UNICODE
  324. #define MsiConfigureProduct  MsiConfigureProductW
  325. #else
  326. #define MsiConfigureProduct  MsiConfigureProductA
  327. #endif // !UNICODE
  328.  
  329. // Reinstall product, used to validate or correct problems
  330.  
  331. UINT WINAPI MsiReinstallProductA(
  332.     LPCSTR      szProduct,        // product code OR descriptor
  333.     DWORD         szReinstallMode); // one or more REINSTALLMODE modes
  334. UINT WINAPI MsiReinstallProductW(
  335.     LPCWSTR      szProduct,        // product code OR descriptor
  336.     DWORD         szReinstallMode); // one or more REINSTALLMODE modes
  337. #ifdef UNICODE
  338. #define MsiReinstallProduct  MsiReinstallProductW
  339. #else
  340. #define MsiReinstallProduct  MsiReinstallProductA
  341. #endif // !UNICODE
  342.  
  343. // Return the product code for a registered component, called once by apps
  344.  
  345. UINT WINAPI MsiGetProductCodeA(
  346.     LPCSTR   szComponent,   // component Id registered for this product
  347.     LPSTR    lpBuf39);      // returned string GUID, sized for 39 characters
  348. UINT WINAPI MsiGetProductCodeW(
  349.     LPCWSTR   szComponent,   // component Id registered for this product
  350.     LPWSTR    lpBuf39);      // returned string GUID, sized for 39 characters
  351. #ifdef UNICODE
  352. #define MsiGetProductCode  MsiGetProductCodeW
  353. #else
  354. #define MsiGetProductCode  MsiGetProductCodeA
  355. #endif // !UNICODE
  356.  
  357. // Return the registered user information for an installed product
  358.  
  359. USERINFOSTATE WINAPI MsiGetUserInfoA(
  360.     LPCSTR  szProduct,        // product code, string GUID
  361.     LPSTR   lpUserNameBuf,    // return user name           
  362.     DWORD    *pcchUserNameBuf, // in/out buffer character count
  363.     LPSTR   lpOrgNameBuf,     // return company name           
  364.     DWORD    *pcchOrgNameBuf,  // in/out buffer character count
  365.     LPSTR   lpSerialBuf,      // return product serial number
  366.     DWORD    *pcchSerialBuf);  // in/out buffer character count
  367. USERINFOSTATE WINAPI MsiGetUserInfoW(
  368.     LPCWSTR  szProduct,        // product code, string GUID
  369.     LPWSTR   lpUserNameBuf,    // return user name           
  370.     DWORD    *pcchUserNameBuf, // in/out buffer character count
  371.     LPWSTR   lpOrgNameBuf,     // return company name           
  372.     DWORD    *pcchOrgNameBuf,  // in/out buffer character count
  373.     LPWSTR   lpSerialBuf,      // return product serial number
  374.     DWORD    *pcchSerialBuf);  // in/out buffer character count
  375. #ifdef UNICODE
  376. #define MsiGetUserInfo  MsiGetUserInfoW
  377. #else
  378. #define MsiGetUserInfo  MsiGetUserInfoA
  379. #endif // !UNICODE
  380.  
  381. // Obtain and store user info and PID from installation wizard (first run)
  382.  
  383. UINT WINAPI MsiCollectUserInfoA(
  384.     LPCSTR  szProduct);     // product code, string GUID
  385. UINT WINAPI MsiCollectUserInfoW(
  386.     LPCWSTR  szProduct);     // product code, string GUID
  387. #ifdef UNICODE
  388. #define MsiCollectUserInfo  MsiCollectUserInfoW
  389. #else
  390. #define MsiCollectUserInfo  MsiCollectUserInfoA
  391. #endif // !UNICODE
  392.  
  393. // --------------------------------------------------------------------------
  394. // Functions to query and configure a feature within a product.
  395. // Separate wrapper functions are provided that accept a descriptor string.
  396. // --------------------------------------------------------------------------
  397.  
  398. // Return the installed state for a product feature
  399.  
  400. INSTALLSTATE WINAPI MsiQueryFeatureStateA(
  401.     LPCSTR  szProduct,
  402.     LPCSTR  szFeature);
  403. INSTALLSTATE WINAPI MsiQueryFeatureStateW(
  404.     LPCWSTR  szProduct,
  405.     LPCWSTR  szFeature);
  406. #ifdef UNICODE
  407. #define MsiQueryFeatureState  MsiQueryFeatureStateW
  408. #else
  409. #define MsiQueryFeatureState  MsiQueryFeatureStateA
  410. #endif // !UNICODE
  411.  
  412. // Indicate intent to use a product feature, increments usage count
  413. // Prompts for CD if not loaded, does not install feature
  414.  
  415. INSTALLSTATE WINAPI MsiUseFeatureA(
  416.     LPCSTR  szProduct,
  417.     LPCSTR  szFeature);
  418. INSTALLSTATE WINAPI MsiUseFeatureW(
  419.     LPCWSTR  szProduct,
  420.     LPCWSTR  szFeature);
  421. #ifdef UNICODE
  422. #define MsiUseFeature  MsiUseFeatureW
  423. #else
  424. #define MsiUseFeature  MsiUseFeatureA
  425. #endif // !UNICODE
  426.  
  427. // Return the usage metrics for a product feature
  428.  
  429. UINT WINAPI MsiGetFeatureUsageA(
  430.     LPCSTR      szProduct,        // product code
  431.     LPCSTR      szFeature,        // feature ID
  432.     DWORD        *pdwUseCount,     // returned use count
  433.     WORD         *pwDateUsed);     // last date used (DOS date format)
  434. UINT WINAPI MsiGetFeatureUsageW(
  435.     LPCWSTR      szProduct,        // product code
  436.     LPCWSTR      szFeature,        // feature ID
  437.     DWORD        *pdwUseCount,     // returned use count
  438.     WORD         *pwDateUsed);     // last date used (DOS date format)
  439. #ifdef UNICODE
  440. #define MsiGetFeatureUsage  MsiGetFeatureUsageW
  441. #else
  442. #define MsiGetFeatureUsage  MsiGetFeatureUsageA
  443. #endif // !UNICODE
  444.  
  445. // Force the installed state for a product feature
  446.  
  447. UINT WINAPI MsiConfigureFeatureA(
  448.     LPCSTR  szProduct,
  449.     LPCSTR  szFeature,
  450.     INSTALLSTATE eInstallState);   // local/source/default/absent/lock/uncache
  451. UINT WINAPI MsiConfigureFeatureW(
  452.     LPCWSTR  szProduct,
  453.     LPCWSTR  szFeature,
  454.     INSTALLSTATE eInstallState);   // local/source/default/absent/lock/uncache
  455. #ifdef UNICODE
  456. #define MsiConfigureFeature  MsiConfigureFeatureW
  457. #else
  458. #define MsiConfigureFeature  MsiConfigureFeatureA
  459. #endif // !UNICODE
  460.  
  461.  
  462. // Reinstall feature, used to validate or correct problems
  463.  
  464. UINT WINAPI MsiReinstallFeatureA(
  465.     LPCSTR      szProduct,        // product code
  466.     LPCSTR      szFeature,        // feature ID, NULL for entire product
  467.     DWORD         dwReinstallMode); // one or more REINSTALLMODE modes
  468. UINT WINAPI MsiReinstallFeatureW(
  469.     LPCWSTR      szProduct,        // product code
  470.     LPCWSTR      szFeature,        // feature ID, NULL for entire product
  471.     DWORD         dwReinstallMode); // one or more REINSTALLMODE modes
  472. #ifdef UNICODE
  473. #define MsiReinstallFeature  MsiReinstallFeatureW
  474. #else
  475. #define MsiReinstallFeature  MsiReinstallFeatureA
  476. #endif // !UNICODE
  477.  
  478. // --------------------------------------------------------------------------
  479. // Functions to return a path to a particular component.
  480. // The state of the feature being used should have been checked previously.
  481. // --------------------------------------------------------------------------
  482.  
  483. // Return full path to an installed component
  484.  
  485. INSTALLSTATE WINAPI MsiLocateComponentA(
  486.     LPCSTR szComponent,  // component Id, string GUID
  487.     LPSTR  lpPathBuf,    // returned path
  488.     DWORD   *pcchBuf);    // in/out buffer character count
  489. INSTALLSTATE WINAPI MsiLocateComponentW(
  490.     LPCWSTR szComponent,  // component Id, string GUID
  491.     LPWSTR  lpPathBuf,    // returned path
  492.     DWORD   *pcchBuf);    // in/out buffer character count
  493. #ifdef UNICODE
  494. #define MsiLocateComponent  MsiLocateComponentW
  495. #else
  496. #define MsiLocateComponent  MsiLocateComponentA
  497. #endif // !UNICODE
  498.  
  499. // Return full component path, performing any necessary installation
  500. // calls MsiQueryFeatureState to detect that all components are installed
  501. // then calls MsiConfigureFeature if any of its components are uninstalled
  502. // then calls MsiLocateComponent to obtain the path the its key file
  503.  
  504. UINT WINAPI MsiProvideComponentA(
  505.     LPCSTR     szProduct,    // product code in case install required
  506.     LPCSTR     szFeature,    // feature ID in case install required
  507.     LPCSTR     szComponent,  // component ID
  508.     DWORD        dwReserved,   // reserved, must be 0
  509.     LPSTR      lpPathBuf,    // returned path, NULL if not desired
  510.     DWORD       *pcchPathBuf);// in/out buffer character count
  511. UINT WINAPI MsiProvideComponentW(
  512.     LPCWSTR     szProduct,    // product code in case install required
  513.     LPCWSTR     szFeature,    // feature ID in case install required
  514.     LPCWSTR     szComponent,  // component ID
  515.     DWORD        dwReserved,   // reserved, must be 0
  516.     LPWSTR      lpPathBuf,    // returned path, NULL if not desired
  517.     DWORD       *pcchPathBuf);// in/out buffer character count
  518. #ifdef UNICODE
  519. #define MsiProvideComponent  MsiProvideComponentW
  520. #else
  521. #define MsiProvideComponent  MsiProvideComponentA
  522. #endif // !UNICODE
  523.  
  524. // For an advertised component that registers descriptor strings,
  525. // return full component path, performing any necessary installation.
  526. // If the qualifier is NULL the default component, if present, will 
  527. // be provided. Calls MsiProvideComponentFromDescriptor to install
  528. // and return the path.
  529.  
  530. UINT WINAPI MsiProvideQualifiedComponentA(
  531.     LPCSTR     szCategory,   // component category ID
  532.     LPCSTR     szQualifier,  // specifies which component to access
  533.     DWORD        dwReserved,   // reserved, must be 0
  534.     LPSTR      lpPathBuf,    // returned path, NULL if not desired
  535.     DWORD       *pcchPathBuf); // in/out buffer character count
  536. UINT WINAPI MsiProvideQualifiedComponentW(
  537.     LPCWSTR     szCategory,   // component category ID
  538.     LPCWSTR     szQualifier,  // specifies which component to access
  539.     DWORD        dwReserved,   // reserved, must be 0
  540.     LPWSTR      lpPathBuf,    // returned path, NULL if not desired
  541.     DWORD       *pcchPathBuf); // in/out buffer character count
  542. #ifdef UNICODE
  543. #define MsiProvideQualifiedComponent  MsiProvideQualifiedComponentW
  544. #else
  545. #define MsiProvideQualifiedComponent  MsiProvideQualifiedComponentA
  546. #endif // !UNICODE
  547.  
  548. // --------------------------------------------------------------------------
  549. // Functions to iterate registered products, features, and components.
  550. // As with reg keys, they accept a 0-based index into the enumeration.
  551. // --------------------------------------------------------------------------
  552.  
  553. // Enumerate the registered products, either installed or advertised
  554.  
  555. UINT WINAPI MsiEnumProductsA(
  556.     DWORD     iProductIndex,    // 0-based index into registered products
  557.     LPSTR   lpProductBuf);    // buffer of char count: 39 (size of string GUID)
  558. UINT WINAPI MsiEnumProductsW(
  559.     DWORD     iProductIndex,    // 0-based index into registered products
  560.     LPWSTR   lpProductBuf);    // buffer of char count: 39 (size of string GUID)
  561. #ifdef UNICODE
  562. #define MsiEnumProducts  MsiEnumProductsW
  563. #else
  564. #define MsiEnumProducts  MsiEnumProductsA
  565. #endif // !UNICODE
  566.  
  567. // Enumerate the advertised features for a given product.
  568. // If parent is not required, supplying NULL will improve performance.
  569.  
  570. UINT WINAPI MsiEnumFeaturesA(
  571.     LPCSTR  szProduct,
  572.     DWORD     iFeatureIndex,  // 0-based index into published features
  573.     LPSTR   lpFeatureBuf,   // feature name buffer,   size=MAX_FEATURE_CHARS+1
  574.     LPSTR   lpParentBuf);   // parent feature buffer, size=MAX_FEATURE_CHARS+1
  575. UINT WINAPI MsiEnumFeaturesW(
  576.     LPCWSTR  szProduct,
  577.     DWORD     iFeatureIndex,  // 0-based index into published features
  578.     LPWSTR   lpFeatureBuf,   // feature name buffer,   size=MAX_FEATURE_CHARS+1
  579.     LPWSTR   lpParentBuf);   // parent feature buffer, size=MAX_FEATURE_CHARS+1
  580. #ifdef UNICODE
  581. #define MsiEnumFeatures  MsiEnumFeaturesW
  582. #else
  583. #define MsiEnumFeatures  MsiEnumFeaturesA
  584. #endif // !UNICODE
  585.  
  586. // Enumerate the installed components for all products
  587.  
  588. UINT WINAPI MsiEnumComponentsA(
  589.     DWORD    iComponentIndex,  // 0-based index into installed components
  590.     LPSTR   lpComponentBuf);  // buffer of char count: 39 (size of string GUID)
  591. UINT WINAPI MsiEnumComponentsW(
  592.     DWORD    iComponentIndex,  // 0-based index into installed components
  593.     LPWSTR   lpComponentBuf);  // buffer of char count: 39 (size of string GUID)
  594. #ifdef UNICODE
  595. #define MsiEnumComponents  MsiEnumComponentsW
  596. #else
  597. #define MsiEnumComponents  MsiEnumComponentsA
  598. #endif // !UNICODE
  599.  
  600. // Enumerate the client products for a component
  601.  
  602. UINT WINAPI MsiEnumClientsA(
  603.     LPCSTR  szComponent,
  604.     DWORD     iProductIndex,    // 0-based index into client products
  605.     LPSTR   lpProductBuf);    // buffer of char count: 39 (size of string GUID)
  606. UINT WINAPI MsiEnumClientsW(
  607.     LPCWSTR  szComponent,
  608.     DWORD     iProductIndex,    // 0-based index into client products
  609.     LPWSTR   lpProductBuf);    // buffer of char count: 39 (size of string GUID)
  610. #ifdef UNICODE
  611. #define MsiEnumClients  MsiEnumClientsW
  612. #else
  613. #define MsiEnumClients  MsiEnumClientsA
  614. #endif // !UNICODE
  615.  
  616. // Enumerate the qualifiers for an advertised component.
  617.  
  618. UINT WINAPI MsiEnumComponentQualifiersA(
  619.     LPCSTR   szComponent,         // generic component ID that is qualified
  620.     DWORD     iIndex,               // 0-based index into qualifiers
  621.     LPSTR    lpQualifierBuf,      // qualifier buffer
  622.     DWORD     *pcchQualifierBuf,   // in/out qualifier buffer character count
  623.     LPSTR    lpDescriptionBuf,    // description buffer
  624.     DWORD     *pcchDescriptionBuf); // in/out description buffer character count
  625. UINT WINAPI MsiEnumComponentQualifiersW(
  626.     LPCWSTR   szComponent,         // generic component ID that is qualified
  627.     DWORD     iIndex,               // 0-based index into qualifiers
  628.     LPWSTR    lpQualifierBuf,      // qualifier buffer
  629.     DWORD     *pcchQualifierBuf,   // in/out qualifier buffer character count
  630.     LPWSTR    lpDescriptionBuf,    // description buffer
  631.     DWORD     *pcchDescriptionBuf); // in/out description buffer character count
  632. #ifdef UNICODE
  633. #define MsiEnumComponentQualifiers  MsiEnumComponentQualifiersW
  634. #else
  635. #define MsiEnumComponentQualifiers  MsiEnumComponentQualifiersA
  636. #endif // !UNICODE
  637.  
  638. // --------------------------------------------------------------------------
  639. // Functions to obtain product or package information.
  640. // --------------------------------------------------------------------------
  641.  
  642. // Open the installation for a product to obtain detailed information
  643.  
  644. UINT WINAPI MsiOpenProductA(
  645.     LPCSTR   szProduct,    // product code OR descriptor
  646.     MSIHANDLE  *hProduct);   // returned product handle, must be closed
  647. UINT WINAPI MsiOpenProductW(
  648.     LPCWSTR   szProduct,    // product code OR descriptor
  649.     MSIHANDLE  *hProduct);   // returned product handle, must be closed
  650. #ifdef UNICODE
  651. #define MsiOpenProduct  MsiOpenProductW
  652. #else
  653. #define MsiOpenProduct  MsiOpenProductA
  654. #endif // !UNICODE
  655.  
  656. // Open a product package in order to access product properties
  657.  
  658. UINT WINAPI MsiOpenPackageA(
  659.     LPCSTR    szPackagePath,     // location of package
  660.     MSIHANDLE  *hProduct);         // returned product handle, must be closed
  661. UINT WINAPI MsiOpenPackageW(
  662.     LPCWSTR    szPackagePath,     // location of package
  663.     MSIHANDLE  *hProduct);         // returned product handle, must be closed
  664. #ifdef UNICODE
  665. #define MsiOpenPackage  MsiOpenPackageW
  666. #else
  667. #define MsiOpenPackage  MsiOpenPackageA
  668. #endif // !UNICODE
  669.  
  670. // Provide the value for an installation property.
  671.  
  672. UINT WINAPI MsiGetProductPropertyA(
  673.     MSIHANDLE   hProduct,       // product handle obtained from MsiOpenProduct
  674.     LPCSTR    szProperty,     // property name, case-sensitive
  675.     LPSTR     lpValueBuf,     // returned value, NULL if not desired
  676.     DWORD      *pcchValueBuf); // in/out buffer character count
  677. UINT WINAPI MsiGetProductPropertyW(
  678.     MSIHANDLE   hProduct,       // product handle obtained from MsiOpenProduct
  679.     LPCWSTR    szProperty,     // property name, case-sensitive
  680.     LPWSTR     lpValueBuf,     // returned value, NULL if not desired
  681.     DWORD      *pcchValueBuf); // in/out buffer character count
  682. #ifdef UNICODE
  683. #define MsiGetProductProperty  MsiGetProductPropertyW
  684. #else
  685. #define MsiGetProductProperty  MsiGetProductPropertyA
  686. #endif // !UNICODE
  687.  
  688.  
  689. // Determine whether a file is a package
  690. // Returns ERROR_SUCCESS if file is a package.
  691.  
  692. UINT WINAPI MsiVerifyPackageA(
  693.     LPCSTR      szPackagePath);   // location of package
  694. UINT WINAPI MsiVerifyPackageW(
  695.     LPCWSTR      szPackagePath);   // location of package
  696. #ifdef UNICODE
  697. #define MsiVerifyPackage  MsiVerifyPackageW
  698. #else
  699. #define MsiVerifyPackage  MsiVerifyPackageA
  700. #endif // !UNICODE
  701.  
  702.  
  703. // Provide descriptive information for product feature: title and description.
  704. // Returns the install level for the feature, or -1 if feature is unknown.
  705. //   0 = feature is not available on this machine
  706. //   1 = highest priority, feature installed if parent is installed
  707. //  >1 = decreasing priority, feature installation based on InstallLevel property
  708.  
  709. UINT WINAPI MsiGetFeatureInfoA(
  710.     MSIHANDLE   hProduct,       // product handle obtained from MsiOpenProduct
  711.     LPCSTR    szFeature,      // feature name
  712.     DWORD      *lpAttributes,  // attribute flags for the feature <to be defined>
  713.     LPSTR     lpTitleBuf,     // returned localized name, NULL if not desired
  714.     DWORD      *pcchTitleBuf,  // in/out buffer character count
  715.     LPSTR     lpHelpBuf,      // returned description, NULL if not desired
  716.     DWORD      *pcchHelpBuf);  // in/out buffer character count
  717. UINT WINAPI MsiGetFeatureInfoW(
  718.     MSIHANDLE   hProduct,       // product handle obtained from MsiOpenProduct
  719.     LPCWSTR    szFeature,      // feature name
  720.     DWORD      *lpAttributes,  // attribute flags for the feature <to be defined>
  721.     LPWSTR     lpTitleBuf,     // returned localized name, NULL if not desired
  722.     DWORD      *pcchTitleBuf,  // in/out buffer character count
  723.     LPWSTR     lpHelpBuf,      // returned description, NULL if not desired
  724.     DWORD      *pcchHelpBuf);  // in/out buffer character count
  725. #ifdef UNICODE
  726. #define MsiGetFeatureInfo  MsiGetFeatureInfoW
  727. #else
  728. #define MsiGetFeatureInfo  MsiGetFeatureInfoA
  729. #endif // !UNICODE
  730.  
  731. // --------------------------------------------------------------------------
  732. // Functions to install missing components and files. These should be used
  733. // as a last resort.
  734. // --------------------------------------------------------------------------
  735.  
  736. // Install a component unexpectedly missing, provided only for error recovery
  737. // This would typically occur due to failue to establish feature availability
  738. // The product feature having the smallest incremental cost is installed
  739.  
  740. UINT WINAPI MsiInstallMissingComponentA(
  741.     LPCSTR      szProduct,        // product code
  742.     LPCSTR      szComponent,      // component Id, string GUID
  743.     INSTALLSTATE eInstallState);  // local/source/default, absent invalid
  744. UINT WINAPI MsiInstallMissingComponentW(
  745.     LPCWSTR      szProduct,        // product code
  746.     LPCWSTR      szComponent,      // component Id, string GUID
  747.     INSTALLSTATE eInstallState);  // local/source/default, absent invalid
  748. #ifdef UNICODE
  749. #define MsiInstallMissingComponent  MsiInstallMissingComponentW
  750. #else
  751. #define MsiInstallMissingComponent  MsiInstallMissingComponentA
  752. #endif // !UNICODE
  753.  
  754. // Install a file unexpectedly missing, provided only for error recovery
  755. // This would typically occur due to failue to establish feature availability
  756. // The missing component is determined from the product's File table, then
  757. // the product feature having the smallest incremental cost is installed
  758.  
  759. UINT WINAPI MsiInstallMissingFileA(
  760.     LPCSTR      szProduct,        // product code
  761.     LPCSTR      szFile);          // file name, without path
  762. UINT WINAPI MsiInstallMissingFileW(
  763.     LPCWSTR      szProduct,        // product code
  764.     LPCWSTR      szFile);          // file name, without path
  765. #ifdef UNICODE
  766. #define MsiInstallMissingFile  MsiInstallMissingFileW
  767. #else
  768. #define MsiInstallMissingFile  MsiInstallMissingFileA
  769. #endif // !UNICODE
  770.  
  771. #ifdef __cplusplus
  772. }
  773. #endif
  774.  
  775. // --------------------------------------------------------------------------
  776. // Error codes for installer access functions - until merged to winerr.h
  777. // --------------------------------------------------------------------------
  778.  
  779. #ifndef ERROR_INSTALL_FAILURE
  780. #define ERROR_INSTALL_USEREXIT      1602L  // User cancel installation.
  781. #define ERROR_INSTALL_FAILURE       1603L  // Fatal error during installation.
  782. #define ERROR_INSTALL_SUSPEND       1604L  // Installation suspended, incomplete.
  783. #define ERROR_UNKNOWN_PRODUCT       1605L  // Product code not registered.
  784. #define ERROR_UNKNOWN_FEATURE       1606L  // Feature ID not registered.
  785. #define ERROR_UNKNOWN_COMPONENT     1607L  // Component ID not registered.
  786. #define ERROR_UNKNOWN_PROPERTY      1608L  // Unknown property.
  787. #define ERROR_INVALID_HANDLE_STATE  1609L  // Handle is in an invalid state.
  788. #define ERROR_BAD_CONFIGURATION     1610L  // Configuration data corrupt.
  789. #define ERROR_INDEX_ABSENT          1611L  // Component qualifier not present.
  790. #define ERROR_INSTALL_SOURCE_ABSENT 1612L  // Install source unavailable.
  791. #define ERROR_PRODUCT_UNINSTALLED   1614L  // Product is uninstalled.
  792. #define ERROR_BAD_QUERY_SYNTAX      1615L  // SQL query syntax invalid or unsupported.
  793. #define ERROR_INVALID_FIELD         1616L  // Record field does not exist.
  794. #endif
  795.  
  796. #ifndef ERROR_INSTALL_STARTING
  797. #define ERROR_INSTALL_STARTING             1600L // Preparing to install...
  798. #define ERROR_INSTALL_SERVICE_FAILURE      1601L // Failure accessing installation service.
  799. #define ERROR_INSTALL_PACKAGE_VERSION      1613L // Database version unsupported.
  800. #define ERROR_INVALID_COMMAND_LINE         1617L // Invalid command line argument.
  801. #define ERROR_INSTALL_ALREADY_RUNNING      1618L // An installation is in progress.
  802. #define ERROR_INSTALL_PACKAGE_OPEN_FAILED  1619L // Installation package could not be opened.
  803. #define ERROR_INSTALL_PACKAGE_INVALID      1620L // Installation package invalid.
  804. #define ERROR_INSTALL_UI_FAILURE           1621L // Could not initialize installer user interface.
  805. #define ERROR_INSTALL_LOG_FAILURE          1622L // Error opening installation log file.
  806. #define ERROR_INSTALL_LANGUAGE_UNSUPPORTED 1623L // Product language not supported by system.
  807. #define ERROR_INSTALL_TRANFORM_FAILURE     1624L // Error applying transform to install package.
  808. #define ERROR_INSTALL_PACKAGE_REJECTED     1625L // Install package signature not accepted.
  809. #define ERROR_FUNCTION_NOT_CALLED          1626L // Function could not be executed.
  810. #define ERROR_FUNCTION_FAILED              1627L // Function failed during execution.
  811. #define ERROR_INVALID_TABLE                1628L // Invalid or unknown table specified.
  812. #define ERROR_DATATYPE_MISMATCH            1629L // Data supplied is of wrong type.
  813. #define ERROR_UNSUPPORTED_TYPE             1630L // Data of this type is not supported.
  814. #define ERROR_CREATE_FAILED                1631L // Data of this type is not supported.
  815. #endif
  816.  
  817. #ifndef ERROR_INSTALL_TEMP_UNWRITABLE      
  818. #define ERROR_INSTALL_TEMP_UNWRITABLE      1632L // Temp folder is full or inaccessible
  819. #endif
  820.  
  821. #pragma option pop /*P_O_Pop*/
  822. #endif // _MSI_H_
  823.