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.

120 lines
3.0 KiB

  1. //+---------------------------------------------------------------------
  2. //
  3. // File: misc.cxx
  4. //
  5. // Contents: Useful OLE helper and debugging functions
  6. //
  7. //----------------------------------------------------------------------
  8. #include "procs.hxx"
  9. //+------------------------------------------------------------------------
  10. //
  11. // Function: GetLastWin32Error
  12. //
  13. // Synopsis: Returns the last Win32 error, converted to an HRESULT.
  14. //
  15. // Returns: HRESULT
  16. //
  17. //-------------------------------------------------------------------------
  18. HRESULT
  19. GetLastWin32Error( )
  20. {
  21. return HRESULT_FROM_WIN32(GetLastError());
  22. }
  23. #if DBG == 1
  24. //+---------------------------------------------------------------
  25. //
  26. // Function: TraceIID
  27. //
  28. // Synopsis: Outputs the name of the interface to the debugging device
  29. //
  30. // Arguments: [riid] -- the interface
  31. //
  32. // Notes: This function disappears in retail builds.
  33. //
  34. //----------------------------------------------------------------
  35. STDAPI_(void)
  36. PrintIID(DWORD dwFlags, REFIID riid)
  37. {
  38. LPWSTR lpstr = NULL;
  39. #define CASE_IID(iid) \
  40. if (IsEqualIID(IID_##iid, riid)) lpstr = (LPWSTR)L#iid;
  41. CASE_IID(IUnknown)
  42. CASE_IID(IOleLink)
  43. CASE_IID(IOleCache)
  44. CASE_IID(IOleManager)
  45. CASE_IID(IOlePresObj)
  46. CASE_IID(IDebug)
  47. CASE_IID(IDebugStream)
  48. CASE_IID(IAdviseSink2)
  49. CASE_IID(IDataObject)
  50. CASE_IID(IViewObject)
  51. CASE_IID(IOleObject)
  52. CASE_IID(IOleInPlaceObject)
  53. CASE_IID(IParseDisplayName)
  54. CASE_IID(IOleContainer)
  55. CASE_IID(IOleItemContainer)
  56. CASE_IID(IOleClientSite)
  57. CASE_IID(IOleInPlaceSite)
  58. CASE_IID(IPersist)
  59. CASE_IID(IPersistStorage)
  60. CASE_IID(IPersistFile)
  61. CASE_IID(IPersistStream)
  62. CASE_IID(IOleClientSite)
  63. CASE_IID(IOleInPlaceSite)
  64. CASE_IID(IAdviseSink)
  65. CASE_IID(IDataAdviseHolder)
  66. CASE_IID(IOleAdviseHolder)
  67. CASE_IID(IClassFactory)
  68. CASE_IID(IOleWindow)
  69. CASE_IID(IOleInPlaceActiveObject)
  70. CASE_IID(IOleInPlaceUIWindow)
  71. CASE_IID(IOleInPlaceFrame)
  72. CASE_IID(IDropSource)
  73. CASE_IID(IDropTarget)
  74. CASE_IID(IBindCtx)
  75. CASE_IID(IEnumUnknown)
  76. CASE_IID(IEnumString)
  77. CASE_IID(IEnumFORMATETC)
  78. CASE_IID(IEnumSTATDATA)
  79. CASE_IID(IEnumOLEVERB)
  80. CASE_IID(IEnumMoniker)
  81. CASE_IID(IEnumGeneric)
  82. CASE_IID(IEnumHolder)
  83. CASE_IID(IEnumCallback)
  84. CASE_IID(ILockBytes)
  85. CASE_IID(IStorage)
  86. CASE_IID(IStream)
  87. CASE_IID(IDispatch)
  88. CASE_IID(IMarshal)
  89. //CASE_IID(IEnumVARIANT)
  90. //CASE_IID(ITypeInfo)
  91. //CASE_IID(ITypeLib)
  92. //CASE_IID(ITypeComp)
  93. //CASE_IID(ICreateTypeInfo)
  94. //CASE_IID(ICreateTypeLib)
  95. #undef CASE_IID
  96. if (lpstr == NULL)
  97. {
  98. WCHAR chBuf[256];
  99. StringFromGUID2(riid, chBuf, 256);
  100. ADsDebugOut((dwFlags | DEB_NOCOMPNAME,
  101. "UNKNOWN ITF %ws", chBuf));
  102. }
  103. else
  104. ADsDebugOut((dwFlags | DEB_NOCOMPNAME, "%ws", lpstr));
  105. }
  106. #endif // DBG == 1