Source code of Windows XP (NT5)
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.

381 lines
14 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1996-1999.
  5. //
  6. // File: NtQuery.h
  7. //
  8. // Contents: Main query header; Defines all exported query API
  9. //
  10. //----------------------------------------------------------------------------
  11. #if !defined(__NTQUERY_H__)
  12. #define __NTQUERY_H__
  13. #if _MSC_VER > 1000
  14. #pragma once
  15. #endif
  16. #if defined(__cplusplus)
  17. extern "C"
  18. {
  19. #endif
  20. //
  21. // Use this path for the null catalog, one that doesn't have an index.
  22. // Use it to search for properties of files that are not indexed.
  23. //
  24. #define CINULLCATALOG L"::_noindex_::"
  25. //
  26. // Use this path to connect to the server for administration work
  27. // (i.e. DocStoreAdmin.) No catalog is associated with the connection
  28. //
  29. #define CIADMIN L"::_nodocstore_::"
  30. //
  31. // Minimal support for persistent handlers.
  32. //
  33. STDAPI LoadIFilter( WCHAR const * pwcsPath,
  34. IUnknown * pUnkOuter,
  35. void ** ppIUnk );
  36. STDAPI BindIFilterFromStorage( IStorage * pStg,
  37. IUnknown * pUnkOuter,
  38. void ** ppIUnk );
  39. STDAPI BindIFilterFromStream( IStream * pStm,
  40. IUnknown * pUnkOuter,
  41. void ** ppIUnk );
  42. STDAPI LocateCatalogsW( WCHAR const * pwszScope,
  43. ULONG iBmk,
  44. WCHAR * pwszMachine,
  45. ULONG * pccMachine,
  46. WCHAR * pwszCat,
  47. ULONG * pccCat );
  48. //
  49. // For calling from VB
  50. //
  51. STDAPI LocateCatalogsA( char const * pwszScope,
  52. ULONG iBmk,
  53. char * pwszMachine,
  54. ULONG * pccMachine,
  55. char * pwszCat,
  56. ULONG * pccCat );
  57. #ifdef UNICODE
  58. #define LocateCatalogs LocateCatalogsW
  59. #else
  60. #define LocateCatalogs LocateCatalogsA
  61. #endif // !UNICODE
  62. // The Index Server Data Source Object CLSID
  63. #define CLSID_INDEX_SERVER_DSO \
  64. { 0xF9AE8980, 0x7E52, 0x11d0, \
  65. { 0x89, 0x64, 0x00, 0xC0, 0x4F, 0xD6, 0x11, 0xD7 } }
  66. // The storage property set
  67. #define PSGUID_STORAGE \
  68. { 0xb725f130, 0x47ef, 0x101a, \
  69. { 0xa5, 0xf1, 0x02, 0x60, 0x8c, 0x9e, 0xeb, 0xac } }
  70. //#define PID_STG_DICTIONARY ((PROPID) 0x00000000) //reserved
  71. //#define PID_STG_CODEPAGE ((PROPID) 0x00000001) //reserved
  72. #define PID_STG_DIRECTORY ((PROPID) 0x00000002)
  73. #define PID_STG_CLASSID ((PROPID) 0x00000003)
  74. #define PID_STG_STORAGETYPE ((PROPID) 0x00000004)
  75. #define PID_STG_VOLUME_ID ((PROPID) 0x00000005)
  76. #define PID_STG_PARENT_WORKID ((PROPID) 0x00000006)
  77. #define PID_STG_SECONDARYSTORE ((PROPID) 0x00000007)
  78. #define PID_STG_FILEINDEX ((PROPID) 0x00000008)
  79. #define PID_STG_LASTCHANGEUSN ((PROPID) 0x00000009)
  80. #define PID_STG_NAME ((PROPID) 0x0000000a)
  81. #define PID_STG_PATH ((PROPID) 0x0000000b)
  82. #define PID_STG_SIZE ((PROPID) 0x0000000c)
  83. #define PID_STG_ATTRIBUTES ((PROPID) 0x0000000d)
  84. #define PID_STG_WRITETIME ((PROPID) 0x0000000e)
  85. #define PID_STG_CREATETIME ((PROPID) 0x0000000f)
  86. #define PID_STG_ACCESSTIME ((PROPID) 0x00000010)
  87. #define PID_STG_CHANGETIME ((PROPID) 0x00000011)
  88. #define PID_STG_CONTENTS ((PROPID) 0x00000013)
  89. #define PID_STG_SHORTNAME ((PROPID) 0x00000014)
  90. #define PID_STG_MAX PID_STG_SHORTNAME
  91. #define CSTORAGEPROPERTY 0x15
  92. // File System Content Index Framework property set
  93. #define DBPROPSET_FSCIFRMWRK_EXT \
  94. { 0xA9BD1526, 0x6A80, 0x11D0, \
  95. { 0x8C, 0x9D, 0x00, 0x20, 0xAF, 0x1D, 0x74, 0x0E } }
  96. #define DBPROP_CI_CATALOG_NAME 2
  97. #define DBPROP_CI_INCLUDE_SCOPES 3
  98. #define DBPROP_CI_DEPTHS 4 // obsolete
  99. #define DBPROP_CI_SCOPE_FLAGS 4
  100. #define DBPROP_CI_EXCLUDE_SCOPES 5
  101. #define DBPROP_CI_SECURITY_ID 6
  102. #define DBPROP_CI_QUERY_TYPE 7
  103. // Query Extension property set
  104. #define DBPROPSET_QUERYEXT \
  105. { 0xA7AC77ED, 0xF8D7, 0x11CE, \
  106. { 0xA7, 0x98, 0x00, 0x20, 0xF8, 0x00, 0x80, 0x25 } }
  107. #define DBPROP_USECONTENTINDEX 2
  108. #define DBPROP_DEFERNONINDEXEDTRIMMING 3
  109. #define DBPROP_USEEXTENDEDDBTYPES 4
  110. #define DBPROP_FIRSTROWS 7
  111. // Content Index Framework Core property set
  112. #define DBPROPSET_CIFRMWRKCORE_EXT \
  113. { 0xafafaca5, 0xb5d1, 0x11d0, \
  114. { 0x8c, 0x62, 0x00, 0xc0, 0x4f, 0xc2, 0xdb, 0x8d } }
  115. #define DBPROP_MACHINE 2
  116. #define DBPROP_CLIENT_CLSID 3
  117. // MSIDXS Rowset property set
  118. #define DBPROPSET_MSIDXS_ROWSETEXT \
  119. { 0xaa6ee6b0, 0xe828, 0x11d0, \
  120. { 0xb2, 0x3e, 0x00, 0xaa, 0x00, 0x47, 0xfc, 0x01 } }
  121. #define MSIDXSPROP_ROWSETQUERYSTATUS 2
  122. #define MSIDXSPROP_COMMAND_LOCALE_STRING 3
  123. #define MSIDXSPROP_QUERY_RESTRICTION 4
  124. //
  125. // Query status values returned by MSIDXSPROP_ROWSETQUERYSTATUS
  126. //
  127. // Bits Effect
  128. // ----- -----------------------------------------------------
  129. // 00-02 Fill Status: How data is being updated, if at all.
  130. // 03-15 Bitfield query reliability: How accurate the result is
  131. #define STAT_BUSY ( 0 )
  132. #define STAT_ERROR ( 0x1 )
  133. #define STAT_DONE ( 0x2 )
  134. #define STAT_REFRESH ( 0x3 )
  135. #define QUERY_FILL_STATUS(x) ( ( x ) & 0x7 )
  136. #define STAT_PARTIAL_SCOPE ( 0x8 )
  137. #define STAT_NOISE_WORDS ( 0x10 )
  138. #define STAT_CONTENT_OUT_OF_DATE ( 0x20 )
  139. #define STAT_REFRESH_INCOMPLETE ( 0x40 )
  140. #define STAT_CONTENT_QUERY_INCOMPLETE ( 0x80 )
  141. #define STAT_TIME_LIMIT_EXCEEDED ( 0x100 )
  142. #define STAT_SHARING_VIOLATION ( 0x200 )
  143. #define QUERY_RELIABILITY_STATUS(x) ( ( x ) & 0xFFF8 )
  144. // Scope flags
  145. #define QUERY_SHALLOW 0
  146. #define QUERY_DEEP 1
  147. #define QUERY_PHYSICAL_PATH 0
  148. #define QUERY_VIRTUAL_PATH 2
  149. // query property set (PSGUID_QUERY) properties not defined in oledb.h
  150. #define PROPID_QUERY_WORKID 5
  151. #define PROPID_QUERY_UNFILTERED 7
  152. #define PROPID_QUERY_VIRTUALPATH 9
  153. #define PROPID_QUERY_LASTSEENTIME 10
  154. //
  155. // Change or get the current state of a catalog specified.
  156. //
  157. #define CICAT_STOPPED 0x1
  158. #define CICAT_READONLY 0x2
  159. #define CICAT_WRITABLE 0x4
  160. #define CICAT_NO_QUERY 0x8
  161. #define CICAT_GET_STATE 0x10
  162. #define CICAT_ALL_OPENED 0x20
  163. STDAPI SetCatalogState ( WCHAR const * pwcsCat,
  164. WCHAR const * pwcsMachine,
  165. DWORD dwNewState,
  166. DWORD * pdwOldState );
  167. //
  168. // Query catalog state
  169. //
  170. #define CI_STATE_SHADOW_MERGE 0x0001 // Index is performing a shadow merge
  171. #define CI_STATE_MASTER_MERGE 0x0002 // Index is performing a master merge
  172. #define CI_STATE_CONTENT_SCAN_REQUIRED 0x0004 // Index is likely corrupt, and a rescan is required
  173. #define CI_STATE_ANNEALING_MERGE 0x0008 // Index is performing an annealing (optimizing) merge
  174. #define CI_STATE_SCANNING 0x0010 // Scans are in-progress
  175. #define CI_STATE_RECOVERING 0x0020 // Index metadata is being recovered
  176. #define CI_STATE_INDEX_MIGRATION_MERGE 0x0040 // Reserved for future use
  177. #define CI_STATE_LOW_MEMORY 0x0080 // Indexing is paused due to low memory availability
  178. #define CI_STATE_HIGH_IO 0x0100 // Indexing is paused due to a high rate of I/O
  179. #define CI_STATE_MASTER_MERGE_PAUSED 0x0200 // Master merge is paused
  180. #define CI_STATE_READ_ONLY 0x0400 // Indexing has been manually paused (read-only)
  181. #define CI_STATE_BATTERY_POWER 0x0800 // Indexing is paused to conserve battery life
  182. #define CI_STATE_USER_ACTIVE 0x1000 // Indexing is paused due to high user activity (keyboard/mouse)
  183. #define CI_STATE_STARTING 0x2000 // Index is still starting up
  184. #define CI_STATE_READING_USNS 0x4000 // USNs on NTFS volumes are being processed
  185. #ifndef CI_STATE_DEFINED
  186. #define CI_STATE_DEFINED
  187. #include <pshpack4.h>
  188. typedef struct _CI_STATE
  189. {
  190. DWORD cbStruct;
  191. DWORD cWordList;
  192. DWORD cPersistentIndex;
  193. DWORD cQueries;
  194. DWORD cDocuments;
  195. DWORD cFreshTest;
  196. DWORD dwMergeProgress;
  197. DWORD eState;
  198. DWORD cFilteredDocuments;
  199. DWORD cTotalDocuments;
  200. DWORD cPendingScans;
  201. DWORD dwIndexSize;
  202. DWORD cUniqueKeys;
  203. DWORD cSecQDocuments;
  204. DWORD dwPropCacheSize;
  205. } CI_STATE;
  206. #include <poppack.h>
  207. #endif // CI_STATE_DEFINED
  208. STDAPI CIState( WCHAR const * pwcsCat,
  209. WCHAR const * pwcsMachine,
  210. CI_STATE * pCiState );
  211. #if defined __ICommand_INTERFACE_DEFINED__
  212. //
  213. // Create an ICommand, specifying scopes, catalogs, and machines
  214. //
  215. STDAPI CIMakeICommand( ICommand ** ppCommand,
  216. ULONG cScope,
  217. DWORD const * aDepths,
  218. WCHAR const * const * awcsScope,
  219. WCHAR const * const * awcsCatalogs,
  220. WCHAR const * const * awcsMachine );
  221. //
  222. // Create an ICommand, specifying a catalog and machine
  223. //
  224. STDAPI CICreateCommand( IUnknown ** ppCommand, // New object
  225. IUnknown * pUnkOuter, // Outer unknown
  226. REFIID riid, // IID of returned object.
  227. // Must be IID_IUnknown unless pUnkOuter == 0
  228. WCHAR const * pwcsCatalog, // Catalog
  229. WCHAR const * pwcsMachine ); // Machine
  230. #if defined __ICommandTree_INTERFACE_DEFINED__
  231. typedef struct tagCIPROPERTYDEF
  232. {
  233. LPWSTR wcsFriendlyName;
  234. DWORD dbType;
  235. DBID dbCol;
  236. } CIPROPERTYDEF;
  237. //
  238. // Values for ulDialect in CITextToSelectTreeEx and CITextToFullTreeEx
  239. //
  240. #define ISQLANG_V1 1 // Same as the non-Ex versions
  241. #define ISQLANG_V2 2
  242. //
  243. // Convert pwszRestriction in Triplish to a command tree.
  244. //
  245. STDAPI CITextToSelectTree( WCHAR const * pwszRestriction,
  246. DBCOMMANDTREE * * ppTree,
  247. ULONG cProperties,
  248. /*optional*/ CIPROPERTYDEF * pProperties,
  249. LCID LocaleID );
  250. STDAPI CITextToSelectTreeEx( WCHAR const * pwszRestriction,
  251. ULONG ulDialect,
  252. DBCOMMANDTREE * * ppTree,
  253. ULONG cProperties,
  254. /*optional*/ CIPROPERTYDEF * pProperties,
  255. LCID LocaleID );
  256. //
  257. // Convert pwszRestriction in Triplish, project columns, sort columns
  258. // and grouping columns to a command tree.
  259. //
  260. STDAPI CITextToFullTree( WCHAR const * pwszRestriction,
  261. WCHAR const * pwszColumns,
  262. WCHAR const * pwszSortColumns, // may be NULL
  263. WCHAR const * pwszGroupings, // may be NULL
  264. DBCOMMANDTREE * * ppTree,
  265. ULONG cProperties,
  266. /*optional*/ CIPROPERTYDEF * pProperties,
  267. LCID LocaleID );
  268. STDAPI CITextToFullTreeEx( WCHAR const * pwszRestriction,
  269. ULONG ulDialect,
  270. WCHAR const * pwszColumns,
  271. WCHAR const * pwszSortColumns, // may be NULL
  272. WCHAR const * pwszGroupings, // may be NULL
  273. DBCOMMANDTREE * * ppTree,
  274. ULONG cProperties,
  275. /*optional*/ CIPROPERTYDEF * pProperties,
  276. LCID LocaleID );
  277. //
  278. // Build a simple restriction node.
  279. //
  280. STDAPI CIBuildQueryNode( WCHAR const *wcsProperty, // friendly property name
  281. DBCOMMANDOP dbOperator, // enumerated constant
  282. PROPVARIANT const *pvarPropertyValue, // value of the property
  283. DBCOMMANDTREE ** ppTree, // ptr to tree returned here. should be non-null
  284. ULONG cProperties,
  285. CIPROPERTYDEF const * pProperty, // Can be 0.
  286. LCID LocaleID ); // locale id to interpret strings
  287. //
  288. // Build a restriction tree from an existing tree (could be empty) and a newly added node/tree.
  289. //
  290. STDAPI CIBuildQueryTree( DBCOMMANDTREE const *pExistingTree, // existing tree. can be null.
  291. DBCOMMANDOP dbBoolOp, // enumerator constant
  292. ULONG cSiblings, // number of siblings in the array
  293. DBCOMMANDTREE const * const *ppSibsToCombine,
  294. DBCOMMANDTREE ** ppTree); // ptr to tree returned here. should be non-null
  295. //
  296. // Convert restriction tree, project columns, sort columns
  297. // and grouping columns to a command tree.
  298. //
  299. STDAPI CIRestrictionToFullTree( DBCOMMANDTREE const *pTree,
  300. WCHAR const * pwszColumns,
  301. WCHAR const * pwszSortColumns, // may be NULL
  302. WCHAR const * pwszGroupings, // may be NULL
  303. DBCOMMANDTREE * * ppTree,
  304. ULONG cProperties,
  305. /*optional*/ CIPROPERTYDEF * pReserved,
  306. LCID LocaleID );
  307. #endif // __ICommandTree_INTERFACE_DEFINED__
  308. #endif // __ICommand_INTERFACE_DEFINED__
  309. #if defined(__cplusplus)
  310. }
  311. #endif
  312. #endif // __NTQUERY_H__