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.

165 lines
5.0 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1997 - 1998
  6. //
  7. // File: format.h
  8. //
  9. //--------------------------------------------------------------------------
  10. #ifndef _FORMAT_H_
  11. #define _FORMAT_H_
  12. #define FSEFLAG_SYSMESSAGE 0x00000001
  13. #define FSEFLAG_MPRMESSAGE 0x00000002
  14. #define FSEFLAG_ANYMESSAGE 0x00000003
  15. #define FDFLAG_MSECONDS 0x00000001
  16. #define FDFLAG_SECONDS 0x00000002
  17. #define FDFLAG_MINUTES 0x00000004
  18. #define FDFLAG_HOURS 0x00000008
  19. #define FDFLAG_DAYS 0x00000010
  20. #define FDFLAG_ALL 0x0000001F
  21. /*!--------------------------------------------------------------------------
  22. DisplayErrorMessage
  23. This function will call FormatSystemError() on the hr value and
  24. display that error text.
  25. Author: KennT
  26. ---------------------------------------------------------------------------*/
  27. void DisplayErrorMessage(HWND hWndParent, HRESULT hr);
  28. /*!--------------------------------------------------------------------------
  29. DisplayStringErrorMessage2
  30. DisplayIdErrorMessage2
  31. This function will call FormatSystemError() on the hr. But will
  32. prepend the pszTopLevelText onto that error. This allows us
  33. to show more descriptive error messages.
  34. Author: KennT
  35. ---------------------------------------------------------------------------*/
  36. void DisplayStringErrorMessage2(HWND hWndParent, LPCTSTR pszTopLevelText, HRESULT hr);
  37. void DisplayIdErrorMessage2(HWND hWndParent, UINT idsError, HRESULT hr);
  38. //----------------------------------------------------------------------------
  39. // Function: FormatSystemError
  40. //
  41. // Formats an error code using '::FormatMessage' or '::MprAdminGetErrorString',
  42. // or both (the default).
  43. // If 'psFormat' is specified, it is used to format the error-string
  44. // into 'sError'.
  45. //----------------------------------------------------------------------------
  46. DWORD
  47. FormatSystemError(
  48. HRESULT hr,
  49. LPTSTR pszError,
  50. UINT cchMax,
  51. UINT idsFormat,
  52. DWORD dwFormatFlags);
  53. // IN UINT idsFormat = 0,
  54. // IN DWORD dwFormatFlags = FSEFLAG_SYSMESSAGE|
  55. // FSEFLAG_MPRMESSAGE);
  56. //----------------------------------------------------------------------------
  57. // Function: FormatNumber
  58. //
  59. // Formats a number as a string, using the thousands-separator
  60. // for the current-user's locale.
  61. //----------------------------------------------------------------------------
  62. VOID
  63. FormatNumber(
  64. DWORD dwNumber,
  65. LPTSTR pszNumber,
  66. UINT cchMax,
  67. BOOL bSigned);
  68. VOID
  69. FormatListString(
  70. IN CStringList& strList,
  71. IN CString& sListString,
  72. IN LPCTSTR pszSeparator
  73. );
  74. //----------------------------------------------------------------------------
  75. // Function: FormatHexBytes
  76. //
  77. // Formats an array of bytes as a string.
  78. //----------------------------------------------------------------------------
  79. VOID
  80. FormatHexBytes(
  81. IN BYTE* pBytes,
  82. IN DWORD dwCount,
  83. IN CString& sBytes,
  84. IN TCHAR chDelimiter);
  85. //----------------------------------------------------------------------------
  86. // Function: FormatDuration
  87. //
  88. // Formats a number as a duration, using the time-separator
  89. // for the current-user's locale. The input expected is in milliseconds.
  90. //----------------------------------------------------------------------------
  91. #define FDFLAG_MSECONDS 0x00000001
  92. #define FDFLAG_SECONDS 0x00000002
  93. #define FDFLAG_MINUTES 0x00000004
  94. #define FDFLAG_HOURS 0x00000008
  95. #define FDFLAG_DAYS 0x00000010
  96. #define FDFLAG_ALL 0x0000001F
  97. #define UNIT_SECONDS (1)
  98. #define UNIT_MILLISECONDS (1000)
  99. VOID
  100. FormatDuration(
  101. IN DWORD dwDuration,
  102. IN CString& sDuration,
  103. IN DWORD dwTimeBase,
  104. IN DWORD dwFormatFlags = FDFLAG_SECONDS|
  105. FDFLAG_MINUTES|
  106. FDFLAG_HOURS );
  107. #define WIN32_FROM_HRESULT(hr) (0x0000FFFF & (hr))
  108. /*---------------------------------------------------------------------------
  109. Class: IfIndexToNameMapping
  110. Use this class to implement an interface-index to friendly-name mapping.
  111. This is used mostly by those that use the MIB calls and want to
  112. display some data.
  113. Note that the interface index may change, so this map should not be
  114. kept around very long.
  115. ---------------------------------------------------------------------------*/
  116. class IfIndexToNameMapping
  117. {
  118. public:
  119. IfIndexToNameMapping();
  120. ~IfIndexToNameMapping();
  121. HRESULT Add(ULONG ulIndex, LPCTSTR pszName);
  122. LPCTSTR Find(ULONG ulIndex);
  123. protected:
  124. // This maps a key (the DWORD index) to the associated name
  125. CMapPtrToPtr m_map;
  126. };
  127. #endif