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.

119 lines
4.4 KiB

  1. // STATS.H
  2. //
  3. // Headers for STATS.DLL: a library to accumulate high performance
  4. // statistics and allow them to be tabulated in a different
  5. // process.
  6. //
  7. // Created 24-Oct-96 [JonT]
  8. #ifndef _STATS_H
  9. #define _STATS_H
  10. #ifdef __cplusplus
  11. extern "C" {
  12. #endif
  13. //#if defined(_BUILD_STATS_) || defined(__midl)
  14. #ifdef _BUILD_STATS_
  15. #define STATSAPI
  16. #else
  17. #define STATSAPI __declspec(dllimport)
  18. #endif
  19. // Equates
  20. #define MAX_COUNTER_NAME 64
  21. #define STATS_COUNTER_ADDDEL_EVENT "StatsNewCounter"
  22. #define COUNTER_FLAG_NO_STATISTICS 1 // Flag to CreateCounter. No statistics accumulated
  23. // for this counter even if StartStatistics called.
  24. // (StartStatistics fails)
  25. #define COUNTER_FLAG_ACCUMULATE 2 // UpdateCounter adds to the counter value rather
  26. // than replacing it.
  27. #define COUNTER_CLEAR 1 // Flag to GetCounter. Specifies the counter should
  28. // be cleared after being read
  29. // Types
  30. #ifdef __midl
  31. typedef DWORD HCOUNTER;
  32. #else
  33. typedef HANDLE HCOUNTER;
  34. #endif
  35. typedef struct _FINDCOUNTER
  36. {
  37. DWORD dwSize;
  38. char szName[MAX_COUNTER_NAME]; // Human-readable counter name
  39. HCOUNTER hcounter; // Handle to use with all stats functions
  40. int nValue; // Current value of counter
  41. WORD wFlags; // COUNTER_FLAG_* values
  42. WORD wRefCount; // Number of times StartStatistics has been called.
  43. DWORD dwReserved; // Must be preserved: used for FindNextCounter
  44. } FINDCOUNTER;
  45. typedef struct _COUNTERSTAT
  46. {
  47. DWORD dwSize; // Size of structure. Allows for future growth...
  48. int nValue;
  49. int nLow; // Lowest value seen since clear
  50. int nHigh; // Highest value seen since clear
  51. int nAverage; // Average value seen since clear
  52. DWORD dwNumSamples; // Number of samples accumulated
  53. DWORD dwmsAtClear; // GetTickCount at last Clear/StartStatistics call
  54. } COUNTERSTAT;
  55. typedef HCOUNTER HREPORT;
  56. #define MAX_REPORT_NAME 64
  57. typedef struct _FINDREPORT
  58. {
  59. DWORD dwSize;
  60. char szName[MAX_REPORT_NAME]; // Human-readable report name
  61. HREPORT hreport; // Handle to use with all functions
  62. WORD wFlags; // COUNTER_FLAG_* values
  63. WORD wRefCount; // Number of times StartStatistics has been called.
  64. DWORD dwReserved; // Must be preserved: used for FindNextCounter
  65. } FINDREPORT;
  66. // Nothing further needed by MIDL
  67. #ifndef __midl
  68. // Functions
  69. // Called by updater of counter to make new counter
  70. // Sets the event named in the equate STATS_NEW_COUNTER_EVENT
  71. STATSAPI HCOUNTER WINAPI CreateCounter(char* szName, WORD wFlags);
  72. // Called by updater of counter when counter is going away
  73. STATSAPI BOOL WINAPI DeleteCounter(HCOUNTER hc);
  74. // Used by reader app to locate specific named counters or walk entire list.
  75. // Pass NULL in for name to walk entire list. Pass NULL to FINDCOUNTER if
  76. // just an HCOUNTER is desired. FindNext returns FALSE when there are no more.
  77. STATSAPI HCOUNTER WINAPI FindFirstCounter(char* szName, FINDCOUNTER* pfc);
  78. STATSAPI BOOL WINAPI FindNextCounter(FINDCOUNTER* pfc);
  79. // Called by updater of counter. Makes the value current in the counter.
  80. STATSAPI void WINAPI UpdateCounter(HCOUNTER hcounter, int value);
  81. // Called by user of counter and just returns value with no statistics
  82. STATSAPI int WINAPI GetCounter(HCOUNTER hcounter, DWORD dwFlags);
  83. // Begins collecting statistics on a counter
  84. STATSAPI BOOL WINAPI StartStatistics(HCOUNTER hcounter);
  85. // Done collecting statistics on a counter
  86. STATSAPI void WINAPI StopStatistics(HCOUNTER hcounter);
  87. // Get statistics on a counter
  88. STATSAPI BOOL WINAPI ReadStatistics(HCOUNTER hcounter, COUNTERSTAT* pcs);
  89. // Clear statistics on a counter
  90. STATSAPI void WINAPI ClearStatistics(HCOUNTER hcounter);
  91. #endif // #ifndef __midl
  92. #ifdef __cplusplus
  93. }
  94. #endif
  95. #endif // #ifndef _STATS_H