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.

367 lines
7.1 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. );
  157. HRESULT
  158. CreateLayeredDirectory(
  159. IN LPCTSTR lpszServer,
  160. IN LPCTSTR lpszPath
  161. );
  162. HRESULT
  163. BrowseNetworkPath(
  164. IN HWND hwndParent,
  165. OUT BSTR *o_pbstrPath
  166. );
  167. BOOL
  168. ValidateTimeout(
  169. IN LPCTSTR lpszTimeOut,
  170. OUT ULONG *pulTimeout
  171. );
  172. TCHAR
  173. GetDiskForStagingPath(
  174. IN LPCTSTR lpszServer,
  175. IN TCHAR tch
  176. );
  177. HRESULT GetDfsRootDisplayName
  178. (
  179. IN BSTR i_bstrScopeName,
  180. IN BSTR i_bstrDfsName,
  181. OUT BSTR* o_pbstrDisplayName
  182. );
  183. HRESULT GetDfsReplicaDisplayName
  184. (
  185. IN BSTR i_bstrServerName,
  186. IN BSTR i_bstrShareName,
  187. OUT BSTR* o_pbstrDisplayName
  188. );
  189. HRESULT
  190. AddLVColumns(
  191. IN const HWND hwndListBox,
  192. IN const INT iStartingResourceID,
  193. IN const UINT uiColumns
  194. );
  195. LPARAM GetListViewItemData(
  196. IN HWND hwndList,
  197. IN int index
  198. );
  199. HRESULT CreateAndHideStagingPath(
  200. IN BSTR i_bstrServer,
  201. IN BSTR i_bstrStagingPath
  202. );
  203. HRESULT ConfigAndStartNtfrs
  204. (
  205. BSTR i_bstrServer
  206. );
  207. HRESULT CheckResourceProvider(LPCTSTR pszResource);
  208. HRESULT FRSShareCheck
  209. (
  210. BSTR i_bstrServer,
  211. BSTR i_bstrFolder,
  212. OUT FRSSHARE_TYPE *pFRSShareType
  213. );
  214. HRESULT FRSIsNTFRSInstalled
  215. (
  216. BSTR i_bstrServer
  217. );
  218. HRESULT InvokeScheduleDlg(
  219. IN HWND i_hwndParent,
  220. IN OUT SCHEDULE* io_pSchedule
  221. );
  222. HRESULT ReadSharePublishInfoOnFTRoot(
  223. LPCTSTR i_pszDomainName,
  224. LPCTSTR i_pszRootName,
  225. OUT BOOL* o_pbPublish,
  226. OUT BSTR* o_pbstrUNCPath,
  227. OUT BSTR* o_pbstrDescription,
  228. OUT BSTR* o_pbstrKeywords,
  229. OUT BSTR* o_pbstrManagedBy);
  230. HRESULT ReadSharePublishInfoOnSARoot(
  231. LPCTSTR i_pszServerName,
  232. LPCTSTR i_pszShareName,
  233. OUT BOOL* o_pbPublish,
  234. OUT BSTR* o_pbstrUNCPath,
  235. OUT BSTR* o_pbstrDescription,
  236. OUT BSTR* o_pbstrKeywords,
  237. OUT BSTR* o_pbstrManagedBy);
  238. HRESULT ModifySharePublishInfoOnFTRoot(
  239. IN PCTSTR i_pszDomainName,
  240. IN PCTSTR i_pszRootName,
  241. IN BOOL i_bPublish,
  242. IN PCTSTR i_pszUNCPath,
  243. IN PCTSTR i_pszDescription,
  244. IN PCTSTR i_pszKeywords,
  245. IN PCTSTR i_pszManagedBy
  246. );
  247. HRESULT ModifySharePublishInfoOnSARoot(
  248. IN PCTSTR i_pszServerName,
  249. IN PCTSTR i_pszShareName,
  250. IN BOOL i_bPublish,
  251. IN PCTSTR i_pszUNCPath,
  252. IN PCTSTR i_pszDescription,
  253. IN PCTSTR i_pszKeywords,
  254. IN PCTSTR i_pszManagedBy
  255. );
  256. HRESULT PutMultiValuesIntoAttrValList(
  257. IN PCTSTR i_pszValues,
  258. OUT LDAP_ATTR_VALUE** o_pVal
  259. );
  260. HRESULT PutMultiValuesIntoStringArray(
  261. IN PCTSTR i_pszValues,
  262. OUT PTSTR** o_pVal
  263. );
  264. void FreeStringArray(PTSTR* i_ppszStrings);
  265. HRESULT mystrtok(
  266. IN PCTSTR i_pszString,
  267. IN OUT int* io_pnIndex, // start from 0
  268. IN PCTSTR i_pszCharSet,
  269. OUT BSTR* o_pbstrToken
  270. );
  271. void TrimBSTR(BSTR bstr);
  272. BOOL CheckPolicyOnSharePublish();
  273. BOOL CheckPolicyOnDisplayingInitialMaster();
  274. HRESULT GetMenuResourceStrings(
  275. IN int i_iStringID,
  276. OUT BSTR* o_pbstrMenuText,
  277. OUT BSTR* o_pbstrToolTipText,
  278. OUT BSTR* o_pbstrStatusBarText
  279. );
  280. LRESULT CALLBACK
  281. NoPasteEditCtrlProc(
  282. HWND hwnd,
  283. UINT uMsg,
  284. WPARAM wParam,
  285. LPARAM lParam
  286. );
  287. void SetActivePropertyPage(IN HWND i_hwndParent, IN HWND i_hwndPage);
  288. void MyShowWindow(HWND hwnd, BOOL bShow);
  289. void OpenBrowseDialog(
  290. IN HWND hwndParent,
  291. IN int idLabel,
  292. IN BOOL bLocalComputer,
  293. IN LPCTSTR lpszComputer,
  294. OUT LPTSTR lpszDir
  295. );
  296. #endif // !defined(AFX_UTILS_H__B3542C03_4260_11D1_AA28_00C06C00392D__INCLUDED_)