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.

488 lines
17 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992-1999.
  5. //
  6. // File: propapi.h
  7. //
  8. // Contents: Stuff needed to make properties build for Nashville and
  9. // NT... definitions of Nt property api.
  10. //
  11. //
  12. // History: 07-Aug-95 BillMo Created.
  13. // 22-Feb-96 MikeHill Fixed the non-WINNT version of
  14. // PROPASSERTMSG.
  15. // 09-May-96 MikeHill Update define to allow PropSet names
  16. // to be 255 characters (from 127).
  17. // 31-May-96 MikeHill Add OSVersion to RtlCreatePropSet.
  18. // 18-Jun-96 MikeHill Add OleAut32 wrappers to Unicode callouts.
  19. // 15-Jul-96 MikeHill - Remvd Win32 SEH exception-related code.
  20. // - WCHAR=>OLECHAR where applicable.
  21. // - Added RtlOnMappedStreamEvent
  22. // - Added Mac versions of PROPASSERT
  23. //
  24. //--------------------------------------------------------------------------
  25. #ifndef _PROPAPI_H_
  26. #define _PROPAPI_H_
  27. #if _MSC_VER > 1000
  28. #pragma once
  29. #endif
  30. #ifdef __cplusplus
  31. extern "C" {
  32. #endif
  33. //
  34. // typedef the function prototypes necessary
  35. // for the UNICODECALLOUTS structure.
  36. //
  37. typedef UINT (WINAPI FNGETACP)(VOID);
  38. typedef int (WINAPI FNMULTIBYTETOWIDECHAR)(
  39. IN UINT CodePage,
  40. IN DWORD dwFlags,
  41. IN LPCSTR lpMultiByteStr,
  42. IN int cchMultiByte,
  43. OUT LPWSTR lpWideCharStr,
  44. IN int cchWideChar);
  45. typedef int (WINAPI FNWIDECHARTOMULTIBYTE)(
  46. IN UINT CodePage,
  47. IN DWORD dwFlags,
  48. IN LPCWSTR lpWideCharStr,
  49. IN int cchWideChar,
  50. OUT LPSTR lpMultiByteStr,
  51. IN int cchMultiByte,
  52. IN LPCSTR lpDefaultChar,
  53. IN LPBOOL lpUsedDefaultChar);
  54. typedef BSTR FNSYSALLOCSTRING(
  55. OLECHAR FAR* pwsz);
  56. typedef VOID FNSYSFREESTRING(
  57. BSTR pwsz);
  58. //
  59. // The UNICODECALLOUTS structure holds function
  60. // pointers for routines needed by the property
  61. // set routines in NTDLL.
  62. //
  63. typedef struct _UNICODECALLOUTS
  64. {
  65. FNGETACP *pfnGetACP;
  66. FNMULTIBYTETOWIDECHAR *pfnMultiByteToWideChar;
  67. FNWIDECHARTOMULTIBYTE *pfnWideCharToMultiByte;
  68. FNSYSALLOCSTRING *pfnSysAllocString;
  69. FNSYSFREESTRING *pfnSysFreeString;
  70. } UNICODECALLOUTS;
  71. //
  72. // Define the default UNICODECALLOUTS
  73. // values.
  74. //
  75. STDAPI_(BSTR)
  76. PropSysAllocString(OLECHAR FAR* pwsz);
  77. STDAPI_(VOID)
  78. PropSysFreeString(BSTR bstr);
  79. #define WIN32_UNICODECALLOUTS \
  80. GetACP, \
  81. MultiByteToWideChar, \
  82. WideCharToMultiByte, \
  83. PropSysAllocString, \
  84. PropSysFreeString
  85. // Is this pure NT (the IProp DLL needs to run on Win95)?
  86. #if defined(WINNT) && !defined(IPROPERTY_DLL)
  87. // Set the function modifiers
  88. # define PROPSYSAPI NTSYSAPI
  89. # define PROPAPI NTAPI
  90. // How do we free mem allocated in the low-level propset routines?
  91. # define PropFreeHeap(h, z, p) RtlFreeHeap(h, z, p)
  92. // Assert implementations
  93. # define PROPASSERT ASSERT
  94. # define PROPASSERTMSG ASSERTMSG
  95. // Generate the default non-simple property stream/storage name
  96. # define PROPGENPROPERTYNAME(s,n) swprintf ((s), L"prop%lu", (n))
  97. // Ansi sprintf implementations
  98. # define PropSprintfA sprintf
  99. # define PropVsprintfA vsprintf
  100. // Otherwise this is either the IProp DLL (NT, Win95, Mac),
  101. // or it's the Win95 OLE32build.
  102. #else // #if defined(WINNT) && !defined(IPROPERTY_DLL)
  103. // Set the function modifiers
  104. # define PROPSYSAPI
  105. # define PROPAPI
  106. // How do we free mem allocated in low-level propset routines?
  107. # define PropFreeHeap(h, z, p) CoTaskMemFree(p)
  108. // Assert implementations
  109. # if DBG==1
  110. # ifdef _MAC_NODOC
  111. # define PROPASSERT(f) { if (!(f)) FnAssert(#f, NULL, __FILE__, __LINE__); }
  112. # define PROPASSERTMSG(szReason, f) { if (!(f)) FnAssert(#f, szReason, __FILE__, __LINE__); }
  113. # else
  114. # define PROPASSERT(f) PROPASSERTMSG(NULL,f)
  115. # define PROPASSERTMSG(szReason,f) { if(!(f)) PropAssertFailed(#f,__FILE__,__LINE__,szReason); }
  116. # endif
  117. # else
  118. # define PROPASSERT(f)
  119. # define PROPASSERTMSG(szReason, f)
  120. # endif // #if DBG==1
  121. // Generate the default non-simple property stream/storage name
  122. # define PROPGENPROPERTYNAME(s,n) \
  123. { \
  124. memcpy ((s), OLESTR("prop"), sizeof (OLESTR("prop"))); \
  125. ULTOO ((n), &(s)[sizeof("prop") - 1], 10); \
  126. }
  127. // Ansi sprintf implementations
  128. # ifdef IPROPERTY_DLL
  129. # define PropSprintfA sprintf
  130. # define PropVsprintfA vsprintf
  131. # else
  132. # define PropSprintfA wsprintfA
  133. # define PropVsprintfA wvsprintfA
  134. # endif // #ifdef _MAC_NODOC
  135. #endif // #if defined(WINNT) && !defined(IPROPERTY_DLL) ... #else
  136. #define WC_PROPSET0 ((WCHAR) 0x0005) //(L'#'))
  137. #define OC_PROPSET0 ((OLECHAR) 0x0005) //OLESTR('#'))
  138. #define CBIT_BYTE 8
  139. #define CBIT_GUID (CBIT_BYTE * sizeof(GUID))
  140. #define CBIT_CHARMASK 5
  141. // The wFormat field in the header indicates what features
  142. // are supported.
  143. #define PROPSET_WFORMAT_ORIGINAL 0
  144. #define PROPSET_WFORMAT_VERSTREAM 1
  145. #define PROPSET_WFORMAT_CASE_SENSITIVE 1
  146. #define PROPSET_WFORMAT_BEHAVIOR 1
  147. #define PROPSET_WFORMAT_LONG_NAMES 1
  148. #define PROPSET_WFORMAT_EXPANDED_VTS 1
  149. // Allow for OC_PROPSET0 and a GUID mapped to a 32 character alphabet
  150. #define CCH_PROPSET (1 + (CBIT_GUID + CBIT_CHARMASK-1)/CBIT_CHARMASK)
  151. #define CCH_PROPSETSZ (CCH_PROPSET + 1) // allow null
  152. #define CCH_PROPSETCOLONSZ (1 + CCH_PROPSET + 1) // allow colon and null
  153. // Define the max property name in units of characters
  154. // (and synonomously in wchars).
  155. #define CCH_MAXPROPNAME 255 // Matches Shell & Office
  156. #define CCH_MAXPROPNAMESZ (CCH_MAXPROPNAME + 1) // allow null
  157. #define CWC_MAXPROPNAME CCH_MAXPROPNAME
  158. #define CWC_MAXPROPNAMESZ CCH_MAXPROPNAMESZ
  159. #define MAX_DOCFILE_ENTRY_NAME 31
  160. //+--------------------------------------------------------------------------
  161. // Property Access APIs:
  162. //---------------------------------------------------------------------------
  163. typedef VOID *NTPROP;
  164. typedef VOID *NTMAPPEDSTREAM;
  165. typedef VOID *NTMEMORYALLOCATOR;
  166. VOID PROPSYSAPI PROPAPI
  167. RtlSetUnicodeCallouts(
  168. IN UNICODECALLOUTS *pUnicodeCallouts);
  169. ULONG PROPSYSAPI PROPAPI
  170. RtlGuidToPropertySetName(
  171. IN GUID const *pguid,
  172. OUT OLECHAR aocname[]);
  173. NTSTATUS PROPSYSAPI PROPAPI
  174. RtlPropertySetNameToGuid(
  175. IN ULONG cwcname,
  176. IN OLECHAR const aocname[],
  177. OUT GUID *pguid);
  178. VOID
  179. PrSetUnicodeCallouts(
  180. IN UNICODECALLOUTS *pUnicodeCallouts);
  181. ULONG
  182. PrGuidToPropertySetName(
  183. IN GUID const *pguid,
  184. OUT OLECHAR aocname[]);
  185. NTSTATUS
  186. PrPropertySetNameToGuid(
  187. IN ULONG cwcname,
  188. IN OLECHAR const aocname[],
  189. OUT GUID *pguid);
  190. // RtlCreatePropertySet Flags:
  191. #define CREATEPROP_READ 0x0000 // request read access (must exist)
  192. #define CREATEPROP_WRITE 0x0001 // request write access (must exist)
  193. #define CREATEPROP_CREATE 0x0002 // create (overwrite if exists)
  194. #define CREATEPROP_CREATEIF 0x0003 // create (open existing if exists)
  195. #define CREATEPROP_DELETE 0x0004 // delete
  196. #define CREATEPROP_UNKNOWN 0x0008 // read/write state is unknown
  197. #define CREATEPROP_MODEMASK 0x000f // open mode mask
  198. #define CREATEPROP_NONSIMPLE 0x0010 // Is non-simple propset (in a storage)
  199. // RtlCreateMappedStream Flags:
  200. #define CMS_READONLY 0x00000000 // Opened for read-only
  201. #define CMS_WRITE 0x00000001 // Opened for write access
  202. #define CMS_TRANSACTED 0x00000002 // Is transacted
  203. NTSTATUS PROPSYSAPI PROPAPI
  204. RtlCreatePropertySet(
  205. IN NTMAPPEDSTREAM ms, // Nt mapped stream
  206. IN USHORT Flags, // NONSIMPLE|*1* of READ/WRITE/CREATE/CREATEIF/DELETE
  207. OPTIONAL IN GUID const *pguid, // property set guid (create only)
  208. OPTIONAL IN GUID const *pclsid,// CLASSID of propset code (create only)
  209. IN NTMEMORYALLOCATOR ma, // caller's memory allocator
  210. IN ULONG LocaleId, // Locale Id (create only)
  211. OPTIONAL OUT ULONG *pOSVersion,// OS Version field in header.
  212. IN OUT USHORT *pCodePage, // IN: CodePage of property set (create only)
  213. // OUT: CodePage of property set (always)
  214. OUT NTPROP *pnp); // Nt property set context
  215. NTSTATUS PROPSYSAPI PROPAPI
  216. RtlClosePropertySet(
  217. IN NTPROP np); // property set context
  218. NTSTATUS
  219. PrCreatePropertySet(
  220. IN NTMAPPEDSTREAM ms, // Nt mapped stream
  221. IN USHORT Flags, // NONSIMPLE|*1* of READ/WRITE/CREATE/CREATEIF/DELETE
  222. OPTIONAL IN GUID const *pguid, // property set guid (create only)
  223. OPTIONAL IN GUID const *pclsid,// CLASSID of propset code (create only)
  224. IN NTMEMORYALLOCATOR ma, // caller's memory allocator
  225. IN ULONG LocaleId, // Locale Id (create only)
  226. OPTIONAL OUT ULONG *pOSVersion,// OS Version field in header.
  227. IN OUT USHORT *pCodePage, // IN: CodePage of property set (create only)
  228. // OUT: CodePage of property set (always)
  229. IN OUT DWORD *pgrfBehavior, // IN: Behavior of property set (create only)
  230. // OUT: Behavior of property set (always)
  231. OUT NTPROP *pnp); // Nt property set context
  232. NTSTATUS
  233. PrClosePropertySet(
  234. IN NTPROP np); // property set context
  235. // *NOTE* RtlOnMappedStreamEvent assumes that the caller has
  236. // already taken the CPropertySetStream::Lock.
  237. #define CBSTM_UNKNOWN ((ULONG) -1)
  238. NTSTATUS PROPSYSAPI PROPAPI
  239. RtlOnMappedStreamEvent(
  240. IN VOID *pv, // property set context (NTPROP)
  241. IN VOID *pbuf, // property set buffer
  242. IN ULONG cbstm ); // size of underlying stream, or CBSTM_UNKNOWN
  243. NTSTATUS
  244. PrOnMappedStreamEvent(
  245. IN VOID *pv, // property set context (NTPROP)
  246. IN VOID *pbuf, // property set buffer
  247. IN ULONG cbstm ); // size of underlying stream, or CBSTM_UNKNOWN
  248. NTSTATUS PROPSYSAPI PROPAPI
  249. RtlFlushPropertySet(
  250. IN NTPROP np); // property set context
  251. NTSTATUS
  252. PrFlushPropertySet(
  253. IN NTPROP np); // property set context
  254. typedef struct _INDIRECTPROPERTY // ip
  255. {
  256. ULONG Index; // Index into Variant and PropId arrays
  257. LPOLESTR poszName; // Old indirect name, RtlSetProperties() only
  258. } INDIRECTPROPERTY;
  259. NTSTATUS PROPSYSAPI PROPAPI
  260. RtlSetProperties(
  261. IN NTPROP np, // property set context
  262. IN ULONG cprop, // property count
  263. IN PROPID pidNameFirst, // first PROPID for new named properties
  264. IN PROPSPEC const aprs[], // array of property specifiers
  265. OPTIONAL OUT PROPID apid[], // buffer for array of propids
  266. OPTIONAL OUT INDIRECTPROPERTY **ppip, // pointer to returned pointer to
  267. // MAXULONG terminated array of Indirect
  268. // properties w/indexes into aprs & avar
  269. OPTIONAL IN PROPVARIANT const avar[]);// array of properties with values
  270. NTSTATUS
  271. PrSetProperties(
  272. IN NTPROP np, // property set context
  273. IN ULONG cprop, // property count
  274. IN PROPID pidNameFirst, // first PROPID for new named properties
  275. IN PROPSPEC const aprs[], // array of property specifiers
  276. OUT USHORT *pCodePage, // updated code page
  277. OPTIONAL OUT PROPID apid[], // buffer for array of propids
  278. OPTIONAL OUT INDIRECTPROPERTY **ppip, // pointer to returned pointer to
  279. // MAXULONG terminated array of Indirect
  280. // properties w/indexes into aprs & avar
  281. OPTIONAL IN PROPVARIANT const avar[]);// array of properties with values
  282. NTSTATUS PROPSYSAPI PROPAPI
  283. RtlQueryProperties(
  284. IN NTPROP np, // property set context
  285. IN ULONG cprop, // property count
  286. IN PROPSPEC const aprs[], // array of property specifiers
  287. OPTIONAL OUT PROPID apid[], // buffer for array of propids
  288. OPTIONAL OUT INDIRECTPROPERTY **ppip, // pointer to returned pointer to
  289. // MAXULONG terminated array of Indirect
  290. // properties w/indexes into aprs & avar
  291. IN OUT PROPVARIANT *avar, // IN: array of uninitialized PROPVARIANTs,
  292. // OUT: may contain pointers to alloc'd memory
  293. OUT ULONG *pcpropFound); // count of property values retrieved
  294. NTSTATUS
  295. PrQueryProperties(
  296. IN NTPROP np, // property set context
  297. IN ULONG cprop, // property count
  298. IN PROPSPEC const aprs[], // array of property specifiers
  299. OPTIONAL OUT PROPID apid[], // buffer for array of propids
  300. OPTIONAL OUT INDIRECTPROPERTY **ppip, // pointer to returned pointer to
  301. // MAXULONG terminated array of Indirect
  302. // properties w/indexes into aprs & avar
  303. IN OUT PROPVARIANT *avar, // IN: array of uninitialized PROPVARIANTs,
  304. // OUT: may contain pointers to alloc'd memory
  305. OUT ULONG *pcpropFound); // count of property values retrieved
  306. #define ENUMPROP_NONAMES 0x00000001 // return property IDs only
  307. NTSTATUS PROPSYSAPI PROPAPI
  308. RtlEnumerateProperties(
  309. IN NTPROP np, // property set context
  310. IN ULONG Flags, // flags: No Names (propids only), etc.
  311. IN OUT ULONG *pkey, // bookmark; caller set to 0 before 1st call
  312. IN OUT ULONG *pcprop, // pointer to property count
  313. OPTIONAL OUT PROPSPEC aprs[],// IN: array of uninitialized PROPSPECs
  314. // OUT: may contain pointers to alloc'd strings
  315. OPTIONAL OUT STATPROPSTG asps[]);
  316. // IN: array of uninitialized STATPROPSTGs
  317. // OUT: may contain pointers to alloc'd strings
  318. NTSTATUS PROPSYSAPI PROPAPI
  319. RtlQueryPropertyNames(
  320. IN NTPROP np, // property set context
  321. IN ULONG cprop, // property count
  322. IN PROPID const *apid, // PROPID array
  323. OUT OLECHAR *aposz[] // OUT pointers to allocated strings
  324. );
  325. NTSTATUS PROPSYSAPI PROPAPI
  326. RtlSetPropertyNames(
  327. IN NTPROP np, // property set context
  328. IN ULONG cprop, // property count
  329. IN PROPID const *apid, // PROPID array
  330. IN OLECHAR const * const aposz[] // pointers to property names
  331. );
  332. NTSTATUS PROPSYSAPI PROPAPI
  333. RtlSetPropertySetClassId(
  334. IN NTPROP np, // property set context
  335. IN GUID const *pclsid // new CLASSID of propset code
  336. );
  337. NTSTATUS PROPSYSAPI PROPAPI
  338. RtlQueryPropertySet(
  339. IN NTPROP np, // property set context
  340. OUT STATPROPSETSTG *pspss // buffer for property set stat information
  341. );
  342. NTSTATUS PROPSYSAPI PROPAPI
  343. RtlEnumeratePropertySets(
  344. IN HANDLE hstg, // structured storage handle
  345. IN BOOLEAN fRestart, // restart scan
  346. IN OUT ULONG *pcspss, // pointer to count of STATPROPSETSTGs
  347. IN OUT GUID *pkey, // bookmark
  348. OUT STATPROPSETSTG *pspss // array of STATPROPSETSTGs
  349. );
  350. NTSTATUS
  351. PrEnumerateProperties(
  352. IN NTPROP np, // property set context
  353. IN ULONG Flags, // flags: No Names (propids only), etc.
  354. IN OUT ULONG *pkey, // bookmark; caller set to 0 before 1st call
  355. IN OUT ULONG *pcprop, // pointer to property count
  356. OPTIONAL OUT PROPSPEC aprs[],// IN: array of uninitialized PROPSPECs
  357. // OUT: may contain pointers to alloc'd strings
  358. OPTIONAL OUT STATPROPSTG asps[]);
  359. // IN: array of uninitialized STATPROPSTGs
  360. // OUT: may contain pointers to alloc'd strings
  361. NTSTATUS
  362. PrQueryPropertyNames(
  363. IN NTPROP np, // property set context
  364. IN ULONG cprop, // property count
  365. IN PROPID const *apid, // PROPID array
  366. OUT OLECHAR *aposz[] // OUT pointers to allocated strings
  367. );
  368. NTSTATUS
  369. PrSetPropertyNames(
  370. IN NTPROP np, // property set context
  371. IN ULONG cprop, // property count
  372. IN PROPID const *apid, // PROPID array
  373. IN OLECHAR const * const aposz[] // pointers to property names
  374. );
  375. NTSTATUS
  376. PrSetPropertySetClassId(
  377. IN NTPROP np, // property set context
  378. IN GUID const *pclsid // new CLASSID of propset code
  379. );
  380. NTSTATUS
  381. PrQueryPropertySet(
  382. IN NTPROP np, // property set context
  383. OUT STATPROPSETSTG *pspss // buffer for property set stat information
  384. );
  385. NTSTATUS
  386. PrEnumeratePropertySets(
  387. IN HANDLE hstg, // structured storage handle
  388. IN BOOLEAN fRestart, // restart scan
  389. IN OUT ULONG *pcspss, // pointer to count of STATPROPSETSTGs
  390. IN OUT GUID *pkey, // bookmark
  391. OUT STATPROPSETSTG *pspss // array of STATPROPSETSTGs
  392. );
  393. #ifdef __cplusplus
  394. }
  395. #endif
  396. #endif // ifndef _PROPAPI_H_