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.

174 lines
4.5 KiB

  1. // Copyright (c) 1997-1999 Microsoft Corporation
  2. //
  3. // global utility functions
  4. //
  5. // 8-14-97 sburns
  6. // KMH: originally named burnslib\utility.* but that filename was
  7. // getting a little overused.
  8. #ifndef UTILITY_HPP_INCLUDED
  9. #define UTILITY_HPP_INCLUDED
  10. #include <chstring.h>
  11. #include <dsrole.h>
  12. //TODO
  13. #define SRV_RECORD_RESERVE = 100
  14. #define MAX_NAME_LENGTH = 2-SRV_RECORD_RESERVE
  15. #define MAX_LABEL_LENGTH = 2
  16. #define BREAK_ON_FAILED_HRESULT(hr) \
  17. if (FAILED(hr)) \
  18. { \
  19. TRACE_HRESULT(hr); \
  20. break; \
  21. }
  22. void
  23. error(HWND parent,
  24. HRESULT hr,
  25. const CHString& message,
  26. const CHString& title);
  27. void error(HWND parent,
  28. HRESULT hr,
  29. const CHString& message);
  30. void error(HWND parent,
  31. HRESULT hr,
  32. const CHString& message,
  33. int titleResID);
  34. void error(HWND parent,
  35. HRESULT hr,
  36. int messageResID,
  37. int titleResID);
  38. void error(HWND parent,
  39. HRESULT hr,
  40. int messageResID);
  41. // Sets or clears a bit, or set of bits.
  42. //
  43. // bits - bit set where bits will be set.
  44. //
  45. // mask - mask of bits to be effected.
  46. //
  47. // state - true to set the mask bits, false to clear them.
  48. void FlipBits(long& bits, long mask, bool state);
  49. // Present a message box dialog, set input focus back to a given edit
  50. // box when the dialog is dismissed.
  51. //
  52. // parentDialog - the parent window containing the control to receive focus.
  53. //
  54. // editResID - Resource ID of the edit box to which focus will be set.
  55. //
  56. // errStringResID - Resource ID of the message text to be shown in the
  57. // dialog. The title of the dialog is "Error".
  58. void gripe(HWND parentDialog,
  59. int editResID,
  60. int errStringResID);
  61. // Present a message box dialog, set input focus back to a given edit
  62. // box when the dialog is dismissed. The title of the message box is "Error".
  63. //
  64. // parentDialog - the parent window containing the control to receive focus.
  65. // editResID - Resource ID of the edit box to which focus will be set.
  66. //
  67. // message - Text to appear in the dialog. The title is "Error".
  68. void gripe(HWND parentDialog,
  69. int editResID,
  70. const CHString& message);
  71. void gripe(HWND parentDialog,
  72. int editResID,
  73. const CHString& message,
  74. int titleResID);
  75. // Present a message box dialog, set input focus back to a given edit
  76. // box when the dialog is dismissed.
  77. //
  78. // parentDialog - the parent window containing the control to receive focus.
  79. //
  80. // editResID - Resource ID of the edit box to which focus will be set.
  81. //
  82. // message - Text to appear in the dialog.
  83. //
  84. // title - The title of the message box. An empty String causes the title
  85. // to be "Error".
  86. void gripe(HWND parentDialog,
  87. int editResID,
  88. const CHString& message,
  89. const CHString& title);
  90. void gripe(HWND parentDialog,
  91. int editResID,
  92. HRESULT hr,
  93. const CHString& message,
  94. const CHString& title);
  95. void gripe(HWND parentDialog,
  96. int editResID,
  97. HRESULT hr,
  98. const CHString& message,
  99. int titleResID);
  100. // Returns the HINSTANCE of the DLL designated to contain all resources.
  101. //
  102. // This function requires that the first module loaded (whether it be a DLL or
  103. // EXE) set the global variable hResourceModuleHandle to the HINSTANCE of the
  104. // module (DLL or EXE) that contains all of the program's binary resources.
  105. // This should be done as early as possible in the module's startup code.
  106. // Returns true if current process token contains administrators membership.
  107. BOOL IsCurrentUserAdministrator();
  108. // Returns true if tcp/ip protocol is installed and bound.
  109. bool IsTCPIPInstalled();
  110. // Return the next highest whole number greater than n if the
  111. // fractional portion of n >= 0.5, otherwise return n.
  112. int Round(double n);
  113. CHString GetTrimmedDlgItemText(HWND parentDialog, UINT itemResID);
  114. void StringLoad(UINT resID, LPCTSTR buf, UINT size);
  115. #endif UTILITY_HPP_INCLUDED