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.

360 lines
6.7 KiB

  1. /*++
  2. Module Name:
  3. Utils.h
  4. Abstract:
  5. This module contains the definition for CUtils class.
  6. Contains utility method which are used throughout the project.
  7. --*/
  8. #if !defined(AFX_UTILS_H__B3542C03_4260_11D1_AA28_00C06C00392D__INCLUDED_)
  9. #define AFX_UTILS_H__B3542C03_4260_11D1_AA28_00C06C00392D__INCLUDED_
  10. #if _MSC_VER >= 1000
  11. #pragma once
  12. #endif // _MSC_VER >= 1000
  13. #include <lmcons.h>
  14. #include <lmerr.h>
  15. #include <icanon.h>
  16. #include "dfsenums.h"
  17. #include <schedule.h>
  18. #include "ldaputils.h"
  19. class CThemeContextActivator
  20. {
  21. public:
  22. CThemeContextActivator() : m_ulActivationCookie(0)
  23. { SHActivateContext (&m_ulActivationCookie); }
  24. ~CThemeContextActivator()
  25. { SHDeactivateContext (m_ulActivationCookie); }
  26. private:
  27. ULONG_PTR m_ulActivationCookie;
  28. };
  29. class CWaitCursor
  30. {
  31. public:
  32. CWaitCursor() { SetStandardCursor(IDC_WAIT); }
  33. ~CWaitCursor() { SetStandardCursor(IDC_ARROW); }
  34. HRESULT SetStandardCursor(
  35. IN LPCTSTR i_lpCursorName
  36. );
  37. };
  38. BOOL Is256ColorSupported(
  39. VOID
  40. );
  41. VOID SetControlFont(
  42. IN HFONT hFont,
  43. IN HWND hwnd,
  44. IN INT nId
  45. );
  46. VOID SetupFonts(
  47. IN HINSTANCE hInstance,
  48. IN HWND hwnd,
  49. IN HFONT *pBigBoldFont,
  50. IN HFONT *pBoldFont
  51. );
  52. VOID
  53. DestroyFonts(
  54. IN HFONT hBigBoldFont,
  55. IN HFONT hBoldFont
  56. );
  57. HRESULT LoadStringFromResource(
  58. IN const UINT i_uResourceID,
  59. OUT BSTR* o_pbstrReadValue
  60. );
  61. HRESULT FormatResourceString(
  62. IN const UINT i_uResourceID,
  63. IN LPCTSTR i_szFirstArg,
  64. OUT BSTR* o_pbstrReadString
  65. );
  66. HRESULT CreateSmallImageList(
  67. IN HINSTANCE i_hInstance,
  68. IN int* i_pIconID,
  69. IN const int i_nNumOfIcons,
  70. OUT HIMAGELIST* o_phImageList
  71. );
  72. HRESULT InsertIntoListView(
  73. IN HWND i_hwndList,
  74. IN LPCTSTR i_szItemText,
  75. IN int i_iImageIndex = 0
  76. );
  77. HRESULT GetListViewItemText(
  78. IN HWND i_hwndListView,
  79. IN int i_iItemID,
  80. OUT BSTR* o_pbstrItemText
  81. );
  82. HRESULT GetComboBoxText(
  83. IN HWND i_hwndCombo,
  84. OUT BSTR* o_pbstrText
  85. );
  86. HRESULT EnableToolbarButtons(
  87. IN const LPTOOLBAR i_lpToolbar,
  88. IN const INT i_iFirstButtonID,
  89. IN const INT i_iLastButtonID,
  90. IN const BOOL i_bEnableState
  91. );
  92. HRESULT AddBitmapToToolbar(
  93. IN const LPTOOLBAR i_lpToolbar,
  94. IN const INT i_iBitmapResource
  95. );
  96. HRESULT
  97. GetMessage(
  98. OUT BSTR* o_pbstrMsg,
  99. IN DWORD dwErr,
  100. IN UINT iStringId,
  101. ...);
  102. int
  103. DisplayMessageBox(
  104. IN HWND hwndParent,
  105. IN UINT uType,
  106. IN DWORD dwErr,
  107. IN UINT iStringId,
  108. ...);
  109. HRESULT DisplayMessageBoxWithOK(
  110. IN const int i_iMessageResID,
  111. IN const BSTR i_bstrArgument = NULL
  112. );
  113. HRESULT DisplayMessageBoxForHR(
  114. IN HRESULT i_hr
  115. );
  116. HRESULT GetInputText(
  117. IN HWND hwnd,
  118. OUT BSTR* o_pbstrText,
  119. OUT DWORD* o_pdwTextLength
  120. );
  121. BOOL CheckRegKey();
  122. BOOL
  123. ValidateNetPath(
  124. IN BSTR i_bstrNetPath,
  125. OUT BSTR *o_pbstrServer,
  126. OUT BSTR *o_pbstrShare
  127. );
  128. HRESULT
  129. IsComputerLocal(
  130. IN LPCTSTR lpszServer
  131. );
  132. BOOL
  133. IsValidLocalAbsolutePath(
  134. IN LPCTSTR lpszPath
  135. );
  136. HRESULT
  137. GetFullPath(
  138. IN LPCTSTR lpszServer,
  139. IN LPCTSTR lpszPath,
  140. OUT BSTR *o_pbstrFullPath
  141. );
  142. HRESULT
  143. VerifyDriveLetter(
  144. IN LPCTSTR lpszServer,
  145. IN LPCTSTR lpszPath
  146. );
  147. HRESULT
  148. IsAdminShare(
  149. IN LPCTSTR lpszServer,
  150. IN LPCTSTR lpszPath
  151. );
  152. HRESULT
  153. IsAnExistingFolder(
  154. IN HWND hwnd,
  155. IN LPCTSTR pszPath,
  156. IN BOOL bDisplayErrorMsg = TRUE
  157. );
  158. HRESULT
  159. CreateLayeredDirectory(
  160. IN LPCTSTR lpszServer,
  161. IN LPCTSTR lpszPath
  162. );
  163. HRESULT
  164. BrowseNetworkPath(
  165. IN HWND hwndParent,
  166. OUT BSTR *o_pbstrPath
  167. );
  168. BOOL
  169. ValidateTimeout(
  170. IN LPCTSTR lpszTimeOut,
  171. OUT ULONG *pulTimeout
  172. );
  173. TCHAR
  174. GetDiskForStagingPath(
  175. IN LPCTSTR lpszServer,
  176. IN TCHAR tch
  177. );
  178. HRESULT GetDfsRootDisplayName
  179. (
  180. IN BSTR i_bstrScopeName,
  181. IN BSTR i_bstrDfsName,
  182. OUT BSTR* o_pbstrDisplayName
  183. );
  184. HRESULT GetDfsReplicaDisplayName
  185. (
  186. IN BSTR i_bstrServerName,
  187. IN BSTR i_bstrShareName,
  188. OUT BSTR* o_pbstrDisplayName
  189. );
  190. HRESULT
  191. AddLVColumns(
  192. IN const HWND hwndListBox,
  193. IN const INT iStartingResourceID,
  194. IN const UINT uiColumns
  195. );
  196. LPARAM GetListViewItemData(
  197. IN HWND hwndList,
  198. IN int index
  199. );
  200. HRESULT CreateAndHideStagingPath(
  201. IN BSTR i_bstrServer,
  202. IN BSTR i_bstrStagingPath
  203. );
  204. HRESULT ConfigAndStartNtfrs
  205. (
  206. BSTR i_bstrServer
  207. );
  208. HRESULT CheckResourceProvider(LPCTSTR pszResource);
  209. HRESULT FRSShareCheck
  210. (
  211. BSTR i_bstrServer,
  212. BSTR i_bstrFolder,
  213. OUT FRSSHARE_TYPE *pFRSShareType
  214. );
  215. HRESULT FRSIsNTFRSInstalled
  216. (
  217. BSTR i_bstrServer
  218. );
  219. HRESULT InvokeScheduleDlg(
  220. IN HWND i_hwndParent,
  221. IN OUT SCHEDULE* io_pSchedule
  222. );
  223. HRESULT ReadSharePublishInfoOnFTRoot(
  224. LPCTSTR i_pszDomainName,
  225. LPCTSTR i_pszRootName,
  226. OUT BOOL* o_pbPublish,
  227. OUT BSTR* o_pbstrUNCPath,
  228. OUT BSTR* o_pbstrDescription,
  229. OUT BSTR* o_pbstrKeywords,
  230. OUT BSTR* o_pbstrManagedBy);
  231. HRESULT ReadSharePublishInfoOnSARoot(
  232. LPCTSTR i_pszServerName,
  233. LPCTSTR i_pszShareName,
  234. OUT BOOL* o_pbPublish,
  235. OUT BSTR* o_pbstrUNCPath,
  236. OUT BSTR* o_pbstrDescription,
  237. OUT BSTR* o_pbstrKeywords,
  238. OUT BSTR* o_pbstrManagedBy);
  239. HRESULT ModifySharePublishInfoOnFTRoot(
  240. IN PCTSTR i_pszDomainName,
  241. IN PCTSTR i_pszRootName,
  242. IN BOOL i_bPublish,
  243. IN PCTSTR i_pszUNCPath,
  244. IN PCTSTR i_pszDescription,
  245. IN PCTSTR i_pszKeywords,
  246. IN PCTSTR i_pszManagedBy
  247. );
  248. HRESULT ModifySharePublishInfoOnSARoot(
  249. IN PCTSTR i_pszServerName,
  250. IN PCTSTR i_pszShareName,
  251. IN BOOL i_bPublish,
  252. IN PCTSTR i_pszUNCPath,
  253. IN PCTSTR i_pszDescription,
  254. IN PCTSTR i_pszKeywords,
  255. IN PCTSTR i_pszManagedBy
  256. );
  257. HRESULT PutMultiValuesIntoAttrValList(
  258. IN PCTSTR i_pszValues,
  259. OUT LDAP_ATTR_VALUE** o_pVal
  260. );
  261. HRESULT PutMultiValuesIntoStringArray(
  262. IN PCTSTR i_pszValues,
  263. OUT PTSTR** o_pVal
  264. );
  265. void FreeStringArray(PTSTR* i_ppszStrings);
  266. HRESULT mystrtok(
  267. IN PCTSTR i_pszString,
  268. IN OUT int* io_pnIndex, // start from 0
  269. IN PCTSTR i_pszCharSet,
  270. OUT BSTR* o_pbstrToken
  271. );
  272. void TrimBSTR(BSTR bstr);
  273. BOOL CheckPolicyOnSharePublish();
  274. BOOL CheckPolicyOnDisplayingInitialMaster();
  275. HRESULT GetMenuResourceStrings(
  276. IN int i_iStringID,
  277. OUT BSTR* o_pbstrMenuText,
  278. OUT BSTR* o_pbstrToolTipText,
  279. OUT BSTR* o_pbstrStatusBarText
  280. );
  281. LRESULT CALLBACK
  282. NoPasteEditCtrlProc(
  283. HWND hwnd,
  284. UINT uMsg,
  285. WPARAM wParam,
  286. LPARAM lParam
  287. );
  288. void SetActivePropertyPage(IN HWND i_hwndParent, IN HWND i_hwndPage);
  289. void MyShowWindow(HWND hwnd, BOOL bShow);
  290. #endif // !defined(AFX_UTILS_H__B3542C03_4260_11D1_AA28_00C06C00392D__INCLUDED_)