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.

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