Setup.Configuration.h 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991
  1. // <copyright file="Setup.Configuration.h" company="Microsoft Corporation">
  2. // Copyright (C) Microsoft Corporation. All rights reserved.
  3. // </copyright>
  4. // This file is licensed under "The MIT License(MIT)".
  5. // This file is released by Visual Studio setup team for consumption by external applications.
  6. // For more information please look at this git repo https://github.com/microsoft/vs-setup-samples
  7. #ifndef SetupConfiguration_h
  8. #define SetupConfiguration_h
  9. #include <objbase.h>
  10. // Constants
  11. //
  12. #ifndef E_NOTFOUND
  13. #define E_NOTFOUND HRESULT_FROM_WIN32(ERROR_NOT_FOUND)
  14. #endif
  15. #ifndef E_FILENOTFOUND
  16. #define E_FILENOTFOUND HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND)
  17. #endif
  18. #if defined(_WIN32) && !defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR)
  19. #ifndef _Outptr_result_maybenull_
  20. #define _Outptr_result_maybenull_
  21. #endif
  22. #ifndef _Out_writes_to_
  23. #define _Out_writes_to_(x,y)
  24. #endif
  25. #ifndef _Reserved_
  26. #define _Reserved_
  27. #endif
  28. #ifndef MAXUINT
  29. #define MAXUINT ((UINT)~((UINT)0))
  30. #endif
  31. // Enumerations
  32. //
  33. /// <summary>
  34. /// The state of an instance.
  35. /// </summary>
  36. enum InstanceState
  37. {
  38. /// <summary>
  39. /// The instance state has not been determined.
  40. /// </summary>
  41. eNone = 0,
  42. /// <summary>
  43. /// The instance installation path exists.
  44. /// </summary>
  45. eLocal = 1,
  46. /// <summary>
  47. /// A product is registered to the instance.
  48. /// </summary>
  49. eRegistered = 2,
  50. /// <summary>
  51. /// No reboot is required for the instance.
  52. /// </summary>
  53. eNoRebootRequired = 4,
  54. /// <summary>
  55. /// The instance represents a complete install.
  56. /// </summary>
  57. eComplete = MAXUINT,
  58. };
  59. // Forward interface declarations
  60. //
  61. #ifndef __ISetupInstance_FWD_DEFINED__
  62. #define __ISetupInstance_FWD_DEFINED__
  63. typedef struct ISetupInstance ISetupInstance;
  64. #endif
  65. #ifndef __ISetupInstance2_FWD_DEFINED__
  66. #define __ISetupInstance2_FWD_DEFINED__
  67. typedef struct ISetupInstance2 ISetupInstance2;
  68. #endif
  69. #ifndef __IEnumSetupInstances_FWD_DEFINED__
  70. #define __IEnumSetupInstances_FWD_DEFINED__
  71. typedef struct IEnumSetupInstances IEnumSetupInstances;
  72. #endif
  73. #ifndef __ISetupConfiguration_FWD_DEFINED__
  74. #define __ISetupConfiguration_FWD_DEFINED__
  75. typedef struct ISetupConfiguration ISetupConfiguration;
  76. #endif
  77. #ifndef __ISetupConfiguration2_FWD_DEFINED__
  78. #define __ISetupConfiguration2_FWD_DEFINED__
  79. typedef struct ISetupConfiguration2 ISetupConfiguration2;
  80. #endif
  81. #ifndef __ISetupPackageReference_FWD_DEFINED__
  82. #define __ISetupPackageReference_FWD_DEFINED__
  83. typedef struct ISetupPackageReference ISetupPackageReference;
  84. #endif
  85. #ifndef __ISetupHelper_FWD_DEFINED__
  86. #define __ISetupHelper_FWD_DEFINED__
  87. typedef struct ISetupHelper ISetupHelper;
  88. #endif
  89. // Forward class declarations
  90. //
  91. #ifndef __SetupConfiguration_FWD_DEFINED__
  92. #define __SetupConfiguration_FWD_DEFINED__
  93. #ifdef __cplusplus
  94. typedef class SetupConfiguration SetupConfiguration;
  95. #endif
  96. #endif
  97. #ifdef __cplusplus
  98. extern "C" {
  99. #endif
  100. // Interface definitions
  101. //
  102. EXTERN_C const IID IID_ISetupInstance;
  103. #if defined(__cplusplus) && !defined(CINTERFACE)
  104. /// <summary>
  105. /// Information about an instance of a product.
  106. /// </summary>
  107. struct DECLSPEC_UUID("B41463C3-8866-43B5-BC33-2B0676F7F42E") DECLSPEC_NOVTABLE ISetupInstance : public IUnknown
  108. {
  109. /// <summary>
  110. /// Gets the instance identifier (should match the name of the parent instance directory).
  111. /// </summary>
  112. /// <param name="pbstrInstanceId">The instance identifier.</param>
  113. /// <returns>Standard HRESULT indicating success or failure, including E_FILENOTFOUND if the instance state does not exist.</returns>
  114. STDMETHOD(GetInstanceId)(
  115. _Out_ BSTR* pbstrInstanceId
  116. ) = 0;
  117. /// <summary>
  118. /// Gets the local date and time when the installation was originally installed.
  119. /// </summary>
  120. /// <param name="pInstallDate">The local date and time when the installation was originally installed.</param>
  121. /// <returns>Standard HRESULT indicating success or failure, including E_FILENOTFOUND if the instance state does not exist and E_NOTFOUND if the property is not defined.</returns>
  122. STDMETHOD(GetInstallDate)(
  123. _Out_ LPFILETIME pInstallDate
  124. ) = 0;
  125. /// <summary>
  126. /// Gets the unique name of the installation, often indicating the branch and other information used for telemetry.
  127. /// </summary>
  128. /// <param name="pbstrInstallationName">The unique name of the installation, often indicating the branch and other information used for telemetry.</param>
  129. /// <returns>Standard HRESULT indicating success or failure, including E_FILENOTFOUND if the instance state does not exist and E_NOTFOUND if the property is not defined.</returns>
  130. STDMETHOD(GetInstallationName)(
  131. _Out_ BSTR* pbstrInstallationName
  132. ) = 0;
  133. /// <summary>
  134. /// Gets the path to the installation root of the product.
  135. /// </summary>
  136. /// <param name="pbstrInstallationPath">The path to the installation root of the product.</param>
  137. /// <returns>Standard HRESULT indicating success or failure, including E_FILENOTFOUND if the instance state does not exist and E_NOTFOUND if the property is not defined.</returns>
  138. STDMETHOD(GetInstallationPath)(
  139. _Out_ BSTR* pbstrInstallationPath
  140. ) = 0;
  141. /// <summary>
  142. /// Gets the version of the product installed in this instance.
  143. /// </summary>
  144. /// <param name="pbstrInstallationVersion">The version of the product installed in this instance.</param>
  145. /// <returns>Standard HRESULT indicating success or failure, including E_FILENOTFOUND if the instance state does not exist and E_NOTFOUND if the property is not defined.</returns>
  146. STDMETHOD(GetInstallationVersion)(
  147. _Out_ BSTR* pbstrInstallationVersion
  148. ) = 0;
  149. /// <summary>
  150. /// Gets the display name (title) of the product installed in this instance.
  151. /// </summary>
  152. /// <param name="lcid">The LCID for the display name.</param>
  153. /// <param name="pbstrDisplayName">The display name (title) of the product installed in this instance.</param>
  154. /// <returns>Standard HRESULT indicating success or failure, including E_FILENOTFOUND if the instance state does not exist and E_NOTFOUND if the property is not defined.</returns>
  155. STDMETHOD(GetDisplayName)(
  156. _In_ LCID lcid,
  157. _Out_ BSTR* pbstrDisplayName
  158. ) = 0;
  159. /// <summary>
  160. /// Gets the description of the product installed in this instance.
  161. /// </summary>
  162. /// <param name="lcid">The LCID for the description.</param>
  163. /// <param name="pbstrDescription">The description of the product installed in this instance.</param>
  164. /// <returns>Standard HRESULT indicating success or failure, including E_FILENOTFOUND if the instance state does not exist and E_NOTFOUND if the property is not defined.</returns>
  165. STDMETHOD(GetDescription)(
  166. _In_ LCID lcid,
  167. _Out_ BSTR* pbstrDescription
  168. ) = 0;
  169. /// <summary>
  170. /// Resolves the optional relative path to the root path of the instance.
  171. /// </summary>
  172. /// <param name="pwszRelativePath">A relative path within the instance to resolve, or NULL to get the root path.</param>
  173. /// <param name="pbstrAbsolutePath">The full path to the optional relative path within the instance. If the relative path is NULL, the root path will always terminate in a backslash.</param>
  174. /// <returns>Standard HRESULT indicating success or failure, including E_FILENOTFOUND if the instance state does not exist and E_NOTFOUND if the property is not defined.</returns>
  175. STDMETHOD(ResolvePath)(
  176. _In_opt_z_ LPCOLESTR pwszRelativePath,
  177. _Out_ BSTR* pbstrAbsolutePath
  178. ) = 0;
  179. };
  180. #endif
  181. EXTERN_C const IID IID_ISetupInstance2;
  182. #if defined(__cplusplus) && !defined(CINTERFACE)
  183. /// <summary>
  184. /// Information about an instance of a product.
  185. /// </summary>
  186. struct DECLSPEC_UUID("89143C9A-05AF-49B0-B717-72E218A2185C") DECLSPEC_NOVTABLE ISetupInstance2 : public ISetupInstance
  187. {
  188. /// <summary>
  189. /// Gets the state of the instance.
  190. /// </summary>
  191. /// <param name="pState">The state of the instance.</param>
  192. /// <returns>Standard HRESULT indicating success or failure, including E_FILENOTFOUND if the instance state does not exist.</returns>
  193. STDMETHOD(GetState)(
  194. _Out_ InstanceState* pState
  195. ) = 0;
  196. /// <summary>
  197. /// Gets an array of package references registered to the instance.
  198. /// </summary>
  199. /// <param name="ppsaPackages">Pointer to an array of <see cref="ISetupPackageReference"/>.</param>
  200. /// <returns>Standard HRESULT indicating success or failure, including E_FILENOTFOUND if the instance state does not exist and E_NOTFOUND if the packages property is not defined.</returns>
  201. STDMETHOD(GetPackages)(
  202. _Out_ LPSAFEARRAY* ppsaPackages
  203. ) = 0;
  204. /// <summary>
  205. /// Gets a pointer to the <see cref="ISetupPackageReference"/> that represents the registered product.
  206. /// </summary>
  207. /// <param name="ppPackage">Pointer to an instance of <see cref="ISetupPackageReference"/>. This may be NULL if <see cref="GetState"/> does not return <see cref="eComplete"/>.</param>
  208. /// <returns>Standard HRESULT indicating success or failure, including E_FILENOTFOUND if the instance state does not exist and E_NOTFOUND if the packages property is not defined.</returns>
  209. STDMETHOD(GetProduct)(
  210. _Outptr_result_maybenull_ ISetupPackageReference** ppPackage
  211. ) = 0;
  212. /// <summary>
  213. /// Gets the relative path to the product application, if available.
  214. /// </summary>
  215. /// <param name="pbstrProductPath">The relative path to the product application, if available.</param>
  216. /// <returns>Standard HRESULT indicating success or failure, including E_FILENOTFOUND if the instance state does not exist.</returns>
  217. STDMETHOD(GetProductPath)(
  218. _Outptr_result_maybenull_ BSTR* pbstrProductPath
  219. ) = 0;
  220. };
  221. #endif
  222. EXTERN_C const IID IID_IEnumSetupInstances;
  223. #if defined(__cplusplus) && !defined(CINTERFACE)
  224. /// <summary>
  225. /// A enumerator of installed <see cref="ISetupInstance"/> objects.
  226. /// </summary>
  227. struct DECLSPEC_UUID("6380BCFF-41D3-4B2E-8B2E-BF8A6810C848") DECLSPEC_NOVTABLE IEnumSetupInstances : public IUnknown
  228. {
  229. /// <summary>
  230. /// Retrieves the next set of product instances in the enumeration sequence.
  231. /// </summary>
  232. /// <param name="celt">The number of product instances to retrieve.</param>
  233. /// <param name="rgelt">A pointer to an array of <see cref="ISetupInstance"/>.</param>
  234. /// <param name="pceltFetched">A pointer to the number of product instances retrieved. If celt is 1 this parameter may be NULL.</param>
  235. /// <returns>S_OK if the number of elements were fetched, S_FALSE if nothing was fetched (at end of enumeration), E_INVALIDARG if celt is greater than 1 and pceltFetched is NULL, or E_OUTOFMEMORY if an <see cref="ISetupInstance"/> could not be allocated.</returns>
  236. STDMETHOD(Next)(
  237. _In_ ULONG celt,
  238. _Out_writes_to_(celt, *pceltFetched) ISetupInstance** rgelt,
  239. _Out_opt_ _Deref_out_range_(0, celt) ULONG* pceltFetched
  240. ) = 0;
  241. /// <summary>
  242. /// Skips the next set of product instances in the enumeration sequence.
  243. /// </summary>
  244. /// <param name="celt">The number of product instances to skip.</param>
  245. /// <returns>S_OK if the number of elements could be skipped; otherwise, S_FALSE;</returns>
  246. STDMETHOD(Skip)(
  247. _In_ ULONG celt
  248. ) = 0;
  249. /// <summary>
  250. /// Resets the enumeration sequence to the beginning.
  251. /// </summary>
  252. /// <returns>Always returns S_OK;</returns>
  253. STDMETHOD(Reset)(void) = 0;
  254. /// <summary>
  255. /// Creates a new enumeration object in the same state as the current enumeration object: the new object points to the same place in the enumeration sequence.
  256. /// </summary>
  257. /// <param name="ppenum">A pointer to a pointer to a new <see cref="IEnumSetupInstances"/> interface. If the method fails, this parameter is undefined.</param>
  258. /// <returns>S_OK if a clone was returned; otherwise, E_OUTOFMEMORY.</returns>
  259. STDMETHOD(Clone)(
  260. _Deref_out_opt_ IEnumSetupInstances** ppenum
  261. ) = 0;
  262. };
  263. #endif
  264. EXTERN_C const IID IID_ISetupConfiguration;
  265. #if defined(__cplusplus) && !defined(CINTERFACE)
  266. /// <summary>
  267. /// Gets information about product instances set up on the machine.
  268. /// </summary>
  269. struct DECLSPEC_UUID("42843719-DB4C-46C2-8E7C-64F1816EFD5B") DECLSPEC_NOVTABLE ISetupConfiguration : public IUnknown
  270. {
  271. /// <summary>
  272. /// Enumerates all completed product instances installed.
  273. /// </summary>
  274. /// <param name="ppEnumInstances">An enumeration of completed, installed product instances.</param>
  275. /// <returns>Standard HRESULT indicating success or failure.</returns>
  276. STDMETHOD(EnumInstances)(
  277. _Out_ IEnumSetupInstances** ppEnumInstances
  278. ) = 0;
  279. /// <summary>
  280. /// Gets the instance for the current process path.
  281. /// </summary>
  282. /// <param name="ppInstance">The instance for the current process path.</param>
  283. /// <returns>The instance for the current process path, or E_NOTFOUND if not found.</returns>
  284. STDMETHOD(GetInstanceForCurrentProcess)(
  285. _Out_ ISetupInstance** ppInstance
  286. ) = 0;
  287. /// <summary>
  288. /// Gets the instance for the given path.
  289. /// </summary>
  290. /// <param name="ppInstance">The instance for the given path.</param>
  291. /// <returns>The instance for the given path, or E_NOTFOUND if not found.</returns>
  292. STDMETHOD(GetInstanceForPath)(
  293. _In_z_ LPCWSTR wzPath,
  294. _Out_ ISetupInstance** ppInstance
  295. ) = 0;
  296. };
  297. #endif
  298. EXTERN_C const IID IID_ISetupConfiguration2;
  299. #if defined(__cplusplus) && !defined(CINTERFACE)
  300. /// <summary>
  301. /// Gets information about product instances.
  302. /// </summary>
  303. struct DECLSPEC_UUID("26AAB78C-4A60-49D6-AF3B-3C35BC93365D") DECLSPEC_NOVTABLE ISetupConfiguration2 : public ISetupConfiguration
  304. {
  305. /// <summary>
  306. /// Enumerates all product instances.
  307. /// </summary>
  308. /// <param name="ppEnumInstances">An enumeration of all product instances.</param>
  309. /// <returns>Standard HRESULT indicating success or failure.</returns>
  310. STDMETHOD(EnumAllInstances)(
  311. _Out_ IEnumSetupInstances** ppEnumInstances
  312. ) = 0;
  313. };
  314. #endif
  315. EXTERN_C const IID IID_ISetupPackageReference;
  316. #if defined(__cplusplus) && !defined(CINTERFACE)
  317. /// <summary>
  318. /// A reference to a package.
  319. /// </summary>
  320. struct DECLSPEC_UUID("da8d8a16-b2b6-4487-a2f1-594ccccd6bf5") DECLSPEC_NOVTABLE ISetupPackageReference : public IUnknown
  321. {
  322. /// <summary>
  323. /// Gets the general package identifier.
  324. /// </summary>
  325. /// <param name="pbstrId">The general package identifier.</param>
  326. /// <returns>Standard HRESULT indicating success or failure.</returns>
  327. STDMETHOD(GetId)(
  328. _Out_ BSTR* pbstrId
  329. ) = 0;
  330. /// <summary>
  331. /// Gets the version of the package.
  332. /// </summary>
  333. /// <param name="pbstrVersion">The version of the package.</param>
  334. /// <returns>Standard HRESULT indicating success or failure.</returns>
  335. STDMETHOD(GetVersion)(
  336. _Out_ BSTR* pbstrVersion
  337. ) = 0;
  338. /// <summary>
  339. /// Gets the target process architecture of the package.
  340. /// </summary>
  341. /// <param name="pbstrChip">The target process architecture of the package.</param>
  342. /// <returns>Standard HRESULT indicating success or failure.</returns>
  343. STDMETHOD(GetChip)(
  344. _Out_ BSTR* pbstrChip
  345. ) = 0;
  346. /// <summary>
  347. /// Gets the language and optional region identifier.
  348. /// </summary>
  349. /// <param name="pbstrLanguage">The language and optional region identifier.</param>
  350. /// <returns>Standard HRESULT indicating success or failure.</returns>
  351. STDMETHOD(GetLanguage)(
  352. _Out_ BSTR* pbstrLanguage
  353. ) = 0;
  354. /// <summary>
  355. /// Gets the build branch of the package.
  356. /// </summary>
  357. /// <param name="pbstrBranch">The build branch of the package.</param>
  358. /// <returns>Standard HRESULT indicating success or failure.</returns>
  359. STDMETHOD(GetBranch)(
  360. _Out_ BSTR* pbstrBranch
  361. ) = 0;
  362. /// <summary>
  363. /// Gets the type of the package.
  364. /// </summary>
  365. /// <param name="pbstrType">The type of the package.</param>
  366. /// <returns>Standard HRESULT indicating success or failure.</returns>
  367. STDMETHOD(GetType)(
  368. _Out_ BSTR* pbstrType
  369. ) = 0;
  370. /// <summary>
  371. /// Gets the unique identifier consisting of all defined tokens.
  372. /// </summary>
  373. /// <param name="pbstrUniqueId">The unique identifier consisting of all defined tokens.</param>
  374. /// <returns>Standard HRESULT indicating success or failure, including E_UNEXPECTED if no Id was defined (required).</returns>
  375. STDMETHOD(GetUniqueId)(
  376. _Out_ BSTR* pbstrUniqueId
  377. ) = 0;
  378. };
  379. #endif
  380. EXTERN_C const IID IID_ISetupHelper;
  381. #if defined(__cplusplus) && !defined(CINTERFACE)
  382. /// <summary>
  383. /// Helper functions.
  384. /// </summary>
  385. /// <remarks>
  386. /// You can query for this interface from the <see cref="SetupConfiguration"/> class.
  387. /// </remarks>
  388. struct DECLSPEC_UUID("42b21b78-6192-463e-87bf-d577838f1d5c") DECLSPEC_NOVTABLE ISetupHelper : public IUnknown
  389. {
  390. /// <summary>
  391. /// Parses a dotted quad version string into a 64-bit unsigned integer.
  392. /// </summary>
  393. /// <param name="pwszVersion">The dotted quad version string to parse, e.g. 1.2.3.4.</param>
  394. /// <param name="pullVersion">A 64-bit unsigned integer representing the version. You can compare this to other versions.</param>
  395. /// <returns>Standard HRESULT indicating success or failure.</returns>
  396. STDMETHOD(ParseVersion)(
  397. _In_ LPCOLESTR pwszVersion,
  398. _Out_ PULONGLONG pullVersion
  399. ) = 0;
  400. /// <summary>
  401. /// Parses a dotted quad version string into a 64-bit unsigned integer.
  402. /// </summary>
  403. /// <param name="pwszVersionRange">The string containing 1 or 2 dotted quad version strings to parse, e.g. [1.0,) that means 1.0.0.0 or newer.</param>
  404. /// <param name="pullMinVersion">A 64-bit unsigned integer representing the minimum version, which may be 0. You can compare this to other versions.</param>
  405. /// <param name="pullMaxVersion">A 64-bit unsigned integer representing the maximum version, which may be MAXULONGLONG. You can compare this to other versions.</param>
  406. /// <returns>Standard HRESULT indicating success or failure.</returns>
  407. STDMETHOD(ParseVersionRange)(
  408. _In_ LPCOLESTR pwszVersionRange,
  409. _Out_ PULONGLONG pullMinVersion,
  410. _Out_ PULONGLONG pullMaxVersion
  411. ) = 0;
  412. };
  413. #endif
  414. // Class declarations
  415. //
  416. EXTERN_C const CLSID CLSID_SetupConfiguration;
  417. #ifdef __cplusplus
  418. /// <summary>
  419. /// This class implements <see cref="ISetupConfiguration"/>, <see cref="ISetupConfiguration2"/>, and <see cref="ISetupHelper"/>.
  420. /// </summary>
  421. class DECLSPEC_UUID("177F0C4A-1CD3-4DE7-A32C-71DBBB9FA36D") SetupConfiguration;
  422. #endif
  423. // Function declarations
  424. //
  425. /// <summary>
  426. /// Gets an <see cref="ISetupConfiguration"/> that provides information about product instances installed on the machine.
  427. /// </summary>
  428. /// <param name="ppConfiguration">The <see cref="ISetupConfiguration"/> that provides information about product instances installed on the machine.</param>
  429. /// <param name="pReserved">Reserved for future use.</param>
  430. /// <returns>Standard HRESULT indicating success or failure.</returns>
  431. STDMETHODIMP GetSetupConfiguration(
  432. _Out_ ISetupConfiguration** ppConfiguration,
  433. _Reserved_ LPVOID pReserved
  434. );
  435. #ifdef __cplusplus
  436. }
  437. #endif
  438. #else
  439. #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
  440. #define VS_SETUP_GCC_DIAGNOSTIC_PUSHED
  441. #pragma GCC diagnostic push
  442. #pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
  443. #endif
  444. #ifndef MAXUINT
  445. #define MAXUINT ((UINT)~((UINT)0))
  446. #endif
  447. #ifndef DECLSPEC_NOVTABLE
  448. #if (_MSC_VER >= 1100) && defined(__cplusplus)
  449. #define DECLSPEC_NOVTABLE __declspec(novtable)
  450. #else
  451. #define DECLSPEC_NOVTABLE
  452. #endif
  453. #endif
  454. // Enumerations
  455. //
  456. /// <summary>
  457. /// The state of an instance.
  458. /// </summary>
  459. enum InstanceState
  460. {
  461. /// <summary>
  462. /// The instance state has not been determined.
  463. /// </summary>
  464. eNone = 0,
  465. /// <summary>
  466. /// The instance installation path exists.
  467. /// </summary>
  468. eLocal = 1,
  469. /// <summary>
  470. /// A product is registered to the instance.
  471. /// </summary>
  472. eRegistered = 2,
  473. /// <summary>
  474. /// No reboot is required for the instance.
  475. /// </summary>
  476. eNoRebootRequired = 4,
  477. /// <summary>
  478. /// The instance represents a complete install.
  479. /// </summary>
  480. eComplete = MAXUINT,
  481. };
  482. // Forward interface declarations
  483. //
  484. #ifndef __ISetupInstance_FWD_DEFINED__
  485. #define __ISetupInstance_FWD_DEFINED__
  486. typedef struct ISetupInstance ISetupInstance;
  487. #endif
  488. #ifndef __ISetupInstance2_FWD_DEFINED__
  489. #define __ISetupInstance2_FWD_DEFINED__
  490. typedef struct ISetupInstance2 ISetupInstance2;
  491. #endif
  492. #ifndef __IEnumSetupInstances_FWD_DEFINED__
  493. #define __IEnumSetupInstances_FWD_DEFINED__
  494. typedef struct IEnumSetupInstances IEnumSetupInstances;
  495. #endif
  496. #ifndef __ISetupConfiguration_FWD_DEFINED__
  497. #define __ISetupConfiguration_FWD_DEFINED__
  498. typedef struct ISetupConfiguration ISetupConfiguration;
  499. #endif
  500. #ifndef __ISetupConfiguration2_FWD_DEFINED__
  501. #define __ISetupConfiguration2_FWD_DEFINED__
  502. typedef struct ISetupConfiguration2 ISetupConfiguration2;
  503. #endif
  504. #ifndef __ISetupPackageReference_FWD_DEFINED__
  505. #define __ISetupPackageReference_FWD_DEFINED__
  506. typedef struct ISetupPackageReference ISetupPackageReference;
  507. #endif
  508. #ifndef __ISetupHelper_FWD_DEFINED__
  509. #define __ISetupHelper_FWD_DEFINED__
  510. typedef struct ISetupHelper ISetupHelper;
  511. #endif
  512. // Forward class declarations
  513. //
  514. #ifndef __SetupConfiguration_FWD_DEFINED__
  515. #define __SetupConfiguration_FWD_DEFINED__
  516. #ifdef __cplusplus
  517. typedef class SetupConfiguration SetupConfiguration;
  518. #endif
  519. #endif
  520. #ifdef __cplusplus
  521. extern "C" {
  522. #endif
  523. // Interface definitions
  524. //
  525. EXTERN_C const IID IID_ISetupInstance;
  526. #if defined(__cplusplus) && !defined(CINTERFACE)
  527. /// <summary>
  528. /// Information about an instance of a product.
  529. /// </summary>
  530. struct DECLSPEC_UUID("B41463C3-8866-43B5-BC33-2B0676F7F42E") DECLSPEC_NOVTABLE ISetupInstance : public IUnknown
  531. {
  532. /// <summary>
  533. /// Gets the instance identifier (should match the name of the parent instance directory).
  534. /// </summary>
  535. /// <param name="pbstrInstanceId">The instance identifier.</param>
  536. /// <returns>Standard HRESULT indicating success or failure, including E_FILENOTFOUND if the instance state does not exist.</returns>
  537. STDMETHOD(GetInstanceId)(
  538. BSTR* pbstrInstanceId
  539. ) = 0;
  540. /// <summary>
  541. /// Gets the local date and time when the installation was originally installed.
  542. /// </summary>
  543. /// <param name="pInstallDate">The local date and time when the installation was originally installed.</param>
  544. /// <returns>Standard HRESULT indicating success or failure, including E_FILENOTFOUND if the instance state does not exist and E_NOTFOUND if the property is not defined.</returns>
  545. STDMETHOD(GetInstallDate)(
  546. LPFILETIME pInstallDate
  547. ) = 0;
  548. /// <summary>
  549. /// Gets the unique name of the installation, often indicating the branch and other information used for telemetry.
  550. /// </summary>
  551. /// <param name="pbstrInstallationName">The unique name of the installation, often indicating the branch and other information used for telemetry.</param>
  552. /// <returns>Standard HRESULT indicating success or failure, including E_FILENOTFOUND if the instance state does not exist and E_NOTFOUND if the property is not defined.</returns>
  553. STDMETHOD(GetInstallationName)(
  554. BSTR* pbstrInstallationName
  555. ) = 0;
  556. /// <summary>
  557. /// Gets the path to the installation root of the product.
  558. /// </summary>
  559. /// <param name="pbstrInstallationPath">The path to the installation root of the product.</param>
  560. /// <returns>Standard HRESULT indicating success or failure, including E_FILENOTFOUND if the instance state does not exist and E_NOTFOUND if the property is not defined.</returns>
  561. STDMETHOD(GetInstallationPath)(
  562. BSTR* pbstrInstallationPath
  563. ) = 0;
  564. /// <summary>
  565. /// Gets the version of the product installed in this instance.
  566. /// </summary>
  567. /// <param name="pbstrInstallationVersion">The version of the product installed in this instance.</param>
  568. /// <returns>Standard HRESULT indicating success or failure, including E_FILENOTFOUND if the instance state does not exist and E_NOTFOUND if the property is not defined.</returns>
  569. STDMETHOD(GetInstallationVersion)(
  570. BSTR* pbstrInstallationVersion
  571. ) = 0;
  572. /// <summary>
  573. /// Gets the display name (title) of the product installed in this instance.
  574. /// </summary>
  575. /// <param name="lcid">The LCID for the display name.</param>
  576. /// <param name="pbstrDisplayName">The display name (title) of the product installed in this instance.</param>
  577. /// <returns>Standard HRESULT indicating success or failure, including E_FILENOTFOUND if the instance state does not exist and E_NOTFOUND if the property is not defined.</returns>
  578. STDMETHOD(GetDisplayName)(
  579. LCID lcid,
  580. BSTR* pbstrDisplayName
  581. ) = 0;
  582. /// <summary>
  583. /// Gets the description of the product installed in this instance.
  584. /// </summary>
  585. /// <param name="lcid">The LCID for the description.</param>
  586. /// <param name="pbstrDescription">The description of the product installed in this instance.</param>
  587. /// <returns>Standard HRESULT indicating success or failure, including E_FILENOTFOUND if the instance state does not exist and E_NOTFOUND if the property is not defined.</returns>
  588. STDMETHOD(GetDescription)(
  589. LCID lcid,
  590. BSTR* pbstrDescription
  591. ) = 0;
  592. /// <summary>
  593. /// Resolves the optional relative path to the root path of the instance.
  594. /// </summary>
  595. /// <param name="pwszRelativePath">A relative path within the instance to resolve, or NULL to get the root path.</param>
  596. /// <param name="pbstrAbsolutePath">The full path to the optional relative path within the instance. If the relative path is NULL, the root path will always terminate in a backslash.</param>
  597. /// <returns>Standard HRESULT indicating success or failure, including E_FILENOTFOUND if the instance state does not exist and E_NOTFOUND if the property is not defined.</returns>
  598. STDMETHOD(ResolvePath)(
  599. LPCOLESTR pwszRelativePath,
  600. BSTR* pbstrAbsolutePath
  601. ) = 0;
  602. };
  603. #endif
  604. EXTERN_C const IID IID_ISetupInstance2;
  605. #if defined(__cplusplus) && !defined(CINTERFACE)
  606. /// <summary>
  607. /// Information about an instance of a product.
  608. /// </summary>
  609. struct DECLSPEC_UUID("89143C9A-05AF-49B0-B717-72E218A2185C") DECLSPEC_NOVTABLE ISetupInstance2 : public ISetupInstance
  610. {
  611. /// <summary>
  612. /// Gets the state of the instance.
  613. /// </summary>
  614. /// <param name="pState">The state of the instance.</param>
  615. /// <returns>Standard HRESULT indicating success or failure, including E_FILENOTFOUND if the instance state does not exist.</returns>
  616. STDMETHOD(GetState)(
  617. InstanceState* pState
  618. ) = 0;
  619. /// <summary>
  620. /// Gets an array of package references registered to the instance.
  621. /// </summary>
  622. /// <param name="ppsaPackages">Pointer to an array of <see cref="ISetupPackageReference"/>.</param>
  623. /// <returns>Standard HRESULT indicating success or failure, including E_FILENOTFOUND if the instance state does not exist and E_NOTFOUND if the packages property is not defined.</returns>
  624. STDMETHOD(GetPackages)(
  625. LPSAFEARRAY* ppsaPackages
  626. ) = 0;
  627. /// <summary>
  628. /// Gets a pointer to the <see cref="ISetupPackageReference"/> that represents the registered product.
  629. /// </summary>
  630. /// <param name="ppPackage">Pointer to an instance of <see cref="ISetupPackageReference"/>. This may be NULL if <see cref="GetState"/> does not return <see cref="eComplete"/>.</param>
  631. /// <returns>Standard HRESULT indicating success or failure, including E_FILENOTFOUND if the instance state does not exist and E_NOTFOUND if the packages property is not defined.</returns>
  632. STDMETHOD(GetProduct)(
  633. ISetupPackageReference** ppPackage
  634. ) = 0;
  635. /// <summary>
  636. /// Gets the relative path to the product application, if available.
  637. /// </summary>
  638. /// <param name="pbstrProductPath">The relative path to the product application, if available.</param>
  639. /// <returns>Standard HRESULT indicating success or failure, including E_FILENOTFOUND if the instance state does not exist.</returns>
  640. STDMETHOD(GetProductPath)(
  641. BSTR* pbstrProductPath
  642. ) = 0;
  643. };
  644. #endif
  645. EXTERN_C const IID IID_IEnumSetupInstances;
  646. #if defined(__cplusplus) && !defined(CINTERFACE)
  647. /// <summary>
  648. /// A enumerator of installed <see cref="ISetupInstance"/> objects.
  649. /// </summary>
  650. struct DECLSPEC_UUID("6380BCFF-41D3-4B2E-8B2E-BF8A6810C848") DECLSPEC_NOVTABLE IEnumSetupInstances : public IUnknown
  651. {
  652. /// <summary>
  653. /// Retrieves the next set of product instances in the enumeration sequence.
  654. /// </summary>
  655. /// <param name="celt">The number of product instances to retrieve.</param>
  656. /// <param name="rgelt">A pointer to an array of <see cref="ISetupInstance"/>.</param>
  657. /// <param name="pceltFetched">A pointer to the number of product instances retrieved. If celt is 1 this parameter may be NULL.</param>
  658. /// <returns>S_OK if the number of elements were fetched, S_FALSE if nothing was fetched (at end of enumeration), E_INVALIDARG if celt is greater than 1 and pceltFetched is NULL, or E_OUTOFMEMORY if an <see cref="ISetupInstance"/> could not be allocated.</returns>
  659. STDMETHOD(Next)(
  660. ULONG celt,
  661. ISetupInstance** rgelt,
  662. ULONG* pceltFetched
  663. ) = 0;
  664. /// <summary>
  665. /// Skips the next set of product instances in the enumeration sequence.
  666. /// </summary>
  667. /// <param name="celt">The number of product instances to skip.</param>
  668. /// <returns>S_OK if the number of elements could be skipped; otherwise, S_FALSE;</returns>
  669. STDMETHOD(Skip)(
  670. ULONG celt
  671. ) = 0;
  672. /// <summary>
  673. /// Resets the enumeration sequence to the beginning.
  674. /// </summary>
  675. /// <returns>Always returns S_OK;</returns>
  676. STDMETHOD(Reset)(void) = 0;
  677. /// <summary>
  678. /// Creates a new enumeration object in the same state as the current enumeration object: the new object points to the same place in the enumeration sequence.
  679. /// </summary>
  680. /// <param name="ppenum">A pointer to a pointer to a new <see cref="IEnumSetupInstances"/> interface. If the method fails, this parameter is undefined.</param>
  681. /// <returns>S_OK if a clone was returned; otherwise, E_OUTOFMEMORY.</returns>
  682. STDMETHOD(Clone)(
  683. IEnumSetupInstances** ppenum
  684. ) = 0;
  685. };
  686. #endif
  687. EXTERN_C const IID IID_ISetupConfiguration;
  688. #if defined(__cplusplus) && !defined(CINTERFACE)
  689. /// <summary>
  690. /// Gets information about product instances set up on the machine.
  691. /// </summary>
  692. struct DECLSPEC_UUID("42843719-DB4C-46C2-8E7C-64F1816EFD5B") DECLSPEC_NOVTABLE ISetupConfiguration : public IUnknown
  693. {
  694. /// <summary>
  695. /// Enumerates all completed product instances installed.
  696. /// </summary>
  697. /// <param name="ppEnumInstances">An enumeration of completed, installed product instances.</param>
  698. /// <returns>Standard HRESULT indicating success or failure.</returns>
  699. STDMETHOD(EnumInstances)(
  700. IEnumSetupInstances** ppEnumInstances
  701. ) = 0;
  702. /// <summary>
  703. /// Gets the instance for the current process path.
  704. /// </summary>
  705. /// <param name="ppInstance">The instance for the current process path.</param>
  706. /// <returns>The instance for the current process path, or E_NOTFOUND if not found.</returns>
  707. STDMETHOD(GetInstanceForCurrentProcess)(
  708. ISetupInstance** ppInstance
  709. ) = 0;
  710. /// <summary>
  711. /// Gets the instance for the given path.
  712. /// </summary>
  713. /// <param name="ppInstance">The instance for the given path.</param>
  714. /// <returns>The instance for the given path, or E_NOTFOUND if not found.</returns>
  715. STDMETHOD(GetInstanceForPath)(
  716. LPCWSTR wzPath,
  717. ISetupInstance** ppInstance
  718. ) = 0;
  719. };
  720. #endif
  721. EXTERN_C const IID IID_ISetupConfiguration2;
  722. #if defined(__cplusplus) && !defined(CINTERFACE)
  723. /// <summary>
  724. /// Gets information about product instances.
  725. /// </summary>
  726. struct DECLSPEC_UUID("26AAB78C-4A60-49D6-AF3B-3C35BC93365D") DECLSPEC_NOVTABLE ISetupConfiguration2 : public ISetupConfiguration
  727. {
  728. /// <summary>
  729. /// Enumerates all product instances.
  730. /// </summary>
  731. /// <param name="ppEnumInstances">An enumeration of all product instances.</param>
  732. /// <returns>Standard HRESULT indicating success or failure.</returns>
  733. STDMETHOD(EnumAllInstances)(
  734. IEnumSetupInstances** ppEnumInstances
  735. ) = 0;
  736. };
  737. #endif
  738. EXTERN_C const IID IID_ISetupPackageReference;
  739. #if defined(__cplusplus) && !defined(CINTERFACE)
  740. /// <summary>
  741. /// A reference to a package.
  742. /// </summary>
  743. struct DECLSPEC_UUID("da8d8a16-b2b6-4487-a2f1-594ccccd6bf5") DECLSPEC_NOVTABLE ISetupPackageReference : public IUnknown
  744. {
  745. /// <summary>
  746. /// Gets the general package identifier.
  747. /// </summary>
  748. /// <param name="pbstrId">The general package identifier.</param>
  749. /// <returns>Standard HRESULT indicating success or failure.</returns>
  750. STDMETHOD(GetId)(
  751. BSTR* pbstrId
  752. ) = 0;
  753. /// <summary>
  754. /// Gets the version of the package.
  755. /// </summary>
  756. /// <param name="pbstrVersion">The version of the package.</param>
  757. /// <returns>Standard HRESULT indicating success or failure.</returns>
  758. STDMETHOD(GetVersion)(
  759. BSTR* pbstrVersion
  760. ) = 0;
  761. /// <summary>
  762. /// Gets the target process architecture of the package.
  763. /// </summary>
  764. /// <param name="pbstrChip">The target process architecture of the package.</param>
  765. /// <returns>Standard HRESULT indicating success or failure.</returns>
  766. STDMETHOD(GetChip)(
  767. BSTR* pbstrChip
  768. ) = 0;
  769. /// <summary>
  770. /// Gets the language and optional region identifier.
  771. /// </summary>
  772. /// <param name="pbstrLanguage">The language and optional region identifier.</param>
  773. /// <returns>Standard HRESULT indicating success or failure.</returns>
  774. STDMETHOD(GetLanguage)(
  775. BSTR* pbstrLanguage
  776. ) = 0;
  777. /// <summary>
  778. /// Gets the build branch of the package.
  779. /// </summary>
  780. /// <param name="pbstrBranch">The build branch of the package.</param>
  781. /// <returns>Standard HRESULT indicating success or failure.</returns>
  782. STDMETHOD(GetBranch)(
  783. BSTR* pbstrBranch
  784. ) = 0;
  785. /// <summary>
  786. /// Gets the type of the package.
  787. /// </summary>
  788. /// <param name="pbstrType">The type of the package.</param>
  789. /// <returns>Standard HRESULT indicating success or failure.</returns>
  790. STDMETHOD(GetType)(
  791. BSTR* pbstrType
  792. ) = 0;
  793. /// <summary>
  794. /// Gets the unique identifier consisting of all defined tokens.
  795. /// </summary>
  796. /// <param name="pbstrUniqueId">The unique identifier consisting of all defined tokens.</param>
  797. /// <returns>Standard HRESULT indicating success or failure, including E_UNEXPECTED if no Id was defined (required).</returns>
  798. STDMETHOD(GetUniqueId)(
  799. BSTR* pbstrUniqueId
  800. ) = 0;
  801. };
  802. #endif
  803. EXTERN_C const IID IID_ISetupHelper;
  804. #if defined(__cplusplus) && !defined(CINTERFACE)
  805. /// <summary>
  806. /// Helper functions.
  807. /// </summary>
  808. /// <remarks>
  809. /// You can query for this interface from the <see cref="SetupConfiguration"/> class.
  810. /// </remarks>
  811. struct DECLSPEC_UUID("42b21b78-6192-463e-87bf-d577838f1d5c") DECLSPEC_NOVTABLE ISetupHelper : public IUnknown
  812. {
  813. /// <summary>
  814. /// Parses a dotted quad version string into a 64-bit unsigned integer.
  815. /// </summary>
  816. /// <param name="pwszVersion">The dotted quad version string to parse, e.g. 1.2.3.4.</param>
  817. /// <param name="pullVersion">A 64-bit unsigned integer representing the version. You can compare this to other versions.</param>
  818. /// <returns>Standard HRESULT indicating success or failure.</returns>
  819. STDMETHOD(ParseVersion)(
  820. LPCOLESTR pwszVersion,
  821. PULONGLONG pullVersion
  822. ) = 0;
  823. /// <summary>
  824. /// Parses a dotted quad version string into a 64-bit unsigned integer.
  825. /// </summary>
  826. /// <param name="pwszVersionRange">The string containing 1 or 2 dotted quad version strings to parse, e.g. [1.0,) that means 1.0.0.0 or newer.</param>
  827. /// <param name="pullMinVersion">A 64-bit unsigned integer representing the minimum version, which may be 0. You can compare this to other versions.</param>
  828. /// <param name="pullMaxVersion">A 64-bit unsigned integer representing the maximum version, which may be MAXULONGLONG. You can compare this to other versions.</param>
  829. /// <returns>Standard HRESULT indicating success or failure.</returns>
  830. STDMETHOD(ParseVersionRange)(
  831. LPCOLESTR pwszVersionRange,
  832. PULONGLONG pullMinVersion,
  833. PULONGLONG pullMaxVersion
  834. ) = 0;
  835. };
  836. #endif
  837. // Class declarations
  838. //
  839. EXTERN_C const CLSID CLSID_SetupConfiguration;
  840. #ifdef __cplusplus
  841. /// <summary>
  842. /// This class implements <see cref="ISetupConfiguration"/>, <see cref="ISetupConfiguration2"/>, and <see cref="ISetupHelper"/>.
  843. /// </summary>
  844. class DECLSPEC_UUID("177F0C4A-1CD3-4DE7-A32C-71DBBB9FA36D") SetupConfiguration;
  845. #endif
  846. // Function declarations
  847. //
  848. /// <summary>
  849. /// Gets an <see cref="ISetupConfiguration"/> that provides information about product instances installed on the machine.
  850. /// </summary>
  851. /// <param name="ppConfiguration">The <see cref="ISetupConfiguration"/> that provides information about product instances installed on the machine.</param>
  852. /// <param name="pReserved">Reserved for future use.</param>
  853. /// <returns>Standard HRESULT indicating success or failure.</returns>
  854. STDMETHODIMP GetSetupConfiguration(
  855. ISetupConfiguration** ppConfiguration,
  856. LPVOID pReserved
  857. );
  858. #ifdef __cplusplus
  859. }
  860. #endif
  861. #ifdef VS_SETUP_GCC_DIAGNOSTIC_PUSHED
  862. #pragma GCC diagnostic pop
  863. #undef VS_SETUP_GCC_DIAGNOSTIC_PUSHED
  864. #endif
  865. #endif
  866. #endif