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.

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