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.

180 lines
4.9 KiB

  1. //
  2. // MODULE: FUNCTIONS.H
  3. //
  4. // PURPOSE: Decodes the the variant structures.
  5. //
  6. // PROJECT: Generic Troubleshooter DLL for Microsoft AnswerPoint
  7. //
  8. // COMPANY: Saltmine Creative, Inc. (206)-633-4743 [email protected]
  9. //
  10. // AUTHOR: Richard Meadows
  11. ///
  12. // ORIGINAL DATE: 6/4/96
  13. //
  14. // NOTES:
  15. // 1.
  16. //
  17. // Version Date By Comments
  18. //--------------------------------------------------------------------
  19. // V0.1 - RM Original
  20. // V0.3 3/24/98 JM Local Version for NT5
  21. //
  22. #ifndef __FUNCTIONS_H_
  23. #define __FUNCTIONS_H_ 1
  24. inline CString GlobFormatMessage(DWORD dwLastError)
  25. {
  26. CString strMessage;
  27. void *lpvMessage;
  28. FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
  29. NULL,
  30. dwLastError,
  31. MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US),
  32. (LPTSTR) &lpvMessage, 0, NULL);
  33. strMessage = (LPCTSTR) lpvMessage;
  34. LocalFree(lpvMessage);
  35. return strMessage;
  36. }
  37. inline CString DecodeVariantTypes(VARTYPE vt)
  38. {
  39. CString str = _T("");
  40. if (VT_EMPTY == vt)
  41. str = _T("Empty ");
  42. else if(VT_ILLEGAL == vt)
  43. str = _T("ILLEGAL ");
  44. else if(VT_ILLEGALMASKED == vt)
  45. str = _T("ILLEGALMASKED ");
  46. else
  47. {
  48. if (VT_VECTOR == (VT_VECTOR & vt))
  49. str += _T("VECTOR ");
  50. if (VT_ARRAY == (VT_ARRAY & vt))
  51. str += _T("ARRAY ");
  52. if (VT_BYREF == (VT_BYREF & vt))
  53. str += _T("BYREF ");
  54. if (VT_RESERVED == (VT_RESERVED & vt))
  55. str += _T("RESERVED ");
  56. if (VT_TYPEMASK == (VT_TYPEMASK & vt))
  57. str += _T("TYPEMASK ");
  58. vt &= 0xFFF;
  59. if (VT_NULL == vt)
  60. str += _T("Null ");
  61. if (VT_I2 == vt)
  62. str += _T("I2 ");
  63. if (VT_I4 == vt)
  64. str += _T("I4 ");
  65. if (VT_R4 == vt)
  66. str += _T("R4 ");
  67. if (VT_R8 == vt)
  68. str += _T("R8 ");
  69. if (VT_CY == vt)
  70. str += _T("CY ");
  71. if (VT_DATE == vt)
  72. str += _T("DATE ");
  73. if (VT_BSTR == vt)
  74. str += _T("BSTR ");
  75. if (VT_DISPATCH == vt)
  76. str += _T("DISPATCH ");
  77. if (VT_ERROR == vt)
  78. str += _T("ERROR ");
  79. if (VT_BOOL == vt)
  80. str += _T("BOOL ");
  81. if (VT_VARIANT == vt)
  82. str += _T("VARIANT ");
  83. if (VT_UNKNOWN == vt)
  84. str += _T("UNKNOWN ");
  85. if (VT_DECIMAL == vt)
  86. str += _T("DECIMAL ");
  87. if (VT_I1 == vt)
  88. str += _T("I1 ");
  89. if (VT_UI1 == vt)
  90. str += _T("UI1 ");
  91. if (VT_UI2 == vt)
  92. str += _T("UI2 ");
  93. if (VT_UI4 == vt)
  94. str += _T("UI4 ");
  95. if (VT_I8 == vt)
  96. str += _T("I8 ");
  97. if (VT_UI8 == vt)
  98. str += _T("UI8 ");
  99. if (VT_INT == vt)
  100. str += _T("INT ");
  101. if (VT_UINT == vt)
  102. str += _T("UINT ");
  103. if (VT_VOID == vt)
  104. str += _T("VOID ");
  105. if (VT_HRESULT == vt)
  106. str += _T("HRESULT ");
  107. if (VT_PTR == vt)
  108. str += _T("PTR ");
  109. if (VT_SAFEARRAY == vt)
  110. str += _T("SAFEARRAY ");
  111. if (VT_CARRAY == vt)
  112. str += _T("CARRAY ");
  113. if (VT_USERDEFINED == vt)
  114. str += _T("USERDEFINED ");
  115. if (VT_LPSTR == vt)
  116. str += _T("LPSTR ");
  117. if (VT_LPWSTR == vt)
  118. str += _T("LPWSTR ");
  119. if (VT_FILETIME == vt)
  120. str += _T("FILETIME ");
  121. if (VT_BLOB == vt)
  122. str += _T("BLOB ");
  123. if (VT_STREAM == vt)
  124. str += _T("STREAM ");
  125. if (VT_STORAGE == vt)
  126. str += _T("STORAGE ");
  127. if (VT_STREAMED_OBJECT == vt)
  128. str += _T("STREAMED_OBJECT ");
  129. if (VT_STORED_OBJECT == vt)
  130. str += _T("STORED_OBJECT ");
  131. if (VT_BLOB_OBJECT == vt)
  132. str += _T("BLOB_OBJECT ");
  133. if (VT_CF == vt)
  134. str += _T("CF ");
  135. if (VT_CLSID == vt)
  136. str += _T("CLSID ");
  137. }
  138. return str;
  139. }
  140. inline CString DecodeSafeArray(unsigned short Features)
  141. {
  142. /*
  143. #define FADF_AUTO 0x0001 // Array is allocated on the stack.
  144. #define FADF_STATIC 0x0002 // Array is statically allocated.
  145. #define FADF_EMBEDDED 0x0004 // Array is embedded in a structure.
  146. #define FADF_FIXEDSIZE 0x0010 // Array may not be resized or
  147. // reallocated.
  148. #define FADF_BSTR 0x0100 // An array of BSTRs.
  149. #define FADF_UNKNOWN 0x0200 // An array of IUnknown*.
  150. #define FADF_DISPATCH 0x0400 // An array of IDispatch*.
  151. #define FADF_VARIANT 0x0800 // An array of VARIANTs.
  152. #define FADF_RESERVED 0xF0E8 // Bits reserved for future use.
  153. */
  154. CString str = _T("");
  155. if (FADF_AUTO == (FADF_AUTO & Features))
  156. str += _T("Array is allocated on the stack.\n");
  157. if (FADF_STATIC == (FADF_STATIC & Features))
  158. str += _T("Array is statically allocated.\n");
  159. if (FADF_EMBEDDED == (FADF_EMBEDDED & Features))
  160. str += _T("Array is embedded in a structure.\n");
  161. if (FADF_FIXEDSIZE == (FADF_FIXEDSIZE & Features))
  162. str += _T("Array may not be resized of reallocated.\n");
  163. if (FADF_BSTR == (FADF_BSTR & Features))
  164. str += _T("An array of BSTRs.\n");
  165. if (FADF_UNKNOWN == (FADF_UNKNOWN & Features))
  166. str += _T("An array of IUnknown.\n");
  167. if (FADF_DISPATCH == (FADF_DISPATCH & Features))
  168. str += _T("An array of IDispatch.\n");
  169. if (FADF_VARIANT == (FADF_VARIANT & Features))
  170. str += _T("An array of VARIANTS.\n");
  171. if (FADF_RESERVED == (FADF_RESERVED & Features))
  172. str+= _T("Array is using all of the reserved bits.\n");
  173. return str;
  174. }
  175. #endif