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.

90 lines
2.2 KiB

  1. #ifndef __OLEBIND_HXX__
  2. #define __OLEBIND_HXX__
  3. #include <safepnt.hxx>
  4. // safe ptrs so we release interfaces in error paths
  5. SAFE_INTERFACE_PTR(XUnknown, IUnknown)
  6. SAFE_INTERFACE_PTR(XBindCtx, IBindCtx)
  7. SAFE_INTERFACE_PTR(XMoniker, IMoniker)
  8. SAFE_INTERFACE_PTR(XStream, IStream)
  9. SAFE_INTERFACE_PTR(XMalloc, IMalloc)
  10. SAFE_INTERFACE_PTR(XOleObject, IOleObject)
  11. SAFE_INTERFACE_PTR(XRunningObjectTable, IRunningObjectTable)
  12. SAFE_INTERFACE_PTR(XEnumMoniker, IEnumMoniker)
  13. SAFE_INTERFACE_PTR(XOleItemContainer, IOleItemContainer)
  14. SAFE_INTERFACE_PTR(XDispatch, IDispatch)
  15. // string version of process id
  16. extern WCHAR wszPid[10];
  17. #define LAST_RELEASE(x) \
  18. { \
  19. ULONG cnt = x->Release(); \
  20. x.Detach(); \
  21. LPSTR pname = #x; \
  22. if (cnt) \
  23. { \
  24. printf("%s:%d %s still has refs = %ld\n", __FILE__, __LINE__, \
  25. pname, cnt); \
  26. } \
  27. }
  28. #define DISPLAY_REFS(x) \
  29. { \
  30. x->AddRef(); \
  31. ULONG cnt = x->Release(); \
  32. LPSTR pname = #x; \
  33. printf("%s refs = %ld\n", pname, cnt); \
  34. }
  35. extern const char *szOleBindError;
  36. extern char wszErrBuf[];
  37. // Failure return macro to be used when you are not interested in an
  38. // HRESULT.
  39. #define TEST_FAILED(x, y) \
  40. if (x) \
  41. { \
  42. wsprintfA(&wszErrBuf[0], "%s:%d %s", __FILE__, __LINE__, y); \
  43. MessageBoxA(NULL, &wszErrBuf[0], szOleBindError, MB_OK); \
  44. return TRUE; \
  45. }
  46. // Failure return macro to be used when you have an interesting HRESULT
  47. // to return.
  48. #define TEST_FAILED_HR(x, y) \
  49. if (x) \
  50. { \
  51. wsprintfA(&wszErrBuf[0], "%s:%d %s HRESULT = %lx", __FILE__, __LINE__, y, hr); \
  52. MessageBoxA(NULL, &wszErrBuf[0], szOleBindError, MB_OK); \
  53. return TRUE; \
  54. }
  55. // Failure return macro to be used when you have an interesting HRESULT
  56. // to return.
  57. #define TEST_FAILED_LAST_ERROR(x, y) \
  58. if (x) \
  59. { \
  60. wsprintfA(&wszErrBuf[0], "%s:%d %s Error = %lx",\
  61. __FILE__, __LINE__, y, GetLastError()); \
  62. MessageBoxA(NULL, &wszErrBuf[0], szOleBindError, MB_OK); \
  63. return TRUE; \
  64. }
  65. extern WCHAR LongDir[MAX_PATH];
  66. extern WCHAR LongDirShort[MAX_PATH];
  67. extern WCHAR LongDirLong[MAX_PATH];
  68. extern WCHAR LongDirLongSe[MAX_PATH];
  69. // Test standard IMalloc interface
  70. BOOL TestStdMalloc(void);
  71. #endif // __OLEBIND_HXX__