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

1123 lines
41 KiB

  1. //
  2. // CCSHELL stock definition and declaration header
  3. //
  4. #ifndef __CCSTOCK_H__
  5. #define __CCSTOCK_H__
  6. #include <malloc.h> // for _alloca
  7. #ifndef RC_INVOKED
  8. // NT and Win95 environments set warnings differently. This makes
  9. // our project consistent across environments.
  10. #pragma warning(3:4101) // Unreferenced local variable
  11. //
  12. // Sugar-coating
  13. //
  14. #define PUBLIC
  15. #define PRIVATE
  16. #define IN
  17. #define OUT
  18. #define BLOCK
  19. #ifndef DECLARE_STANDARD_TYPES
  20. /*
  21. * For a type "FOO", define the standard derived types PFOO, CFOO, and PCFOO.
  22. */
  23. #define DECLARE_STANDARD_TYPES(type) typedef type *P##type; \
  24. typedef const type C##type; \
  25. typedef const type *PC##type;
  26. #endif
  27. #ifndef DECLARE_STANDARD_TYPES_U
  28. /*
  29. * For a type "FOO", define the standard derived UNALIGNED types PFOO, CFOO, and PCFOO.
  30. * WINNT: RISC boxes care about ALIGNED, intel does not.
  31. */
  32. #define DECLARE_STANDARD_TYPES_U(type) typedef UNALIGNED type *P##type; \
  33. typedef UNALIGNED const type C##type; \
  34. typedef UNALIGNED const type *PC##type;
  35. #endif
  36. // For string constants that are always wide
  37. #define __TEXTW(x) L##x
  38. #define TEXTW(x) __TEXTW(x)
  39. //
  40. // Count of characters to count of bytes
  41. //
  42. #define CbFromCchW(cch) ((cch)*sizeof(WCHAR))
  43. #define CbFromCchA(cch) ((cch)*sizeof(CHAR))
  44. #ifdef UNICODE
  45. #define CbFromCch CbFromCchW
  46. #else // UNICODE
  47. #define CbFromCch CbFromCchA
  48. #endif // UNICODE
  49. //
  50. // General flag macros
  51. //
  52. #define SetFlag(obj, f) do {obj |= (f);} while (0)
  53. #define ToggleFlag(obj, f) do {obj ^= (f);} while (0)
  54. #define ClearFlag(obj, f) do {obj &= ~(f);} while (0)
  55. #define IsFlagSet(obj, f) (BOOL)(((obj) & (f)) == (f))
  56. #define IsFlagClear(obj, f) (BOOL)(((obj) & (f)) != (f))
  57. //
  58. // String macros
  59. //
  60. #define IsSzEqual(sz1, sz2) (BOOL)(lstrcmpi(sz1, sz2) == 0)
  61. #define IsSzEqualC(sz1, sz2) (BOOL)(lstrcmp(sz1, sz2) == 0)
  62. #define lstrnicmpA(sz1, sz2, cch) StrCmpNIA(sz1, sz2, cch)
  63. #define lstrnicmpW(sz1, sz2, cch) StrCmpNIW(sz1, sz2, cch)
  64. #define lstrncmpA(sz1, sz2, cch) StrCmpNA(sz1, sz2, cch)
  65. #define lstrncmpW(sz1, sz2, cch) StrCmpNW(sz1, sz2, cch)
  66. //
  67. // lstrcatnA and lstrcatnW are #defined here to StrCatBuff which is implemented
  68. // in shlwapi. We do this here (and not in shlwapi.h or shlwapip.h) in case the
  69. // kernel guys ever decided to implement this.
  70. //
  71. #define lstrcatnA(sz1, sz2, cchBuffSize) StrCatBuffA(sz1, sz2, cchBuffSize)
  72. #define lstrcatnW(sz1, sz2, cchBuffSize) StrCatBuffW(sz1, sz2, cchBuffSize)
  73. #ifdef UNICODE
  74. #define lstrcatn lstrcatnW
  75. #else
  76. #define lstrcatn lstrcatnA
  77. #endif // UNICODE
  78. #ifdef UNICODE
  79. #define lstrnicmp lstrnicmpW
  80. #define lstrncmp lstrncmpW
  81. #else
  82. #define lstrnicmp lstrnicmpA
  83. #define lstrncmp lstrncmpA
  84. #endif
  85. #ifndef SIZEOF
  86. #define SIZEOF(a) sizeof(a)
  87. #endif
  88. #ifndef ARRAYSIZE
  89. #define ARRAYSIZE(a) (sizeof(a)/sizeof(a[0]))
  90. #endif
  91. #define SIZECHARS(sz) (sizeof(sz)/sizeof(sz[0]))
  92. #define InRange(id, idFirst, idLast) ((UINT)((id)-(idFirst)) <= (UINT)((idLast)-(idFirst)))
  93. #define IsInRange InRange
  94. // ATOMICRELEASE
  95. //
  96. #ifndef ATOMICRELEASE
  97. # ifdef __cplusplus
  98. # define ATOMICRELEASET(p, type) { if(p) { type* punkT=p; p=NULL; punkT->Release();} }
  99. # else
  100. # define ATOMICRELEASET(p, type) { if(p) { type* punkT=p; p=NULL; punkT->lpVtbl->Release(punkT);} }
  101. # endif
  102. // doing this as a function instead of inline seems to be a size win.
  103. //
  104. # ifdef NOATOMICRELESEFUNC
  105. # define ATOMICRELEASE(p) ATOMICRELEASET(p, IUnknown)
  106. # else
  107. # ifdef __cplusplus
  108. # define ATOMICRELEASE(p) IUnknown_SafeReleaseAndNullPtr(p)
  109. # else
  110. # define ATOMICRELEASE(p) IUnknown_AtomicRelease((void **)&p)
  111. # endif
  112. # endif
  113. #endif //ATOMICRELEASE
  114. //
  115. // IID_PPV_ARG(IType, ppType)
  116. // IType is the type of pType
  117. // ppType is the variable of type IType that will be filled
  118. //
  119. // RESULTS in: IID_IType, ppvType
  120. // will create a compiler error if wrong level of indirection is used.
  121. //
  122. // macro for QueryInterface and related functions
  123. // that require a IID and a (void **)
  124. // this will insure that the cast is safe and appropriate on C++
  125. //
  126. // IID_PPV_ARG_NULL(IType, ppType)
  127. //
  128. // Just like IID_PPV_ARG, except that it sticks a NULL between the
  129. // IID and PPV (for IShellFolder::GetUIObjectOf).
  130. //
  131. // IID_X_PPV_ARG(IType, X, ppType)
  132. //
  133. // Just like IID_PPV_ARG, except that it sticks X between the
  134. // IID and PPV (for SHBindToObject).
  135. //
  136. //
  137. #ifdef __cplusplus
  138. #define IID_PPV_ARG(IType, ppType) IID_##IType, reinterpret_cast<void**>(static_cast<IType**>(ppType))
  139. #define IID_X_PPV_ARG(IType, X, ppType) IID_##IType, X, reinterpret_cast<void**>(static_cast<IType**>(ppType))
  140. #else
  141. #define IID_PPV_ARG(IType, ppType) &IID_##IType, (void**)(ppType)
  142. #define IID_X_PPV_ARG(IType, X, ppType) &IID_##IType, X, (void**)(ppType)
  143. #endif
  144. #define IID_PPV_ARG_NULL(IType, ppType) IID_X_PPV_ARG(IType, NULL, ppType)
  145. #define PPUNK_SET(ppunkDst, punkSrc) \
  146. { ATOMICRELEASE(*ppunkDst); \
  147. if (punkSrc) \
  148. { punkSrc->AddRef(); \
  149. *ppunkDst = punkSrc; \
  150. } \
  151. }
  152. //
  153. // Helper macro for managing weak pointers to inner interfaces.
  154. // (It's the weak version of ATOMICRELEASE.)
  155. //
  156. // The extra cast to (void **) is to keep C++ from doing strange
  157. // inheritance games when all I want to do is change the type.
  158. //
  159. #ifndef RELEASEINNERINTERFACE
  160. #define RELEASEINNERINTERFACE(pOuter, p) \
  161. SHReleaseInnerInterface(pOuter, (IUnknown**)(void **)&(p))
  162. #endif // RELEASEINNERINTERFACE
  163. // For checking window charsets
  164. #ifdef UNICODE
  165. #define IsWindowTchar IsWindowUnicode
  166. #else // !UNICODE
  167. #define IsWindowTchar !IsWindowUnicode
  168. #endif // UNICODE
  169. #ifdef DEBUG
  170. // This macro is especially useful for cleaner looking code in
  171. // declarations or for single lines. For example, instead of:
  172. //
  173. // {
  174. // DWORD dwRet;
  175. // #ifdef DEBUG
  176. // DWORD dwDebugOnlyVariable;
  177. // #endif
  178. //
  179. // ....
  180. // }
  181. //
  182. // You can type:
  183. //
  184. // {
  185. // DWORD dwRet;
  186. // DEBUG_CODE( DWORD dwDebugOnlyVariable; )
  187. //
  188. // ....
  189. // }
  190. #define DEBUG_CODE(x) x
  191. #else
  192. #define DEBUG_CODE(x)
  193. #endif // DEBUG
  194. //
  195. // SAFECAST(obj, type)
  196. //
  197. // This macro is extremely useful for enforcing strong typechecking on other
  198. // macros. It generates no code.
  199. //
  200. // Simply insert this macro at the beginning of an expression list for
  201. // each parameter that must be typechecked. For example, for the
  202. // definition of MYMAX(x, y), where x and y absolutely must be integers,
  203. // use:
  204. //
  205. // #define MYMAX(x, y) (SAFECAST(x, int), SAFECAST(y, int), ((x) > (y) ? (x) : (y)))
  206. //
  207. //
  208. #define SAFECAST(_obj, _type) (((_type)(_obj)==(_obj)?0:0), (_type)(_obj))
  209. //
  210. // Bitfields don't get along too well with bools,
  211. // so here's an easy way to convert them:
  212. //
  213. #define BOOLIFY(expr) (!!(expr))
  214. // (scotth): we should probably make this a 'bool', but be careful
  215. // because the Alpha compiler might not recognize it yet. Talk to AndyP.
  216. // This isn't a BOOL because BOOL is signed and the compiler produces
  217. // sloppy code when testing for a single bit.
  218. typedef DWORD BITBOOL;
  219. // a three state boolean for bools that need initialization
  220. typedef enum
  221. {
  222. TRIBIT_UNDEFINED = 0,
  223. TRIBIT_TRUE,
  224. TRIBIT_FALSE,
  225. } TRIBIT;
  226. //
  227. // DESTROY_OBJ_WITH_HANDLE(h, fn)
  228. //
  229. // Kind of like ATOMICRELEASE for handles. Checks for NULL and assigns
  230. // NULL when it's done. You supply the destructor function.
  231. //
  232. #define DESTROY_OBJ_WITH_HANDLE(h, fn) { if (h) { fn(h); (h) = NULL; } }
  233. // STOCKLIB util functions
  234. // staticIsOS(): returns TRUE/FALSE if the platform is the indicated OS.
  235. // This function exists for those who cannot link to shlwapi.dll
  236. STDAPI_(BOOL) staticIsOS(DWORD dwOS);
  237. #include <pshpack2.h>
  238. typedef struct tagDLGTEMPLATEEX
  239. {
  240. WORD wDlgVer;
  241. WORD wSignature;
  242. DWORD dwHelpID;
  243. DWORD dwExStyle;
  244. DWORD dwStyle;
  245. WORD cDlgItems;
  246. short x;
  247. short y;
  248. short cx;
  249. short cy;
  250. } DLGTEMPLATEEX, *LPDLGTEMPLATEEX;
  251. #include <poppack.h>
  252. //
  253. // round macro that rounds a to the next multiple of b.
  254. //
  255. #ifndef ROUNDUP
  256. #define ROUNDUP(a,b) ((((a)+(b)-1)/(b))*(b))
  257. #endif
  258. #define ROUND_TO_CLUSTER ROUNDUP
  259. //
  260. // macro that rounds cbSize fields to the nearest pointer size (for alignment)
  261. //
  262. #define ROUND_TO_POINTER(cbSize) ROUNDUP(cbSize, sizeof(void*))
  263. //
  264. // macro that sees if a give char is an number
  265. //
  266. #define ISDIGIT(c) ((c) >= TEXT('0') && (c) <= TEXT('9'))
  267. //
  268. // inline that does PathIsDotOrDotDot
  269. //
  270. __inline BOOL PathIsDotOrDotDotW(LPCWSTR pszPath)
  271. {
  272. return ((pszPath[0] == L'.') &&
  273. ((pszPath[1] == L'\0') || ((pszPath[1] == L'.') && (pszPath[2] == L'\0'))));
  274. }
  275. __inline BOOL PathIsDotOrDotDotA(LPCSTR pszPath)
  276. {
  277. return ((pszPath[0] == '.') &&
  278. ((pszPath[1] == '\0') || ((pszPath[1] == '.') && (pszPath[2] == '\0'))));
  279. }
  280. #ifdef UNICODE
  281. #define PathIsDotOrDotDot PathIsDotOrDotDotW
  282. #else
  283. #define PathIsDotOrDotDot PathIsDotOrDotDotA
  284. #endif
  285. //
  286. // FILETIME helpers
  287. //
  288. __inline unsigned __int64 _FILETIMEtoInt64(const FILETIME* pft)
  289. {
  290. return ((unsigned __int64)pft->dwHighDateTime << 32) + pft->dwLowDateTime;
  291. }
  292. #define FILETIMEtoInt64(ft) _FILETIMEtoInt64(&(ft))
  293. __inline void SetFILETIMEfromInt64(FILETIME *pft, unsigned __int64 i64)
  294. {
  295. pft->dwLowDateTime = (DWORD)i64;
  296. pft->dwHighDateTime = (DWORD)(i64 >> 32);
  297. }
  298. __inline void IncrementFILETIME(FILETIME *pft, unsigned __int64 iAdjust)
  299. {
  300. SetFILETIMEfromInt64(pft, _FILETIMEtoInt64(pft) + iAdjust);
  301. }
  302. __inline void DecrementFILETIME(FILETIME *pft, unsigned __int64 iAdjust)
  303. {
  304. SetFILETIMEfromInt64(pft, _FILETIMEtoInt64(pft) - iAdjust);
  305. }
  306. //
  307. // FAT and NTFS use different values for "unknown date".
  308. //
  309. // The FAT "unknown date" is January 1 1980 LOCAL TIME.
  310. // The NTFS "unknown date" is January 1 1601 GMT.
  311. //
  312. // This LOCAL/GMT discrepancy is annoying.
  313. //
  314. #define FT_FAT_UNKNOWNLOCAL ((unsigned __int64)0x01A8E79FE1D58000)
  315. #define FT_NTFS_UNKNOWNGMT ((unsigned __int64)0x0000000000000000)
  316. //
  317. // FT_ONEHOUR is the number of FILETIME units in an hour.
  318. // FT_ONEDAY is the number of FILETIME units in a day.
  319. //
  320. // 10,000,000 FILETIME units per second *
  321. // 3600 seconds per hour *
  322. // 24 hours per day.
  323. //
  324. #define FT_ONESECOND ((unsigned __int64)10000000)
  325. #define FT_ONEHOUR ((unsigned __int64)10000000 * 3600)
  326. #define FT_ONEDAY ((unsigned __int64)10000000 * 3600 * 24)
  327. //
  328. //
  329. // WindowLong accessor macros and other Win64 niceness
  330. //
  331. __inline void * GetWindowPtr(HWND hWnd, int nIndex) {
  332. return (void *)GetWindowLongPtr(hWnd, nIndex);
  333. }
  334. __inline void * SetWindowPtr(HWND hWnd, int nIndex, void * p) {
  335. return (void *)SetWindowLongPtr(hWnd, nIndex, (LONG_PTR)p);
  336. }
  337. //*** GetWindowLong0 -- 'fast' GetWindowLong (and GetWindowLongPtr)
  338. // DESCRIPTION
  339. // what's up w/ this? it's all about perf. GetWindowLong has 'A' and 'W'
  340. // versions. however 99% of the time they do the same thing (the other
  341. // 0.1% has to do w/ setting the WndProc and having to go thru a thunk).
  342. // but we still need wrappers for the general case. but most of the time
  343. // we're just doing a GWL(0), e.g. on entry to a wndproc to get our private
  344. // data. so by having a special version of that, we save going thru the
  345. // wrapper (which was costing us 1-3% of our profile).
  346. // NOTES
  347. // note that we call the 'A' version since that's guaranteed to exist on
  348. // all platforms.
  349. __inline LONG GetWindowLong0(HWND hWnd) {
  350. return GetWindowLongA(hWnd, 0);
  351. }
  352. __inline LONG SetWindowLong0(HWND hWnd, LONG l) {
  353. return SetWindowLongA(hWnd, 0, l);
  354. }
  355. __inline void * GetWindowPtr0(HWND hWnd) {
  356. return (void *)GetWindowLongPtrA(hWnd, 0);
  357. }
  358. __inline void * SetWindowPtr0(HWND hWnd, void * p) {
  359. return (void *)SetWindowLongPtrA(hWnd, 0, (LONG_PTR)p);
  360. }
  361. #define IS_WM_CONTEXTMENU_KEYBOARD(lParam) ((DWORD)(lParam) == 0xFFFFFFFF)
  362. //
  363. // CharUpperChar - Convert a single character to uppercase
  364. //
  365. __inline WCHAR CharUpperCharW(int c)
  366. {
  367. return (WCHAR)(DWORD_PTR)CharUpperW((LPWSTR)(DWORD_PTR)(c));
  368. }
  369. __inline CHAR CharUpperCharA(int c)
  370. {
  371. return (CHAR)(DWORD_PTR)CharUpperA((LPSTR)(DWORD_PTR)(c));
  372. }
  373. //
  374. // CharLowerChar - Convert a single character to lowercase
  375. //
  376. __inline WCHAR CharLowerCharW(int c)
  377. {
  378. return (WCHAR)(DWORD_PTR)CharLowerW((LPWSTR)(DWORD_PTR)(c));
  379. }
  380. __inline CHAR CharLowerCharA(int c)
  381. {
  382. return (CHAR)(DWORD_PTR)CharLowerA((LPSTR)(DWORD_PTR)(c));
  383. }
  384. #ifdef UNICODE
  385. #define CharUpperChar CharUpperCharW
  386. #define CharLowerChar CharLowerCharW
  387. #else
  388. #define CharUpperChar CharUpperCharA
  389. #define CharLowerChar CharLowerCharA
  390. #endif
  391. //
  392. // ShrinkProcessWorkingSet - Use this to stay Sundown-happy.
  393. //
  394. #define ShrinkWorkingSet() \
  395. SetProcessWorkingSetSize(GetCurrentProcess(), (SIZE_T) -1, (SIZE_T) -1)
  396. //
  397. // COM Initialization.
  398. //
  399. // Usage:
  400. //
  401. // HRESULT hrInit = SHCoInitialize();
  402. // ... do COM stuff ...
  403. // SHCoUninitialize(hrInit);
  404. //
  405. // Notice: Continue doing COM stuff even if SHCoInitialize fails.
  406. // It might fail if somebody else already CoInit'd with different
  407. // flags, but we don't want to barf under those conditions.
  408. //
  409. STDAPI SHCoInitialize(void);
  410. #define SHCoUninitialize(hr) if (SUCCEEDED(hr)) CoUninitialize()
  411. //
  412. // OLE Initialization.
  413. //
  414. // Usage:
  415. //
  416. // HRESULT hrInit = SHOleInitialize(pMalloc);
  417. // ... do COM stuff ...
  418. // SHOleUninitialize(hrInit);
  419. //
  420. #define SHOleInitialize(pMalloc) OleInitialize(pMalloc)
  421. #define SHOleUninitialize(hr) if (SUCCEEDED(hr)) OleUninitialize()
  422. #include <shtypes.h>
  423. //
  424. // Name Parsing generic across the shell
  425. //
  426. // Usage:
  427. //
  428. // HRESULT SHGetNameAndFlags()
  429. // wrapper to bind to the folder and do a GetDisplayName()
  430. //
  431. STDAPI SHGetNameAndFlagsA(LPCITEMIDLIST pidl, DWORD dwFlags, LPSTR pszName, UINT cchName, DWORD *pdwAttribs);
  432. STDAPI SHGetNameAndFlagsW(LPCITEMIDLIST pidl, DWORD dwFlags, LPWSTR pszName, UINT cchName, DWORD *pdwAttribs);
  433. STDAPI SHBindToObject(struct IShellFolder *psf, REFIID riid, LPCITEMIDLIST pidl, void **ppv);
  434. STDAPI SHBindToObjectEx(struct IShellFolder *psf, LPCITEMIDLIST pidl, struct IBindCtx *pbc, REFIID riid, void **ppv);
  435. STDAPI SHGetUIObjectFromFullPIDL(LPCITEMIDLIST pidl, HWND hwnd, REFIID riid, void **ppv);
  436. STDAPI SHGetTargetFolderIDList(LPCITEMIDLIST pidlFolder, LPITEMIDLIST *ppidl);
  437. STDAPI SHGetTargetFolderPathW(LPCITEMIDLIST pidlFolder, LPWSTR pszPath, UINT cchBuf);
  438. STDAPI SHGetTargetFolderPathA(LPCITEMIDLIST pidlFolder, LPSTR pszPath, UINT cchBuf);
  439. STDAPI_(DWORD) SHGetAttributes(struct IShellFolder *psf, LPCITEMIDLIST pidl, DWORD dwAttributes);
  440. #define SHGetAttributesOf(pidl, prgfInOut) SHGetNameAndFlags(pidl, 0, NULL, 0, prgfInOut)
  441. #ifdef __IShellFolder2_FWD_DEFINED__
  442. STDAPI GetDateProperty(IShellFolder2 *psf, LPCITEMIDLIST pidl, const SHCOLUMNID *pscid, FILETIME *pft);
  443. STDAPI GetLongProperty(IShellFolder2 *psf, LPCITEMIDLIST pidl, const SHCOLUMNID *pscid, ULONGLONG *pdw);
  444. STDAPI GetStringProperty(IShellFolder2 *psf, LPCITEMIDLIST pidl, const SHCOLUMNID *pscid, LPTSTR pszVal, int cchMax);
  445. #endif // __IShellFolder2_FWD_DEFINED__
  446. STDAPI LoadFromFileW(REFCLSID clsid, LPCWSTR pszFile, REFIID riid, void **ppv);
  447. STDAPI LoadFromIDList(REFCLSID clsid, LPCITEMIDLIST pidl, REFIID riid, void **ppv);
  448. STDAPI_(DWORD) GetUrlSchemeW(LPCWSTR pszUrl);
  449. STDAPI_(DWORD) GetUrlSchemeA(LPCSTR pszUrl);
  450. STDAPI_(void) SHRemoveURLTurd(LPTSTR pszUrl);
  451. STDAPI_(void) SHCleanupUrlForDisplay(LPTSTR pszUrl);
  452. STDAPI_(BOOL) ShouldNavigateInIE(LPCWSTR pszUrl);
  453. STDAPI_(BOOL) IsDesktopFrame(IUnknown *punk);
  454. #ifdef UNICODE
  455. #define SHGetNameAndFlags SHGetNameAndFlagsW
  456. #define GetUrlScheme GetUrlSchemeW
  457. #define SHGetTargetFolderPath SHGetTargetFolderPathW
  458. #define LoadFromFile LoadFromFileW
  459. #else
  460. #define SHGetNameAndFlags SHGetNameAndFlagsA
  461. #define GetUrlScheme GetUrlSchemeA
  462. #define SHGetTargetFolderPath SHGetTargetFolderPathA
  463. #endif
  464. //
  465. // BindCtx helpers
  466. //
  467. STDAPI BindCtx_CreateWithMode(DWORD grfMode, IBindCtx **ppbc);
  468. STDAPI_(DWORD) BindCtx_GetMode(IBindCtx *pbc, DWORD grfModeDefault);
  469. STDAPI_(BOOL) BindCtx_ContainsObject(IBindCtx *pbc, LPOLESTR sz);
  470. STDAPI BindCtx_RegisterObjectParam(IBindCtx *pbcIn, LPCOLESTR pszRegister, IUnknown *punkRegister, IBindCtx **ppbcOut);
  471. STDAPI BindCtx_CreateWithTimeoutDelta(DWORD dwTicksToAllow, IBindCtx **ppbc);
  472. STDAPI BindCtx_GetTimeoutDelta(IBindCtx *pbc, DWORD *pdwTicksToAllow);
  473. STDAPI BindCtx_RegisterUIWindow(IBindCtx *pbcIn, HWND hwnd, IBindCtx **ppbcOut);
  474. STDAPI_(HWND) BindCtx_GetUIWindow(IBindCtx *pbc);
  475. typedef struct _BINDCTX_PARAM
  476. {
  477. LPCWSTR pszName;
  478. IBindCtx *pbcParam;
  479. } BINDCTX_PARAM;
  480. STDAPI BindCtx_RegisterObjectParams(IBindCtx *pbcIn, BINDCTX_PARAM *rgParams, UINT cParams, IBindCtx **ppbcOut);
  481. // SHBindToIDListParent(LPCITEMIDLIST pidl, REFIID riid, void **ppv, LPCITEMIDLIST *ppidlLast)
  482. //
  483. // Given a pidl, you can get an interface pointer (as specified by riid) of the pidl's parent folder (in ppv)
  484. // If ppidlLast is non-NULL, you can also get the pidl of the last item.
  485. //
  486. STDAPI SHBindToIDListParent(LPCITEMIDLIST pidl, REFIID riid, void **ppv, LPCITEMIDLIST *ppidlLast);
  487. //
  488. // SHBindToFolderIDListParent
  489. //
  490. // Same as SHBindToIDListParent, except you also specify which root to use.
  491. //
  492. STDAPI SHBindToFolderIDListParent(struct IShellFolder *psfRoot, LPCITEMIDLIST pidl, REFIID riid, void **ppv, LPCITEMIDLIST *ppidlLast);
  493. //
  494. // context menu and dataobject helpers.
  495. //
  496. STDAPI_(void) ReleaseStgMediumHGLOBAL(void *pv, STGMEDIUM *pmedium);
  497. #define FAILED_AND_NOT_CANCELED(hr) (FAILED(hr) && (HRESULT_FROM_WIN32(ERROR_CANCELLED) != hr))
  498. STDAPI SHInvokeCommandOnPidl(HWND hwnd, IUnknown* punk, LPCITEMIDLIST pidl, UINT uFlags, LPCSTR lpVerb);
  499. STDAPI SHInvokeCommandOnPidlArray(HWND hwnd, IUnknown* punk, struct IShellFolder* psf, LPCITEMIDLIST *ppidlItem, UINT cItems, UINT uFlags, LPCSTR lpVerb);
  500. STDAPI SHInvokeCommandOnDataObject(HWND hwnd, IUnknown* punk, IDataObject* pdo, UINT uFlags, LPCSTR lpVerb);
  501. STDAPI DisplayNameOf(struct IShellFolder *psf, LPCITEMIDLIST pidl, DWORD flags, LPTSTR psz, UINT cch);
  502. STDAPI DisplayNameOfAsOLESTR(struct IShellFolder *psf, LPCITEMIDLIST pidl, DWORD flags, LPWSTR *ppsz);
  503. // clones the parent of the pidl
  504. STDAPI_(LPITEMIDLIST) ILCloneParent(LPCITEMIDLIST pidl);
  505. STDAPI SHGetIDListFromUnk(IUnknown *punk, LPITEMIDLIST *ppidl);
  506. STDAPI_(BOOL) ILIsRooted(LPCITEMIDLIST pidl);
  507. STDAPI_(LPCITEMIDLIST) ILRootedFindIDList(LPCITEMIDLIST pidl);
  508. STDAPI_(BOOL) ILRootedGetClsid(LPCITEMIDLIST pidl, CLSID *clsid);
  509. STDAPI_(LPITEMIDLIST) ILRootedCreateIDList(CLSID *pclsid, LPCITEMIDLIST pidl);
  510. STDAPI_(int) ILRootedCompare(LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2);
  511. #define ILIsEqualRoot(pidl1, pidl2) (0 == ILRootedCompare(pidl1, pidl2))
  512. STDAPI ILRootedBindToRoot(LPCITEMIDLIST pidl, REFIID riid, void **ppv);
  513. STDAPI ILRootedBindToObject(LPCITEMIDLIST pidl, REFIID riid, void **ppv);
  514. STDAPI ILRootedBindToParentFolder(LPCITEMIDLIST pidl, REFIID riid, void **ppv, LPCITEMIDLIST *ppidlChild);
  515. typedef HGLOBAL HIDA;
  516. STDAPI_(HIDA) HIDA_Create(LPCITEMIDLIST pidlFolder, UINT cidl, LPCITEMIDLIST *apidl);
  517. STDAPI_(void) HIDA_Free(HIDA hida);
  518. STDAPI_(HIDA) HIDA_Clone(HIDA hida);
  519. STDAPI_(UINT) HIDA_GetCount(HIDA hida);
  520. STDAPI_(UINT) HIDA_GetIDList(HIDA hida, UINT i, LPITEMIDLIST pidlOut, UINT cbMax);
  521. STDAPI StgMakeUniqueName(IStorage *pStorageParent, LPCTSTR pszFileSpec, REFIID riid, void **ppv);
  522. STDAPI_(BOOL) PathIsImage(LPCTSTR pszFile);
  523. STDAPI_(BOOL) SHChangeMenuWasSentByMe(LPVOID self, LPCITEMIDLIST pidlNotify);
  524. STDAPI_(void) SHSendChangeMenuNotify(LPVOID self, DWORD shcnee, DWORD shcnf, LPCITEMIDLIST pidl2);
  525. STDAPI_(BOOL) Pidl_Set(LPITEMIDLIST* ppidl, LPCITEMIDLIST pidl);
  526. STDAPI GetHTMLDoc2(IUnknown *punk, struct IHTMLDocument2 **ppHtmlDoc);
  527. STDAPI LocalZoneCheck(IUnknown *punkSite);
  528. STDAPI LocalZoneCheckPath(LPCWSTR pszUrl, IUnknown *punkSite);
  529. STDAPI GetZoneFromUrl(LPCWSTR pszUrl, IUnknown * punkSite, DWORD * pdwZoneID);
  530. STDAPI GetZoneFromSite(IUnknown *punkSite, DWORD * pdwZoneID);
  531. STDAPI SHGetDefaultClientOpenCommandW(LPCWSTR pwszClientType,
  532. LPWSTR pwszClientCommand, DWORD dwCch,
  533. OPTIONAL LPWSTR pwszClientParams, DWORD dwCchParams);
  534. STDAPI SHGetDefaultClientNameW(LPCWSTR pwszClientType, LPWSTR pwszBuf, DWORD dwCch);
  535. //===========================================================================
  536. // Helper functions for pidl allocation using the task allocator.
  537. //
  538. STDAPI_(LPITEMIDLIST) _ILCreate(UINT cbSize);
  539. STDAPI SHILClone(LPCITEMIDLIST pidl, LPITEMIDLIST * ppidlOut);
  540. STDAPI SHILCombine(LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2, LPITEMIDLIST * ppidlOut);
  541. #define SHILFree(pidl) SHFree(pidl)
  542. //
  543. // DLL version helper macros
  544. //
  545. // To add DllGetVersion support to your DLL, do this:
  546. //
  547. // 1. foo.c
  548. //
  549. // DLLVER_SINGLEBINARY(VER_PRODUCTVERSION_DW, VER_PRODUCTBUILD_QFE);
  550. //
  551. // or
  552. //
  553. // DLLVER_DUALBINARY(VER_PRODUCTVERSION_DW, VER_PRODUCTBUILD_QFE);
  554. //
  555. // depending on whether you are a single-binary or dual-binary component.
  556. //
  557. // 2. foo.src:
  558. //
  559. // DllGetVersion = CCDllGetVersion ULTRAPRIVATE
  560. //
  561. // 3. sources:
  562. //
  563. // LINKLIBS = $(LINKLIBS) $(CCSHELL_DIR)\lib\$(O)\stocklib.lib
  564. //
  565. #define PRODUCTVER_GETMAJOR(ver) (((ver) & 0xFF000000) >> 24)
  566. #define PRODUCTVER_GETMINOR(ver) (((ver) & 0x00FF0000) >> 16)
  567. #define PRODUCTVER_GETBUILD(ver) (((ver) & 0x0000FFFF) >> 0)
  568. #define MAKEDLLVERULL_PRODUCTVERQFE(ver, qfe) \
  569. MAKEDLLVERULL(PRODUCTVER_GETMAJOR(ver), \
  570. PRODUCTVER_GETMINOR(ver), \
  571. PRODUCTVER_GETBUILD(ver), qfe)
  572. #define MAKE_DLLVER_STRUCT(ver, plat, qfe) \
  573. EXTERN_C const DLLVERSIONINFO2 c_dllver = { \
  574. { /* DLLVERSIONINFO */ \
  575. 0, /* cbSize */ \
  576. PRODUCTVER_GETMAJOR(ver), /* dwMajorVersion */ \
  577. PRODUCTVER_GETMINOR(ver), /* dwMinorVersion */ \
  578. PRODUCTVER_GETBUILD(ver), /* dwBuildNumber */ \
  579. plat, /* dwPlatformID */ \
  580. }, \
  581. 0, /* dwFlags */ \
  582. MAKEDLLVERULL_PRODUCTVERQFE(ver, qfe), /* ullVersion */ \
  583. }
  584. #define DLLVER_9xBINARY(ver, qfe) \
  585. MAKE_DLLVER_STRUCT(ver, DLLVER_PLATFORM_WINDOWS, qfe)
  586. #define DLLVER_NTBINARY(ver, qfe) \
  587. MAKE_DLLVER_STRUCT(ver, DLLVER_PLATFORM_NT, qfe)
  588. #define DLLVER_SINGLEBINARY DLLVER_9xBINARY
  589. #ifdef WINNT
  590. #define DLLVER_DUALBINARY DLLVER_NTBINARY
  591. #else
  592. #define DLLVER_DUALBINARY DLLVER_9xBINARY
  593. #endif
  594. STDAPI CCDllGetVersion(struct _DLLVERSIONINFO * pinfo);
  595. //
  596. // Mirroring-Support APIs (astracted in \shell\lib\stock5\rtlmir.cpp)
  597. //
  598. #ifdef __cplusplus
  599. extern "C" {
  600. #endif
  601. extern BOOL g_bMirroredOS;
  602. void EditBiDiDLGTemplate(LPDLGTEMPLATE pdt, DWORD dwFlags, PWORD pwIgnoreList, int cIgnore);
  603. #define EBDT_NOMIRROR 0x00000001
  604. #define EBDT_FLIP 0x00000002
  605. #ifdef USE_MIRRORING
  606. BOOL IsBiDiLocalizedSystem( void );
  607. BOOL IsBiDiLocalizedSystemEx( LANGID *pLangID );
  608. BOOL Mirror_IsEnabledOS( void );
  609. LANGID Mirror_GetUserDefaultUILanguage( void );
  610. BOOL Mirror_IsUILanguageInstalled( LANGID langId );
  611. BOOL CALLBACK Mirror_EnumUILanguagesProc(LPTSTR lpUILanguageString, LONG_PTR lParam);
  612. BOOL Mirror_IsWindowMirroredRTL( HWND hWnd );
  613. DWORD Mirror_IsDCMirroredRTL( HDC hdc );
  614. DWORD Mirror_MirrorDC( HDC hdc );
  615. BOOL Mirror_MirrorProcessRTL( void );
  616. DWORD Mirror_GetLayout( HDC hdc );
  617. DWORD Mirror_SetLayout( HDC hdc , DWORD dwLayout );
  618. BOOL Mirror_GetProcessDefaultLayout( DWORD *pdwDefaultLayout );
  619. BOOL Mirror_IsProcessRTL( void );
  620. extern const DWORD dwNoMirrorBitmap;
  621. extern const DWORD dwExStyleRTLMirrorWnd;
  622. extern const DWORD dwExStyleNoInheritLayout;
  623. extern const DWORD dwPreserveBitmap;
  624. //
  625. // 'g_bMirroredOS' is defined in each component which will use the
  626. // mirroring APIs. I decided to put it here, in order to make sure
  627. // each component has validated that the OS supports the mirroring
  628. // APIs before calling them.
  629. //
  630. #define GET_BIDI_LOCALIZED_SYSTEM_LANGID(pLangID) \
  631. IsBiDiLocalizedSystemEx(pLangID)
  632. #define IS_BIDI_LOCALIZED_SYSTEM() IsBiDiLocalizedSystem()
  633. #define IS_MIRRORING_ENABLED() Mirror_IsEnabledOS()
  634. #define IS_WINDOW_RTL_MIRRORED(hwnd) (g_bMirroredOS && Mirror_IsWindowMirroredRTL(hwnd))
  635. #define IS_DC_RTL_MIRRORED(hdc) (g_bMirroredOS && Mirror_IsDCMirroredRTL(hdc))
  636. #define GET_PROCESS_DEF_LAYOUT(pdwl) (g_bMirroredOS && Mirror_GetProcessDefaultLayout(pdwl))
  637. #define IS_PROCESS_RTL_MIRRORED() (g_bMirroredOS && Mirror_IsProcessRTL())
  638. #define SET_DC_RTL_MIRRORED(hdc) Mirror_MirrorDC(hdc)
  639. #define SET_DC_LAYOUT(hdc,dwl) Mirror_SetLayout(hdc,dwl)
  640. #define SET_PROCESS_RTL_LAYOUT() Mirror_MirrorProcessRTL()
  641. #define GET_DC_LAYOUT(hdc) Mirror_GetLayout(hdc)
  642. #define DONTMIRRORBITMAP dwNoMirrorBitmap
  643. #define RTL_MIRRORED_WINDOW dwExStyleRTLMirrorWnd
  644. #define RTL_NOINHERITLAYOUT dwExStyleNoInheritLayout
  645. #define LAYOUT_PRESERVEBITMAP dwPreserveBitmap
  646. #else
  647. #define GET_BIDI_LOCALIZED_SYSTEM_LANGID(pLangID) \
  648. FALSE
  649. #define IS_BIDI_LOCALIZED_SYSTEM() FALSE
  650. #define IS_MIRRORING_ENABLED() FALSE
  651. #define IS_WINDOW_RTL_MIRRORED(hwnd) FALSE
  652. #define IS_DC_RTL_MIRRORED(hdc) FALSE
  653. #define GET_PROCESS_DEF_LAYOUT(pdwl) FALSE
  654. #define IS_PROCESS_RTL_MIRRORED() FALSE
  655. #define SET_DC_RTL_MIRRORED(hdc)
  656. #define SET_DC_LAYOUT(hdc,dwl)
  657. #define SET_PROCESS_DEFAULT_LAYOUT()
  658. #define GET_DC_LAYOUT(hdc) 0L
  659. #define DONTMIRRORBITMAP 0L
  660. #define RTL_MIRRORED_WINDOW 0L
  661. #define LAYOUT_PRESERVEBITMAP 0L
  662. #define RTL_NOINHERITLAYOUT 0L
  663. #endif // USE_MIRRROING
  664. BOOL IsBiDiLocalizedWin95( BOOL bArabicOnly );
  665. //------------------------------------------------------------------------
  666. // Dynamic class array
  667. //
  668. typedef struct _DCA * HDCA; // hdca
  669. HDCA DCA_Create();
  670. void DCA_Destroy(HDCA hdca);
  671. int DCA_GetItemCount(HDCA hdca);
  672. BOOL DCA_AddItem(HDCA hdca, REFCLSID rclsid);
  673. const CLSID * DCA_GetItem(HDCA hdca, int i);
  674. void DCA_AddItemsFromKeyA(HDCA hdca, HKEY hkey, LPCSTR pszSubKey);
  675. void DCA_AddItemsFromKeyW(HDCA hdca, HKEY hkey, LPCWSTR pszSubKey);
  676. #ifdef UNICODE
  677. #define DCA_AddItemsFromKey DCA_AddItemsFromKeyW
  678. #else
  679. #define DCA_AddItemsFromKey DCA_AddItemsFromKeyA
  680. #endif
  681. STDAPI DCA_CreateInstance(HDCA hdca, int iItem, REFIID riid, void ** ppv);
  682. #ifdef __cplusplus
  683. };
  684. #endif
  685. #endif // RC_INVOKED
  686. //------------------------------------------------------------------------
  687. // Random helpful functions
  688. //------------------------------------------------------------------------
  689. //
  690. #define EDGE_LEFT 0x00000001
  691. #define EDGE_RIGHT 0x00000002
  692. #define EDGE_TOP 0x00000004
  693. #define EDGE_BOTTOM 0x00000008
  694. STDAPI_(DWORD) SHIsButtonObscured(HWND hwnd, PRECT prc, INT_PTR i);
  695. STDAPI_(void) _SHPrettyMenu(HMENU hm);
  696. STDAPI_(BOOL) _SHIsMenuSeparator(HMENU hm, int i);
  697. STDAPI_(BOOL) _SHIsMenuSeparator2(HMENU hm, int i, BOOL *pbIsNamed);
  698. STDAPI_(BYTE) SHBtnStateFromRestriction(DWORD dwRest, BYTE fsState);
  699. STDAPI_(BOOL) SHIsDisplayable(LPCWSTR pwszName, BOOL fRunOnFE, BOOL fRunOnNT5);
  700. #define SHProcessMessagesUntilEvent(hwnd, hEvent, dwTimeout) SHProcessMessagesUntilEventEx(hwnd, hEvent, dwTimeout, QS_ALLINPUT)
  701. #define SHProcessSentMessagesUntilEvent(hwnd, hEvent, dwTimeout) SHProcessMessagesUntilEventEx(hwnd, hEvent, dwTimeout, QS_SENDMESSAGE)
  702. STDAPI_(DWORD) SHProcessMessagesUntilEventEx(HWND hwnd, HANDLE hEvent, DWORD dwTimeout, DWORD dwWakeMask);
  703. STDAPI_(BOOL) SetWindowZorder(HWND hwnd, HWND hwndInsertAfter);
  704. STDAPI_(BOOL) SHForceWindowZorder(HWND hwnd, HWND hwndInsertAfter);
  705. STDAPI_(void) EnableOKButtonFromString(HWND hDlg, LPTSTR pszText);
  706. STDAPI_(void) EnableOKButtonFromID(HWND hDlg, int id);
  707. STDAPI_(void) AlphaStripRenderIcon(HDC hdc, int x, int y, HICON hicon, HDC hdcCompatible);
  708. STDAPI_(void) SHAdjustLOGFONTA(IN OUT LOGFONTA *plf);
  709. STDAPI_(void) SHAdjustLOGFONTW(IN OUT LOGFONTW *plf);
  710. #ifdef UNICODE
  711. #define SHAdjustLOGFONT SHAdjustLOGFONTW
  712. #else
  713. #define SHAdjustLOGFONT SHAdjustLOGFONTA
  714. #endif
  715. STDAPI SHLoadLegacyRegUIStringA(HKEY hk, LPCSTR pszSubkey, LPSTR pszOutBuf, UINT cchOutBuf);
  716. STDAPI SHLoadLegacyRegUIStringW(HKEY hk, LPCWSTR pszSubkey, LPWSTR pszOutBuf, UINT cchOutBuf);
  717. #ifdef UNICODE
  718. #define SHLoadLegacyRegUIString SHLoadLegacyRegUIStringW
  719. #else
  720. #define SHLoadLegacyRegUIString SHLoadLegacyRegUIStringA
  721. #endif
  722. // These 2 functions determine whether a registry subkey exists by
  723. // trying to open and close the key using the KEY_QUERY_VALUE sam.
  724. STDAPI_(BOOL) SHRegSubKeyExistsA(HKEY hkey, PCSTR pszSubKey); // DO NOT MAKE PUBLIC IN SHLWAPI: use SHRegGetValue() directly
  725. STDAPI_(BOOL) SHRegSubKeyExistsW(HKEY hkey, PCWSTR pwszSubKey); // DO NOT MAKE PUBLIC IN SHLWAPI: use SHRegGetValue() directly
  726. STDAPI SHRegGetDWORDA( HKEY hkey, PCSTR pszSubKey, PCSTR pszValue, DWORD *pdwData); // DO NOT MAKE PUBLIC IN SHLWAPI: use SHRegGetValue() directly
  727. STDAPI SHRegGetDWORDW( HKEY hkey, PCWSTR pwszSubKey, PCWSTR pwszValue, DWORD *pdwData); // DO NOT MAKE PUBLIC IN SHLWAPI: use SHRegGetValue() directly
  728. STDAPI SHRegGetStringA( HKEY hkey, PCSTR pszSubKey, PCSTR pszValue, PSTR pszData, DWORD cchData); // DO NOT MAKE PUBLIC IN SHLWAPI: use SHRegGetValue() directly
  729. STDAPI SHRegGetStringW( HKEY hkey, PCWSTR pwszSubKey, PCWSTR pwszValue, PWSTR pwszData, DWORD cchData); // DO NOT MAKE PUBLIC IN SHLWAPI: use SHRegGetValue() directly
  730. STDAPI SHRegAllocStringA( HKEY hkey, PCSTR pszSubKey, PCSTR pszValue, PSTR * ppszData); // DO NOT MAKE PUBLIC IN SHLWAPI: use SHRegGetValue() directly
  731. STDAPI SHRegAllocStringW( HKEY hkey, PCWSTR pwszSubKey, PCWSTR pwszValue, PWSTR *ppwszData); // DO NOT MAKE PUBLIC IN SHLWAPI: use SHRegGetValue() directly
  732. #ifdef UNICODE
  733. #define SHRegSubKeyExists SHRegSubKeyExistsW
  734. #define SHRegGetDWORD SHRegGetDWORDW
  735. #define SHRegGetString SHRegGetStringW
  736. #define SHRegAllocString SHRegAllocStringW
  737. #else
  738. #define SHRegSubKeyExists SHRegSubKeyExistsA
  739. #define SHRegGetDWORD SHRegGetDWORDA
  740. #define SHRegGetString SHRegGetStringA
  741. #define SHRegAllocString SHRegAllocStringA
  742. #endif
  743. STDAPI_(CHAR) SHFindMnemonicA(LPCSTR psz);
  744. STDAPI_(WCHAR) SHFindMnemonicW(LPCWSTR psz);
  745. #ifdef UNICODE
  746. #define SHFindMnemonic SHFindMnemonicW
  747. #else
  748. #define SHFindMnemonic SHFindMnemonicA
  749. #endif
  750. typedef struct tagINSTALL_INFO
  751. {
  752. LPTSTR szSource;
  753. LPTSTR szDest;
  754. DWORD dwDestAttrib;
  755. } INSTALL_INFO;
  756. //
  757. // Special attributes in INSTALL_INFO.dwDestAttrib. We use attributes
  758. // that we would never otherwise use.
  759. //
  760. #define FILE_ATTRIBUTE_INSTALL_NTONLY FILE_ATTRIBUTE_DEVICE
  761. #define FILE_ATTRIBUTE_INSTALL_9XONLY FILE_ATTRIBUTE_TEMPORARY
  762. // superhidden files are attrib'ed +h +s
  763. #define FILE_ATTRIBUTE_SUPERHIDDEN (FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN)
  764. #define IS_SYSTEM_HIDDEN(dw) ((dw & FILE_ATTRIBUTE_SUPERHIDDEN) == FILE_ATTRIBUTE_SUPERHIDDEN)
  765. STDAPI GetInstallInfoFromResource(HINSTANCE hResourceInst, UINT uID, INSTALL_INFO *piiFile);
  766. STDAPI InstallInfoFreeMembers(INSTALL_INFO *piiFile);
  767. STDAPI InstallFileFromResource(HINSTANCE hInstResource, INSTALL_INFO *piiFile, LPCTSTR pszDestDir);
  768. #ifndef OBJCOMPATFLAGS
  769. typedef DWORD OBJCOMPATFLAGS;
  770. #endif
  771. STDAPI_(OBJCOMPATFLAGS) SHGetObjectCompatFlagsFromIDList(LPCITEMIDLIST pidl);
  772. #define ROUS_DEFAULTALLOW 0x0000
  773. #define ROUS_DEFAULTRESTRICT 0x0001
  774. #define ROUS_KEYALLOWS 0x0000
  775. #define ROUS_KEYRESTRICTS 0x0002
  776. STDAPI_(BOOL) IsRestrictedOrUserSettingA(HKEY hkeyRoot, enum RESTRICTIONS rest, LPCSTR pszSubKey, LPCSTR pszValue, UINT flags);
  777. STDAPI_(BOOL) IsRestrictedOrUserSettingW(HKEY hkeyRoot, enum RESTRICTIONS rest, LPCWSTR pszSubKey, LPCWSTR pszValue, UINT flags);
  778. STDAPI_(BOOL) GetExplorerUserSettingA(HKEY hkeyRoot, LPCTSTR pszSubKey, LPCTSTR pszValue);
  779. STDAPI_(BOOL) GetExplorerUserSettingW(HKEY hkeyRoot, LPCTSTR pszSubKey, LPCTSTR pszValue);
  780. #ifdef UNICODE
  781. #define IsRestrictedOrUserSetting IsRestrictedOrUserSettingW
  782. #define GetExplorerUserSetting GetExplorerUserSettingW
  783. #else
  784. #define IsRestrictedOrUserSetting IsRestrictedOrUserSettingA
  785. #define GetExplorerUserSetting GetExplorerUserSettingA
  786. #endif
  787. //
  788. // PropertBag helpers
  789. STDAPI_(void) SHPropertyBag_ReadStrDef(IPropertyBag* ppb, LPCWSTR pszPropName, LPWSTR psz, int cch, LPCWSTR pszDef);
  790. STDAPI_(void) SHPropertyBag_ReadIntDef(IPropertyBag* ppb, LPCWSTR pszPropName, int* piResult, int iDef);
  791. STDAPI_(void) SHPropertyBag_ReadSHORTDef(IPropertyBag* ppb, LPCWSTR pszPropName, SHORT* psh, SHORT shDef);
  792. STDAPI_(void) SHPropertyBag_ReadLONGDef(IPropertyBag* ppb, LPCWSTR pszPropName, LONG* pl, LONG lDef);
  793. STDAPI_(void) SHPropertyBag_ReadDWORDDef(IPropertyBag* ppb, LPCWSTR pszPropName, DWORD* pdw, DWORD dwDef);
  794. STDAPI_(void) SHPropertyBag_ReadBOOLDef(IPropertyBag* ppb, LPCWSTR pszPropName, BOOL* pf, BOOL fDef);
  795. STDAPI_(void) SHPropertyBag_ReadGUIDDef(IPropertyBag* ppb, LPCWSTR pszPropName, GUID* pguid, const GUID* pguidDef);
  796. STDAPI_(void) SHPropertyBag_ReadPOINTLDef(IPropertyBag* ppb, LPCWSTR pszPropName, POINTL* ppt, const POINTL* pptDef);
  797. STDAPI_(void) SHPropertyBag_ReadPOINTSDef(IPropertyBag* ppb, LPCWSTR pszPropName, POINTS* ppt, const POINTS* pptDef);
  798. STDAPI_(void) SHPropertyBag_ReadRECTLDef(IPropertyBag* ppb, LPCWSTR pszPropName, RECTL* prc, const RECTL* prcDef);
  799. STDAPI_(BOOL) SHPropertyBag_ReadBOOLDefRet(IPropertyBag* ppb, LPCWSTR pszPropName, BOOL fDef);
  800. STDAPI SHPropertyBag_ReadStreamScreenRes(IPropertyBag* ppb, LPCWSTR pszPropName, IStream** ppstm);
  801. STDAPI SHPropertyBag_WriteStreamScreenRes(IPropertyBag* ppb, LPCWSTR pszPropName, IStream* pstm);
  802. STDAPI SHPropertyBag_ReadPOINTSScreenRes(IPropertyBag* ppb, LPCWSTR pszPropName, POINTS* ppt);
  803. STDAPI SHPropertyBag_WritePOINTSScreenRes(IPropertyBag* ppb, LPCWSTR pszPropName, const POINTS* ppt);
  804. STDAPI_(void) SHPropertyBag_ReadDWORDScreenResDef(IPropertyBag* ppb, LPCWSTR pszPropName, DWORD* pdw, DWORD dwDef);
  805. STDAPI SHPropertyBag_WriteDWORDScreenRes(IPropertyBag* ppb, LPCWSTR pszPropName, DWORD dw);
  806. STDAPI SHPropertyBag_ReadPOINTLScreenRes(IPropertyBag* ppb, LPCWSTR pszPropName, POINTL* ppt);
  807. STDAPI SHPropertyBag_WritePOINTLScreenRes(IPropertyBag* ppb, LPCWSTR pszPropName, const POINTL* ppt);
  808. STDAPI SHPropertyBag_ReadRECTLScreenRes(IPropertyBag* ppb, LPCWSTR pszPropName, RECTL* prc);
  809. STDAPI SHPropertyBag_WriteRECTLScreenRes(IPropertyBag* ppb, LPCWSTR pszPropName, const RECTL* prc);
  810. STDAPI SHPropertyBag_DeleteScreenRes(IPropertyBag* ppb, LPCWSTR pszPropName);
  811. #define VS_BAGSTR_EXPLORER L"Shell"
  812. #define VS_BAGSTR_DESKTOP L"Desktop"
  813. #define VS_BAGSTR_COMCLG L"ComDlg"
  814. #define VS_PROPSTR_MINPOS L"MinPos"
  815. #define VS_PROPSTR_MAXPOS L"MaxPos"
  816. #define VS_PROPSTR_POS L"WinPos"
  817. #define VS_PROPSTR_MODE L"Mode"
  818. #define VS_PROPSTR_REV L"Rev"
  819. #define VS_PROPSTR_WPFLAGS L"WFlags"
  820. #define VS_PROPSTR_SHOW L"ShowCmd"
  821. #define VS_PROPSTR_FFLAGS L"FFlags"
  822. #define VS_PROPSTR_HOTKEY L"HotKey"
  823. #define VS_PROPSTR_BUTTONS L"Buttons"
  824. #define VS_PROPSTR_STATUS L"Status"
  825. #define VS_PROPSTR_LINKS L"Links"
  826. #define VS_PROPSTR_ADDRESS L"Address"
  827. #define VS_PROPSTR_VID L"Vid"
  828. #define VS_PROPSTR_SCROLL L"ScrollPos"
  829. #define VS_PROPSTR_SORT L"Sort"
  830. #define VS_PROPSTR_SORTDIR L"SortDir"
  831. #define VS_PROPSTR_COL L"Col"
  832. #define VS_PROPSTR_COLINFO L"ColInfo"
  833. #define VS_PROPSTR_ITEMPOS L"ItemPos"
  834. //------------------------------------------------------------------------
  835. ////////////////
  836. //
  837. // Critical section stuff
  838. //
  839. // Helper macros that give nice debug support
  840. //
  841. EXTERN_C CRITICAL_SECTION g_csDll;
  842. #ifdef DEBUG
  843. EXTERN_C UINT g_CriticalSectionCount;
  844. EXTERN_C DWORD g_CriticalSectionOwner;
  845. EXTERN_C void Dll_EnterCriticalSection(CRITICAL_SECTION*);
  846. EXTERN_C void Dll_LeaveCriticalSection(CRITICAL_SECTION*);
  847. #if defined(__cplusplus) && defined(AssertMsg)
  848. class DEBUGCRITICAL {
  849. protected:
  850. BOOL fClosed;
  851. public:
  852. DEBUGCRITICAL() {fClosed = FALSE;};
  853. void Leave() {fClosed = TRUE;};
  854. ~DEBUGCRITICAL()
  855. {
  856. AssertMsg(fClosed, TEXT("you left scope while holding the critical section"));
  857. }
  858. };
  859. #define ENTERCRITICAL DEBUGCRITICAL debug_crit; Dll_EnterCriticalSection(&g_csDll)
  860. #define LEAVECRITICAL debug_crit.Leave(); Dll_LeaveCriticalSection(&g_csDll)
  861. #define ENTERCRITICALNOASSERT Dll_EnterCriticalSection(&g_csDll)
  862. #define LEAVECRITICALNOASSERT Dll_LeaveCriticalSection(&g_csDll)
  863. #else // __cplusplus
  864. #define ENTERCRITICAL Dll_EnterCriticalSection(&g_csDll)
  865. #define LEAVECRITICAL Dll_LeaveCriticalSection(&g_csDll)
  866. #define ENTERCRITICALNOASSERT Dll_EnterCriticalSection(&g_csDll)
  867. #define LEAVECRITICALNOASSERT Dll_LeaveCriticalSection(&g_csDll)
  868. #endif // __cplusplus
  869. #define ASSERTCRITICAL ASSERT(g_CriticalSectionCount > 0 && GetCurrentThreadId() == g_CriticalSectionOwner)
  870. #define ASSERTNONCRITICAL ASSERT(GetCurrentThreadId() != g_CriticalSectionOwner)
  871. #else // DEBUG
  872. #define ENTERCRITICAL EnterCriticalSection(&g_csDll)
  873. #define LEAVECRITICAL LeaveCriticalSection(&g_csDll)
  874. #define ENTERCRITICALNOASSERT EnterCriticalSection(&g_csDll)
  875. #define LEAVECRITICALNOASSERT LeaveCriticalSection(&g_csDll)
  876. #define ASSERTCRITICAL
  877. #define ASSERTNONCRITICAL
  878. #endif // DEBUG
  879. ////////////////
  880. //
  881. // computer display name support
  882. //
  883. // Display name: A formatted name that NetFldr uses. It is currently constructed out of the computer name,
  884. // and, if available, the computer comment (description).
  885. // DSheldon
  886. STDAPI SHBuildDisplayMachineName(LPCWSTR pszMachineName, LPCWSTR pszComment, LPWSTR pszDisplayName, DWORD cchDisplayName);
  887. STDAPI CreateFromRegKey(LPCWSTR pszKey, LPCWSTR pszValue, REFIID riid, void **ppv);
  888. STDAPI_(LPCTSTR) SkipServerSlashes(LPCTSTR pszName);
  889. //
  890. // A couple of inline functions that create an HRESULT from
  891. // a Win32 error code without the double-evaluation side effect of
  892. // the HRESULT_FROM_WIN32 macro.
  893. //
  894. // Use ResultFromWin32 in place of HRESULT_FROM_WIN32 if
  895. // the side effects of that macro are unwanted.
  896. // ResultFromLastError was created as a convenience for a
  897. // common idiom.
  898. // You could simply call ResultFromWin32(GetLastError()) yourself.
  899. //
  900. __inline HRESULT ResultFromWin32(DWORD dwErr)
  901. {
  902. return HRESULT_FROM_WIN32(dwErr);
  903. }
  904. __inline HRESULT ResultFromLastError(void)
  905. {
  906. return ResultFromWin32(GetLastError());
  907. }
  908. STDAPI_(void) IEPlaySound(LPCTSTR pszSound, BOOL fSysSound);
  909. STDAPI IUnknown_DragEnter(IUnknown* punk, IDataObject *pdtobj, DWORD grfKeyState, POINTL pt, DWORD *pdwEffect);
  910. STDAPI IUnknown_DragOver(IUnknown* punk, DWORD grfKeyState, POINTL pt, DWORD *pdwEffect);
  911. STDAPI IUnknown_DragLeave(IUnknown* punk);
  912. STDAPI IUnknown_Drop(IUnknown* punk, IDataObject *pdtobj, DWORD grfKeyState, POINTL pt, DWORD *pdwEffect);
  913. STDAPI_(BOOL) IsTypeInList(LPCTSTR pszType, const LPCTSTR *arszList, UINT cList);
  914. //----------------------------------------------------------------------
  915. // Msg: WM_MSIME_MODEBIAS
  916. // Desc: input mode bias
  917. // Owner: YutakaN
  918. // Usage: SendMessage( hwndDefUI, WM_MSIME_MODEBIAS, MODEBIAS_xxxx, MODEBIASMODE_xxxx );
  919. // wParam: operation of bias
  920. // lParam: bias mode
  921. // return: If wParam is MODEBIAS_GETVERSION,returns version number of interface.
  922. // If wParam is MODEBIAS_SETVALUE : return non-zero value if succeeded. Returns 0 if fail.
  923. // If wParam is MODEBIAS_GETVALUE : returns current bias mode.
  924. // Label for RegisterWindowMessage
  925. #define RWM_MODEBIAS TEXT("MSIMEModeBias")
  926. // Current version
  927. #define VERSION_MODEBIAS 1
  928. // Set or Get (wParam)
  929. #define MODEBIAS_GETVERSION 0
  930. #define MODEBIAS_SETVALUE 1
  931. #define MODEBIAS_GETVALUE 2
  932. // Bias (lParam)
  933. #define MODEBIASMODE_DEFAULT 0x00000000 // reset all of bias setting
  934. #define MODEBIASMODE_FILENAME 0x00000001 // filename
  935. #define MODEBIASMODE_READING 0x00000002 // reading recommended
  936. #define MODEBIASMODE_DIGIT 0x00000004 // ANSI-Digit Recommended Mode
  937. #define MODEBIASMODE_URLHISTORY 0x00010000 // URL history
  938. STDAPI_(void) SetModeBias(DWORD dwMode);
  939. #endif // __CCSTOCK_H__