Source code of Windows XP (NT5)
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.

231 lines
5.5 KiB

  1. //////////////////////////////////////////////////////////////////////////////
  2. /*++
  3. Copyright (C) Microsoft Corporation, 1997 - 1999
  4. Module Name:
  5. MMCUtility.cpp
  6. Abstract:
  7. Implementation file for functions doing various handy things
  8. that were getting written over and over again.
  9. Author:
  10. Michael A. Maguire 02/05/98
  11. Revision History:
  12. mmaguire 02/05/98 - created
  13. mmaguire 11/03/98 - moved GetSdo/PutSdo wrappers to sdohelperfuncs.h
  14. --*/
  15. //////////////////////////////////////////////////////////////////////////////
  16. #if !defined(_IAS_MMC_UTILITY_H_)
  17. #define _IAS_MMC_UTILITY_H_
  18. //////////////////////////////////////////////////////////////////////////////
  19. // BEGIN INCLUDES
  20. //
  21. // where we can find what this class derives from:
  22. //
  23. //
  24. //
  25. // where we can find what this class has or uses:
  26. //
  27. //
  28. // END INCLUDES
  29. //////////////////////////////////////////////////////////////////////////////
  30. //////////////////////////////////////////////////////////////////////////////
  31. /*++
  32. BringUpPropertySheetForNode
  33. Tries to bring up a property sheet on a given node. If the sheet for the
  34. node is already up, it will bring that sheet to the foreground.
  35. Parameters:
  36. pSnapInItem
  37. You must supply a pointer to the node you want the sheet for.
  38. pComponentData, pComponent
  39. Either you call with pComponentData != NULL and pComponent == NULL
  40. or pComponentData == NULL and pComponent != NULL.
  41. pConsole
  42. You must supply a pointer to an IConsole interface.
  43. bCreateSheetIfOneIsntAlreadyUp
  44. TRUE - if a sheet isn't already up, will try to create a property sheet
  45. for you -- in this case you should specify a title for the
  46. sheet in lpszSheetTitle.
  47. FALSE - will try to bring already existing sheet to foreground, but
  48. will return immediately if there isn't one.
  49. bPropertyPage
  50. TRUE for property pages. (Note: MMC creates property sheet in new thread.)
  51. FALSE for wizard pages. (Note: Wizard pages run in same thread.)
  52. Return:
  53. S_OK if found property sheet already up.
  54. S_FALSE if didn't find sheet already up but successfully made new one appear.
  55. E_... if some error error occurred.
  56. Remarks:
  57. For this function's to work, you must have correctly implemented
  58. IComponentData::CompareObjects and IComponentData::CompareObjects.
  59. --*/
  60. //////////////////////////////////////////////////////////////////////////////
  61. HRESULT BringUpPropertySheetForNode(
  62. CSnapInItem *pSnapInItem
  63. , IComponentData *pComponentData
  64. , IComponent *pComponent
  65. , IConsole *pConsole
  66. , BOOL bCreateSheetIfOneIsntAlreadyUp = FALSE
  67. , LPCTSTR lpszSheetTitle = NULL
  68. , BOOL bPropertyPage = TRUE // TRUE creates property page, FALSE wizard page.
  69. , DWORD dwPropertySheetOptions = 0 // e.g. pass MMC_PSO_NEWWIZARDTYPE for Wizard97 style
  70. );
  71. #define USE_DEFAULT 0
  72. #define USE_SUPPLEMENTAL_ERROR_STRING_ONLY 1
  73. //////////////////////////////////////////////////////////////////////////////
  74. /*++
  75. ShowErrorDialog
  76. Puts up an error dialog with varying degrees of detail
  77. Parameters:
  78. All parameters are optional -- in the worst case, you can simply call
  79. ShowErrorDialog();
  80. to put up a very generic error message.
  81. uErrorID
  82. The resource ID of the string to be used for the error message.
  83. Passing in USE_DEFAULT gives causes the default error message to be displayed.
  84. Passing in USE_SUPPLEMENTAL_ERROR_STRING_ONLY causes no resource string text to be displayed.
  85. bstrSupplementalErrorString
  86. Pass in a string to print as the error message. Useful if you are
  87. receiving an error string from some other component you communicate with.
  88. hr
  89. If there is an HRESULT involved in the error, pass it in here so that
  90. a suitable error message based on the HRESULT can be put up.
  91. Pass in S_OK if the HRESULT doesn't matter to the error.
  92. uTitleID
  93. The resource ID of the string to be used for the error dialog title.
  94. Passing in USE_DEFAULT gives causes the default error dialog title to be displayed.
  95. pConsole
  96. If you are running within the main MMC context, pass in a valid IConsole pointer
  97. and ShowErrorDialog will use MMC's IConsole::MessageBox rather than the
  98. standard system MessageBox.
  99. hWnd
  100. Whatever you pass in here will be passed in as the HWND parameter
  101. to the MessageBox call.
  102. This is not used if you pass in an IConsole pointer.
  103. uType
  104. Whatever you pass in here will be passed in as the HWND parameter
  105. to the MessageBox call.
  106. Return:
  107. The standard int returned from MessageBox.
  108. --*/
  109. //////////////////////////////////////////////////////////////////////////////
  110. int ShowErrorDialog(
  111. HWND hWnd = NULL
  112. , UINT uErrorID = USE_DEFAULT
  113. , BSTR bstrSupplementalErrorString = NULL
  114. , HRESULT hr = S_OK
  115. , UINT uTitleID = USE_DEFAULT
  116. , IConsole *pConsole = NULL
  117. , UINT uType = MB_OK | MB_ICONEXCLAMATION
  118. );
  119. ////////////////////////////////////////////////////////////////////////////
  120. /*++
  121. GetUserAndDomainName
  122. Retrieves current user's username and domain.
  123. Stolen from Knowledge Base HOWTO article:
  124. HOWTO: Look Up Current User Name and Domain Name
  125. Rollup: WINPROG
  126. Database: win32sdk
  127. Article ID: Q155698
  128. Last modified: June 16, 1997
  129. Security: PUBLIC
  130. --*/
  131. //////////////////////////////////////////////////////////////////////////////
  132. BOOL GetUserAndDomainName( LPTSTR UserName
  133. , LPDWORD cchUserName
  134. , LPTSTR DomainName
  135. , LPDWORD cchDomainName
  136. );
  137. DWORD GetModuleFileNameOnly(HINSTANCE hInst, LPTSTR lpFileName, DWORD nSize );
  138. ////////////////////////////////////////////////////////////////////////////
  139. /*++
  140. */
  141. HRESULT IfServiceInstalled(LPCTSTR lpszMachine, LPCTSTR lpszService, BOOL* pBool);
  142. #endif // _IAS_MMC_UTILITY_H_