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.

649 lines
20 KiB

  1. //+----------------------------------------------------------------------------
  2. //
  3. // Windows NT Directory Service Property Pages
  4. //
  5. // Microsoft Windows
  6. // Copyright (C) Microsoft Corporation, 1992 - 1999
  7. //
  8. // File: proputil.h
  9. //
  10. // Contents: DS object property pages utility and helper functions header
  11. //
  12. // History: 29-Sept-98 EricB created
  13. //
  14. //-----------------------------------------------------------------------------
  15. #ifndef _PROPUTIL_H_
  16. #define _PROPUTIL_H_
  17. extern const CLSID CLSID_DomainAdmin; // Domains & Trusts snapin CLSID
  18. const unsigned long DSPROP_FILETIMES_PER_MILLISECOND = 10000;
  19. const DWORD DSPROP_FILETIMES_PER_SECOND = 1000 * DSPROP_FILETIMES_PER_MILLISECOND;
  20. const DWORD DSPROP_FILETIMES_PER_MINUTE = 60 * DSPROP_FILETIMES_PER_SECOND;
  21. const __int64 DSPROP_FILETIMES_PER_HOUR = 60 * (__int64)DSPROP_FILETIMES_PER_MINUTE;
  22. const __int64 DSPROP_FILETIMES_PER_DAY = 24 * DSPROP_FILETIMES_PER_HOUR;
  23. const __int64 DSPROP_FILETIMES_PER_MONTH= 30 * DSPROP_FILETIMES_PER_DAY;
  24. const UINT DSPROP_TIMER_DELAY = 300; // 300 millisecond delay.
  25. extern ULONG g_ulMemberFilterCount;
  26. extern ULONG g_ulMemberQueryLimit;
  27. #define DSPROP_MEMBER_FILTER_COUNT_DEFAULT 35
  28. #define DSPROP_MEMBER_QUERY_LIMIT_DEFAULT 500
  29. //
  30. // Helpers.
  31. //
  32. BOOL UnicodeToTchar(LPWSTR pwszIn, LPTSTR * pptszOut);
  33. BOOL TcharToUnicode(LPTSTR ptszIn, LPWSTR * ppwszOut);
  34. BOOL AllocWStr(PWSTR pwzStrIn, PWSTR * ppwzNewStr);
  35. BOOL AllocTStr(PTSTR ptzStrIn, PTSTR * pptzNewStr);
  36. BOOL LoadStringToTchar(int ids, PTSTR * pptstr);
  37. HRESULT AddLDAPPrefix(CDsPropPageBase * pObj, PWSTR pwzObj, CStrW &strResult,
  38. BOOL fServer = TRUE);
  39. void InitAttrInfo(PADS_ATTR_INFO pAttr, PWSTR pwzName, ADSTYPEENUM type);
  40. HRESULT GetLdapServerName(IUnknown * pDsObj, CStrW& strServer);
  41. BOOL FValidSMTPAddress(PWSTR pwzBuffer);
  42. HRESULT CheckRegisterClipFormats(void);
  43. HRESULT BindToGCcopyOfObj(CDsPropPageBase * pPage, PWSTR pwzObjADsPath,
  44. IDirectoryObject ** ppDsObj);
  45. void ConvertSidToPath(PSID ObjSID, CStrW &strSIDname);
  46. #define ARRAYLENGTH(x) (sizeof(x)/sizeof((x)[0]))
  47. #define DO_DEL(x) if (x) {delete x; x = NULL;}
  48. #define DO_RELEASE(x) if (x) {x->Release(); x = NULL;}
  49. HRESULT GetDomainScope(CDsPropPageBase * pPage, BSTR * pBstrOut);
  50. HRESULT GetObjectsDomain(CDsPropPageBase * pPage, PWSTR pwzObjPath, BSTR * pBstrOut);
  51. void ReportErrorWorker(HWND hWnd, PTSTR ptzMsg);
  52. #if defined(DSADMIN)
  53. //+----------------------------------------------------------------------------
  54. //
  55. // Function: DspFormatMessage
  56. //
  57. // Synopsis: Loads a string resource with replaceable parameters and uses
  58. // FormatMessage to populate the replaceable params from the
  59. // argument array. If dwErr is non-zero, will load the system
  60. // description for that error and include it in the argument array.
  61. //
  62. //-----------------------------------------------------------------------------
  63. void
  64. DspFormatMessage(
  65. int nMessageId, // string resource ID of message. Must have replacable params to match nArguments.
  66. DWORD dwErr, // Error code, or zero if not needed.
  67. PVOID * rgpvArgs, // array of pointers/values for substitution in the nMessageId string.
  68. int nArguments, // count of pointers in string array.
  69. BOOL fTryADSiErrors,// If the failure is the result of an ADSI call, see if an ADSI extended error.
  70. PWSTR * ppwzMsg, // The returned error string, free with LocalFree.
  71. HWND hWnd = NULL // owning window, can be NULL.
  72. );
  73. #endif // defined(DSADMIN)
  74. //
  75. // Predefined table-driven page auxiliary functions
  76. //
  77. //
  78. // For these, set the bit you want in pAttrMap->pData.
  79. // You can "reverse the sense" of the checkbox by providing the inverse of the bit.
  80. //
  81. HRESULT
  82. FirstSharedBitField(CDsPropPageBase * pPage, PATTR_MAP pAttrMap, PADS_ATTR_INFO pAttrInfo,
  83. LPARAM lParam, PATTR_DATA pAttrData, DLG_OP DlgOp);
  84. HRESULT
  85. SubsequentSharedBitField(CDsPropPageBase * pPage, PATTR_MAP pAttrMap, PADS_ATTR_INFO pAttrInfo,
  86. LPARAM lParam, PATTR_DATA pAttrData, DLG_OP DlgOp);
  87. HRESULT
  88. HideBasedOnBitField(CDsPropPageBase * pPage, PATTR_MAP pAttrMap, PADS_ATTR_INFO pAttrInfo,
  89. LPARAM lParam, PATTR_DATA pAttrData, DLG_OP DlgOp);
  90. // Sets the context help ID to pAttrMap->pData on fInit/fObjChanged
  91. // This is particularly useful for static text controls which cannot set
  92. // context help ID in the resource file.
  93. HRESULT
  94. SetContextHelpIdAttrFn(CDsPropPageBase * pPage, PATTR_MAP pAttrMap, PADS_ATTR_INFO pAttrInfo,
  95. LPARAM lParam, PATTR_DATA pAttrData, DLG_OP DlgOp);
  96. HRESULT
  97. DsQuerySite(CDsPropPageBase * pPage, PATTR_MAP pAttrMap,
  98. PADS_ATTR_INFO pAttrInfo, LPARAM lParam, PATTR_DATA pAttrData, DLG_OP DlgOp);
  99. HRESULT
  100. DsQueryInterSiteTransport(CDsPropPageBase * pPage, PATTR_MAP pAttrMap,
  101. PADS_ATTR_INFO pAttrInfo, LPARAM lParam, PATTR_DATA pAttrData, DLG_OP DlgOp);
  102. HRESULT
  103. DsQueryPolicy(CDsPropPageBase * pPage, PATTR_MAP pAttrMap,
  104. PADS_ATTR_INFO pAttrInfo, LPARAM lParam, PATTR_DATA pAttrData, DLG_OP DlgOp);
  105. HRESULT
  106. DsReplicateListbox(CDsPropPageBase * pPage, PATTR_MAP pAttrMap,
  107. PADS_ATTR_INFO pAttrInfo, LPARAM lParam, PATTR_DATA pAttrData, DLG_OP DlgOp);
  108. /*
  109. HRESULT
  110. DsQueryFrsPrimaryMember(CDsPropPageBase * pPage, PATTR_MAP pAttrMap,
  111. PADS_ATTR_INFO pAttrInfo, LPARAM lParam, PATTR_DATA pAttrData, DLG_OP DlgOp);
  112. */
  113. HRESULT
  114. GeneralPageIcon(CDsPropPageBase * pPage, PATTR_MAP pAttrMap,
  115. PADS_ATTR_INFO pAttrInfo, LPARAM lParam, PATTR_DATA pAttrData,
  116. DLG_OP DlgOp);
  117. //
  118. // Duelling listbox functions
  119. //
  120. // DuellingListbox can be used for all "out" listboxes,
  121. // and DuellingListboxButton can be used for all Add and Remove buttons.
  122. // Only the In listbox needs an individual handler.
  123. // The control IDs for the four controls in a duelling listbox set are constrained;
  124. // they must be in sequence OUT, ADD, REMOVE, IN, with the ID for OUT divisible by 4.
  125. //
  126. HRESULT
  127. DuellingListbox(CDsPropPageBase * pPage, PATTR_MAP pAttrMap,
  128. PADS_ATTR_INFO pAttrInfo, LPARAM lParam, PATTR_DATA pAttrData, DLG_OP DlgOp);
  129. HRESULT
  130. DuellingListboxButton(CDsPropPageBase * pPage, PATTR_MAP pAttrMap,
  131. PADS_ATTR_INFO pAttrInfo, LPARAM lParam, PATTR_DATA pAttrData, DLG_OP DlgOp);
  132. HRESULT
  133. DsQuerySiteList(CDsPropPageBase * pPage, PATTR_MAP pAttrMap,
  134. PADS_ATTR_INFO pAttrInfo, LPARAM lParam, PATTR_DATA pAttrData, DLG_OP DlgOp);
  135. HRESULT
  136. DsQuerySiteLinkList(CDsPropPageBase * pPage, PATTR_MAP pAttrMap,
  137. PADS_ATTR_INFO pAttrInfo, LPARAM lParam, PATTR_DATA pAttrData, DLG_OP DlgOp);
  138. HRESULT
  139. DsQueryBridgeheadList(CDsPropPageBase * pPage, PATTR_MAP pAttrMap,
  140. PADS_ATTR_INFO pAttrInfo, LPARAM lParam, PATTR_DATA pAttrData, DLG_OP DlgOp);
  141. HRESULT IntegerAsBoolDefOn(CDsPropPageBase *, PATTR_MAP, PADS_ATTR_INFO,
  142. LPARAM, PATTR_DATA, DLG_OP);
  143. HRESULT VolumeUNCpath(CDsPropPageBase *, PATTR_MAP, PADS_ATTR_INFO,
  144. LPARAM, PATTR_DATA, DLG_OP);
  145. // Flags for Validate Unc Path
  146. #define VUP_mskfAllowEmptyPath 0x0001 // Empty path is valid
  147. #define VUP_mskfAllowUNCPath 0x0002 // UNC path is valid
  148. BOOL FIsValidUncPath(LPCTSTR pszPath, UINT uFlags = 0);
  149. //+----------------------------------------------------------------------------
  150. //
  151. // Class: CPageInfo
  152. //
  153. // Purpose: Holds the HWNDs of all proppages and the errors associated with
  154. // them from the apply
  155. //
  156. //-----------------------------------------------------------------------------
  157. class CPageInfo
  158. {
  159. public:
  160. CPageInfo() : m_hWnd(NULL), m_ptzTitle(NULL), m_ApplyStatus(notAttempted) {}
  161. ~CPageInfo()
  162. {
  163. if (m_ptzTitle != NULL)
  164. {
  165. delete[] m_ptzTitle;
  166. m_ptzTitle = NULL;
  167. }
  168. }
  169. typedef enum
  170. {
  171. notAttempted = 0,
  172. success,
  173. failed,
  174. } APPLYSTATUS;
  175. HWND m_hWnd;
  176. CADsApplyErrors m_ApplyErrors;
  177. APPLYSTATUS m_ApplyStatus;
  178. PTSTR m_ptzTitle;
  179. };
  180. //+----------------------------------------------------------------------------
  181. //
  182. // Class: CNotifyObj
  183. //
  184. // Purpose: Handles inter-page and inter-sheet syncronization.
  185. //
  186. //-----------------------------------------------------------------------------
  187. class CNotifyObj
  188. {
  189. #ifdef _DEBUG
  190. char szClass[32];
  191. #endif
  192. friend VOID __cdecl NotifyThreadFcn(PVOID);
  193. friend VOID RegisterNotifyClass(void);
  194. public:
  195. CNotifyObj(LPDATAOBJECT pDataObj, PPROPSHEETCFG pSheetCfg);
  196. ~CNotifyObj(void);
  197. //
  198. // Creation function to create an instance of the object.
  199. //
  200. static HRESULT Create(LPDATAOBJECT pAppThdDataObj, PWSTR pwzADsObjName,
  201. HWND * phNotifyObj);
  202. //
  203. // Pages call this at their object init time to retreive DS object info.
  204. //
  205. static BOOL GetInitInfo(HWND hNotifyObj, PADSPROPINITPARAMS pInitParams);
  206. //
  207. // Pages call this at their dialog init time to send their hwnd.
  208. //
  209. static BOOL SetHwnd(HWND hNotifyObj, HWND hPage, PTSTR ptzTitle = NULL);
  210. //
  211. // Static WndProc to be passed as class address.
  212. //
  213. static LRESULT CALLBACK StaticNotifyProc(HWND hWnd, UINT uMsg,
  214. WPARAM wParam, LPARAM lParam);
  215. //
  216. // Instance window procedure.
  217. //
  218. LRESULT CALLBACK NotifyProc(HWND hWnd, UINT uMsg, WPARAM wParam,
  219. LPARAM lParam);
  220. //
  221. // Member functions, called by WndProc
  222. //
  223. LRESULT OnCreate(void);
  224. //
  225. // Data members
  226. //
  227. HWND m_hWnd;
  228. DWORD m_cPages;
  229. DWORD m_cApplies;
  230. LPDATAOBJECT m_pAppThdDataObj;
  231. UINT m_nPageInfoArraySize;
  232. CPageInfo* m_pPageInfoArray;
  233. private:
  234. // HWND m_hWnd;
  235. HWND m_hPropSheet;
  236. // DWORD m_cPages;
  237. // DWORD m_cApplies;
  238. // LPDATAOBJECT m_pAppThdDataObj;
  239. LPSTREAM m_pStrmMarshalledDO;
  240. PROPSHEETCFG m_sheetCfg;
  241. HANDLE m_hInitEvent;
  242. BOOL m_fBeingDestroyed;
  243. BOOL m_fSheetDirty;
  244. HRESULT m_hr;
  245. PWSTR m_pwzObjDN;
  246. IDirectoryObject * m_pDsObj;
  247. PWSTR m_pwzCN;
  248. PADS_ATTR_INFO m_pWritableAttrs;
  249. PADS_ATTR_INFO m_pAttrs;
  250. CDllRef m_DllRef;
  251. // UINT m_nPageInfoArraySize;
  252. // CPageInfo* m_pPageInfoArray;
  253. };
  254. //+----------------------------------------------------------------------------
  255. //
  256. // Class: CMultiStringAttr
  257. //
  258. // Purpose: Read, edit, and write a multi-valued, string property.
  259. //
  260. //-----------------------------------------------------------------------------
  261. class CMultiStringAttr
  262. {
  263. public:
  264. CMultiStringAttr(CDsPropPageBase * pPage);
  265. ~CMultiStringAttr();
  266. HRESULT Init(PATTR_MAP pAttrMap, PADS_ATTR_INFO pAttrInfo,
  267. BOOL fWritable = TRUE, int nLimit = 0,
  268. BOOL fCommaList = FALSE,
  269. BOOL fAppend = FALSE);
  270. HRESULT Write(PADS_ATTR_INFO pAttr);
  271. BOOL DoDlgInit(HWND hDlg);
  272. int DoCommand(HWND hDlg, int id, int code);
  273. BOOL DoNotify(HWND hDlg, NMHDR * pNmHdr);
  274. BOOL HasValues(void) {return m_AttrInfo.dwNumValues > 0;};
  275. void EnableControls(HWND hDlg, BOOL fEnable);
  276. void SetDirty(HWND hDlg);
  277. BOOL IsDirty(void) {return m_fDirty;};
  278. void ClearDirty(void) {m_fDirty = FALSE;};
  279. BOOL IsWritable(void) {return m_fWritable;};
  280. private:
  281. void ClearAttrInfo(void);
  282. CDsPropPageBase * m_pPage;
  283. ADS_ATTR_INFO m_AttrInfo;
  284. PWSTR m_pAttrLDAPname;
  285. int m_nMaxLen;
  286. int m_nCurDefCtrl;
  287. BOOL m_fListHasSel;
  288. int m_nLimit;
  289. int m_cValues;
  290. BOOL m_fWritable;
  291. BOOL m_fCommaList;
  292. BOOL m_fDirty;
  293. BOOL m_fAppend;
  294. };
  295. //+----------------------------------------------------------------------------
  296. //
  297. // Class: CMultiStringAttrDlg
  298. //
  299. // Purpose: Read, edit, and write a multi-valued, string property. This
  300. // is a dialog that hosts the CMultiStringAttr class.
  301. //
  302. //-----------------------------------------------------------------------------
  303. class CMultiStringAttrDlg
  304. {
  305. public:
  306. CMultiStringAttrDlg(CDsPropPageBase * pPage);
  307. ~CMultiStringAttrDlg() {};
  308. //
  309. // Static WndProc for multi-valued edit dialog.
  310. //
  311. static LRESULT CALLBACK StaticDlgProc(HWND hWnd, UINT uMsg,
  312. WPARAM wParam, LPARAM lParam);
  313. HRESULT Init(PATTR_MAP pAttrMap, PADS_ATTR_INFO pAttrInfo,
  314. BOOL fWritable = TRUE, int nLimit = 0,
  315. BOOL fCommaList = FALSE,
  316. BOOL fMultiselectPage = FALSE);
  317. INT_PTR Edit(void);
  318. HRESULT Write(PADS_ATTR_INFO pAttr);
  319. private:
  320. //
  321. // Dialog proc.
  322. //
  323. BOOL CALLBACK MultiValDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam,
  324. LPARAM lParam);
  325. void ClearAttrInfo(void);
  326. CMultiStringAttr m_MSA;
  327. CDsPropPageBase * m_pPage;
  328. };
  329. // Attribute function invoked by Other values button, manipulates the
  330. // CMultiStringAttr class.
  331. //
  332. HRESULT
  333. OtherValuesBtn(CDsPropPageBase * pPage, PATTR_MAP pAttrMap,
  334. PADS_ATTR_INFO pAttrInfo, LPARAM lParam, PATTR_DATA pAttrData,
  335. DLG_OP DlgOp);
  336. //+----------------------------------------------------------------------------
  337. //
  338. // Class: CDsIconCtrl
  339. //
  340. // Purpose: sub-class window proc for icon control.
  341. //
  342. //-----------------------------------------------------------------------------
  343. class CDsIconCtrl
  344. {
  345. public:
  346. #ifdef _DEBUG
  347. char szClass[32];
  348. #endif
  349. CDsIconCtrl(HWND hCtrl, HICON hIcon);
  350. ~CDsIconCtrl(void);
  351. //
  352. // Static WndProc to be passed as subclass address.
  353. //
  354. static LRESULT CALLBACK StaticCtrlProc(HWND hWnd, UINT uMsg,
  355. WPARAM wParam, LPARAM lParam);
  356. //
  357. // Member functions, called by WndProc
  358. //
  359. LRESULT OnPaint(void);
  360. //
  361. // Data members
  362. //
  363. protected:
  364. HWND m_hCtrl;
  365. HWND m_hDlg;
  366. WNDPROC m_pOldProc;
  367. HICON m_hIcon;
  368. };
  369. //+----------------------------------------------------------------------------
  370. //
  371. // Template: CSmartPtr
  372. //
  373. // Purpose: A simple smart pointer template that does cleanup with
  374. // the delete operator.
  375. //
  376. //-----------------------------------------------------------------------------
  377. template <class T>
  378. class CSmartPtr
  379. {
  380. public:
  381. CSmartPtr(void) {m_ptr = NULL; m_fDetached = FALSE;}
  382. CSmartPtr(DWORD dwSize) {m_ptr = new T[dwSize]; m_fDetached = FALSE;}
  383. ~CSmartPtr(void) {if (!m_fDetached) DO_DEL(m_ptr);}
  384. T* operator=(const CSmartPtr& src) {return src.m_ptr;}
  385. void operator=(const T* src) {if (!m_fDetached) DO_DEL(m_ptr); m_ptr = src;}
  386. operator const T*() {return m_ptr;}
  387. operator T*() {return m_ptr;}
  388. T* operator->() {dspAssert(m_ptr); return m_ptr;}
  389. T** operator&() {if (!m_fDetached) DO_DEL(m_ptr); return &m_ptr;}
  390. operator BOOL() const {return m_ptr != NULL;}
  391. BOOL operator!() {return m_ptr == NULL;}
  392. T* Detach() {m_fDetached = TRUE; return m_ptr;}
  393. private:
  394. T * m_ptr;
  395. BOOL m_fDetached;
  396. };
  397. //+----------------------------------------------------------------------------
  398. //
  399. // class: CSmartPtr for character string pointers.
  400. //
  401. // Purpose: Simple types don't allow the -> operator, so specialize the
  402. // template.
  403. //
  404. //-----------------------------------------------------------------------------
  405. #if !defined(UNICODE)
  406. template <> class CSmartPtr <TCHAR>
  407. {
  408. public:
  409. CSmartPtr(void) {m_ptr = NULL; m_fDetached = FALSE;}
  410. CSmartPtr(DWORD dwSize) {m_ptr = new TCHAR[dwSize]; m_fDetached = FALSE;}
  411. ~CSmartPtr(void) {if (!m_fDetached) DO_DEL(m_ptr);}
  412. TCHAR* operator=(const CSmartPtr& src) {return src.m_ptr;}
  413. void operator=(TCHAR* src) {if (!m_fDetached) DO_DEL(m_ptr); m_ptr = src;}
  414. operator const TCHAR*() {return m_ptr;}
  415. operator TCHAR*() {return m_ptr;}
  416. TCHAR** operator&() {if (!m_fDetached) DO_DEL(m_ptr); return &m_ptr;}
  417. operator BOOL() const {return m_ptr != NULL;}
  418. BOOL operator!() {return m_ptr == NULL;}
  419. TCHAR* Detach() {m_fDetached = TRUE; return m_ptr;}
  420. private:
  421. TCHAR * m_ptr;
  422. BOOL m_fDetached;
  423. };
  424. #endif
  425. template <> class CSmartPtr <WCHAR>
  426. {
  427. public:
  428. CSmartPtr(void) {m_ptr = NULL; m_fDetached = FALSE;}
  429. CSmartPtr(DWORD dwSize) {m_ptr = new WCHAR[dwSize]; m_fDetached = FALSE;}
  430. ~CSmartPtr(void) {if (!m_fDetached) DO_DEL(m_ptr);}
  431. WCHAR* operator=(const CSmartPtr& src) {return src.m_ptr;}
  432. void operator=(WCHAR* src) {if (!m_fDetached) DO_DEL(m_ptr); m_ptr = src;}
  433. operator const WCHAR*() {return m_ptr;}
  434. operator WCHAR*() {return m_ptr;}
  435. WCHAR** operator&() {if (!m_fDetached) DO_DEL(m_ptr); return &m_ptr;}
  436. operator BOOL() const {return m_ptr != NULL;}
  437. BOOL operator!() {return m_ptr == NULL;}
  438. WCHAR* Detach() {m_fDetached = TRUE; return m_ptr;}
  439. private:
  440. WCHAR * m_ptr;
  441. BOOL m_fDetached;
  442. };
  443. #define CSmartWStr CSmartPtr <WCHAR>
  444. template <> class CSmartPtr <PVOID>
  445. {
  446. public:
  447. CSmartPtr(void) {m_ptr = NULL; m_fDetached = FALSE;}
  448. CSmartPtr(DWORD dwSize) {m_ptr = new BYTE[dwSize]; m_fDetached = FALSE;}
  449. ~CSmartPtr(void)
  450. {
  451. if (!m_fDetached)
  452. DO_DEL(m_ptr);
  453. }
  454. PVOID operator=(const CSmartPtr& src) {return src.m_ptr;}
  455. void operator=(PVOID src) {if (!m_fDetached) DO_DEL(m_ptr); m_ptr = src;}
  456. operator const PVOID() {return m_ptr;}
  457. operator PVOID() {return m_ptr;}
  458. PVOID* operator&() {if (!m_fDetached) DO_DEL(m_ptr); return &m_ptr;}
  459. operator BOOL() const {return m_ptr != NULL;}
  460. BOOL operator!() {return m_ptr == NULL;}
  461. PVOID Detach() {m_fDetached = TRUE; return m_ptr;}
  462. private:
  463. PVOID m_ptr;
  464. BOOL m_fDetached;
  465. };
  466. class CSmartBytePtr
  467. {
  468. public:
  469. CSmartBytePtr(void) {m_ptr = NULL; m_fDetached = FALSE;}
  470. CSmartBytePtr(DWORD dwSize) {m_ptr = new BYTE[dwSize]; m_fDetached = FALSE;}
  471. ~CSmartBytePtr(void) {if (!m_fDetached) DO_DEL(m_ptr);}
  472. BYTE* operator=(const CSmartBytePtr& src) {return src.m_ptr;}
  473. void operator=(BYTE* src) {if (!m_fDetached) DO_DEL(m_ptr); m_ptr = src;}
  474. operator const BYTE*() {return m_ptr;}
  475. operator BYTE*() {return m_ptr;}
  476. BYTE** operator&() {if (!m_fDetached) DO_DEL(m_ptr); return &m_ptr;}
  477. operator BOOL() const {return m_ptr != NULL;}
  478. BOOL operator!() {return m_ptr == NULL;}
  479. BYTE* Detach() {m_fDetached = TRUE; return m_ptr;}
  480. private:
  481. BYTE * m_ptr;
  482. BOOL m_fDetached;
  483. };
  484. class CSimpleSecurityDescriptorHolder
  485. {
  486. public:
  487. CSimpleSecurityDescriptorHolder()
  488. {
  489. m_pSD = NULL;
  490. }
  491. ~CSimpleSecurityDescriptorHolder()
  492. {
  493. if (m_pSD != NULL)
  494. {
  495. ::LocalFree(m_pSD);
  496. m_pSD = NULL;
  497. }
  498. }
  499. PSECURITY_DESCRIPTOR m_pSD;
  500. private:
  501. CSimpleSecurityDescriptorHolder(const CSimpleSecurityDescriptorHolder&)
  502. {}
  503. CSimpleSecurityDescriptorHolder& operator=(const CSimpleSecurityDescriptorHolder&) {}
  504. };
  505. class CSimpleAclHolder
  506. {
  507. public:
  508. CSimpleAclHolder()
  509. {
  510. m_pAcl = NULL;
  511. }
  512. ~CSimpleAclHolder()
  513. {
  514. if (m_pAcl != NULL)
  515. ::LocalFree(m_pAcl);
  516. }
  517. PACL m_pAcl;
  518. };
  519. extern ATTR_MAP GenIcon;
  520. #ifdef DSADMIN
  521. //+----------------------------------------------------------------------------
  522. //
  523. // Class: CMultiSelectErrorDialog
  524. //
  525. // Purpose: Error Message box when multi-select proppages fail to apply all
  526. // properties. Each object is listed with each failure
  527. //
  528. //-----------------------------------------------------------------------------
  529. class CMultiSelectErrorDialog
  530. {
  531. public:
  532. CMultiSelectErrorDialog(HWND hNotifyObj, HWND hParent);
  533. ~CMultiSelectErrorDialog()
  534. {
  535. if (m_pDataObj != NULL)
  536. {
  537. m_pDataObj->Release();
  538. }
  539. }
  540. static LRESULT CALLBACK StaticDlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  541. HRESULT Init(CPageInfo* pPageInfoArray, UINT nPageCount, IDataObject* pDataObj);
  542. virtual int DoModal();
  543. virtual BOOL OnInitDialog(HWND hDlg);
  544. virtual void OnCopyButton();
  545. virtual void OnClose();
  546. virtual void ListItemActivate(LPNMHDR pnmh);
  547. virtual void ListItemClick(LPNMHDR pnmh);
  548. HRESULT InitializeListBox(HWND hDlg);
  549. virtual BOOL ShowWindow();
  550. BOOL ShowListViewItemProperties();
  551. HWND m_hWnd;
  552. BOOL m_bModal;
  553. private:
  554. HWND m_hNotifyObj;
  555. HWND m_hParent;
  556. BOOL m_bInit;
  557. HWND m_hList;
  558. IDataObject* m_pDataObj;
  559. UINT m_nPageCount;
  560. CPageInfo* m_pPageInfoArray;
  561. };
  562. #endif // DSADMIN
  563. #endif // _PROPUTIL_H_