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.

1990 lines
42 KiB

  1. /*++
  2. Copyright (c) 1994-1998 Microsoft Corporation
  3. Module Name :
  4. mdkeys.h
  5. Abstract:
  6. Metabase key wrapper classes
  7. Author:
  8. Ronald Meijer (ronaldm)
  9. Project:
  10. Internet Services Manager
  11. Revision History:
  12. --*/
  13. #ifndef _MDKEYS_H_
  14. #define _MDKEYS_H_
  15. //
  16. // Include Files
  17. //
  18. #include <iadmw.h>
  19. #include <iwamreg.h>
  20. #include <iiscnfgp.h>
  21. #include <winsvc.h>
  22. #include <iisrsta.h>
  23. //
  24. // Forward definitions
  25. //
  26. class CBlob;
  27. //
  28. // Use this instance number to denote the master
  29. //
  30. #define MASTER_INSTANCE (0)
  31. #define IS_MASTER_INSTANCE(i) (i == MASTER_INSTANCE ? TRUE : FALSE)
  32. //
  33. // Metabase node constants, used for static initialization of const
  34. // strings further down. Defined here with #defines for easier
  35. // concatenation later.
  36. //
  37. #define SZ_MBN_MACHINE _T("LM")
  38. #define SZ_MBN_FILTERS _T("Filters")
  39. #define SZ_MBN_MIMEMAP _T("MimeMap")
  40. #define SZ_MBN_TEMPLATES _T("Templates")
  41. #define SZ_MBN_INFO _T("Info")
  42. #define SZ_MBN_ROOT _T("Root")
  43. #define SZ_MBN_COMPRESSION _T("Compression")
  44. #define SZ_MBN_PARAMETERS _T("Parameters")
  45. #define SZ_MBN_SEP_CHAR _T('/')
  46. #define SZ_MBN_SEP_STR _T("/")
  47. #define SZ_MBN_WEB _T("W3SVC")
  48. #define SZ_MBN_FTP _T("MSFTPSVC")
  49. class COMDLL CMetaInterface
  50. /*++
  51. Class description:
  52. Metabase interface class
  53. Virtual Interface:
  54. Succeeded : Return TRUE if item constructed successfully
  55. QueryResult : Return construction error code
  56. Public Interface:
  57. operator BOOL : Cast to TRUE/FALSE depending on success
  58. operator HRESULT : Cast to the HRESULT status
  59. QueryServerName : Get the server name
  60. Regenerate : Recreate the interface
  61. --*/
  62. {
  63. //
  64. // Constructor/Destructor
  65. //
  66. protected:
  67. //
  68. // Fully defined constructor that creates the interface.
  69. // Use NULL to indicate the local computer name
  70. //
  71. CMetaInterface(
  72. IN LPCTSTR lpszServerName = NULL
  73. );
  74. //
  75. // Construct from existing interface
  76. //
  77. CMetaInterface(
  78. IN const CMetaInterface * pInterface
  79. );
  80. //
  81. // Destructor destroys the interface
  82. //
  83. ~CMetaInterface();
  84. //
  85. // Virtual Interface:
  86. //
  87. public:
  88. virtual BOOL Succeeded() const;
  89. virtual HRESULT QueryResult() const;
  90. //
  91. // ISSUE: Does this break encapsulation?
  92. //
  93. public:
  94. LPCTSTR QueryServerName() const { return m_strServerName; }
  95. HRESULT Regenerate();
  96. //
  97. // Conversion Operators
  98. //
  99. public:
  100. operator BOOL() const { return Succeeded(); }
  101. operator HRESULT() const { return m_hrInterface; }
  102. protected:
  103. //
  104. // Create a metadata object in this server. This function initializes the
  105. // metadata object with DCOM.
  106. //
  107. HRESULT Create(
  108. IN LPCTSTR lpszServerName = NULL
  109. );
  110. //
  111. // Make sure the interface has been created
  112. //
  113. BOOL HasInterface() const { return m_pInterface != NULL; }
  114. //
  115. // IADMW Interface
  116. //
  117. protected:
  118. HRESULT OpenKey(
  119. IN METADATA_HANDLE hkBase,
  120. IN LPCTSTR lpszMDPath,
  121. IN DWORD dwFlags,
  122. OUT METADATA_HANDLE * phMDNewHandle
  123. );
  124. HRESULT CloseKey(
  125. IN METADATA_HANDLE hKey
  126. );
  127. HRESULT SetLastChangeTime(
  128. IN METADATA_HANDLE hMDHandle,
  129. IN LPCTSTR pszMDPath,
  130. IN FILETIME * pftMDLastChangeTime,
  131. IN BOOL bLocalTime
  132. );
  133. HRESULT GetLastChangeTime(
  134. IN METADATA_HANDLE hMDHandle,
  135. IN LPCTSTR lpszMDPath,
  136. OUT FILETIME * pftMDLastChangeTime,
  137. IN BOOL bLocalTime
  138. );
  139. HRESULT AddKey(
  140. IN METADATA_HANDLE hKey,
  141. IN LPCTSTR lpszMDPath
  142. );
  143. HRESULT DeleteKey(
  144. IN METADATA_HANDLE hKey,
  145. IN LPCTSTR lpszMDPath
  146. );
  147. HRESULT DeleteChildKeys(
  148. IN METADATA_HANDLE hKey,
  149. IN LPCTSTR lpszMDPath
  150. );
  151. HRESULT EnumKeys(
  152. IN METADATA_HANDLE hKey,
  153. IN LPCTSTR lpszMDPath,
  154. OUT LPTSTR lpszMDName,
  155. IN DWORD dwIndex
  156. );
  157. HRESULT CopyKey(
  158. IN METADATA_HANDLE hSourceKey,
  159. IN LPCTSTR lpszMDSourcePath,
  160. IN METADATA_HANDLE hDestKey,
  161. IN LPCTSTR lpszMDDestPath,
  162. IN BOOL fOverwrite,
  163. IN BOOL fCopy
  164. );
  165. HRESULT RenameKey(
  166. IN METADATA_HANDLE hKey,
  167. IN LPCTSTR lpszMDPath,
  168. IN LPCTSTR lpszNewName
  169. );
  170. HRESULT GetData(
  171. IN METADATA_HANDLE hKey,
  172. IN LPCTSTR lpszMDPath,
  173. OUT METADATA_RECORD * pmdRecord,
  174. OUT DWORD * pdwRequiredDataLen
  175. );
  176. HRESULT SetData(
  177. IN METADATA_HANDLE hKey,
  178. IN LPCTSTR lpszMDPath,
  179. IN METADATA_RECORD * pmdRecord
  180. );
  181. HRESULT DeleteData(
  182. IN METADATA_HANDLE hKey,
  183. IN LPCTSTR lpszMDPath,
  184. IN DWORD dwMDIdentifier,
  185. IN DWORD dwMDDataType
  186. );
  187. HRESULT EnumData(
  188. IN METADATA_HANDLE hKey,
  189. IN LPCTSTR lpszMDPath,
  190. OUT METADATA_RECORD * pmdRecord,
  191. IN DWORD dwIndex,
  192. OUT DWORD * pdwRequiredDataLen
  193. );
  194. HRESULT GetAllData(
  195. IN METADATA_HANDLE hKey,
  196. IN LPCTSTR lpszMDPath,
  197. IN DWORD dwMDAttributes,
  198. IN DWORD dwMDUserType,
  199. IN DWORD dwMDDataType,
  200. OUT DWORD * pdwMDNumDataEntries,
  201. OUT DWORD * pdwMDDataSetNumber,
  202. IN DWORD dwMDBufferSize,
  203. OUT LPBYTE pbMDBuffer,
  204. OUT DWORD * pdwRequiredBufferSize
  205. );
  206. HRESULT DeleteAllData(
  207. IN METADATA_HANDLE hKey,
  208. IN LPCTSTR lpszMDPath,
  209. IN DWORD dwMDUserType,
  210. IN DWORD dwMDDataType
  211. );
  212. HRESULT CopyData(
  213. IN METADATA_HANDLE hMDSourceKey,
  214. IN LPCTSTR lpszMDSourcePath,
  215. IN METADATA_HANDLE hMDDestKey,
  216. IN LPCTSTR lpszMDDestPath,
  217. IN DWORD dwMDAttributes,
  218. IN DWORD dwMDUserType,
  219. IN DWORD dwMDDataType,
  220. IN BOOL fCopy
  221. );
  222. HRESULT GetDataPaths(
  223. IN METADATA_HANDLE hKey,
  224. IN LPCTSTR lpszMDPath,
  225. IN DWORD dwMDIdentifier,
  226. IN DWORD dwMDDataType,
  227. IN DWORD dwMDBufferSize,
  228. OUT LPTSTR lpszBuffer,
  229. OUT DWORD * pdwMDRequiredBufferSize
  230. );
  231. HRESULT Backup(
  232. IN LPCTSTR lpszBackupLocation,
  233. IN DWORD dwMDVersion,
  234. IN DWORD dwMDFlags
  235. );
  236. HRESULT BackupWithPassword(
  237. IN LPCTSTR lpszBackupLocation,
  238. IN DWORD dwMDVersion,
  239. IN DWORD dwMDFlags,
  240. IN LPCTSTR lpszPassword
  241. );
  242. HRESULT Restore(
  243. IN LPCTSTR lpszBackupLocation,
  244. IN DWORD dwMDVersion,
  245. IN DWORD dwMDFlags
  246. );
  247. HRESULT RestoreWithPassword(
  248. IN LPCTSTR lpszBackupLocation,
  249. IN DWORD dwMDVersion,
  250. IN DWORD dwMDFlags,
  251. IN LPCTSTR lpszPassword
  252. );
  253. HRESULT EnumBackups(
  254. OUT LPTSTR lpszBackupLocation,
  255. OUT DWORD * pdwMDVersion,
  256. OUT FILETIME * pftMDBackupTime,
  257. IN DWORD dwIndex
  258. );
  259. HRESULT DeleteBackup(
  260. IN LPCTSTR lpszBackupLocation,
  261. IN DWORD dwMDVersion
  262. );
  263. protected:
  264. CString m_strServerName;
  265. IMSAdminBase * m_pInterface;
  266. private:
  267. int m_iTimeOutValue;
  268. HRESULT m_hrInterface;
  269. };
  270. class COMDLL CWamInterface
  271. /*++
  272. Class description:
  273. WAM interface class
  274. Virtual Interface:
  275. Succeeded : Return TRUE if item constructed successfully
  276. QueryResult : Return construction error code
  277. Public Interface:
  278. operator BOOL : Cast to TRUE/FALSE depending on success
  279. operator HRESULT : Cast to the HRESULT status
  280. SupportsPooledProc : Check to see if pooled out of proc is supported.
  281. --*/
  282. {
  283. //
  284. // App Protection States:
  285. //
  286. public:
  287. enum
  288. {
  289. //
  290. // Note: order must match MD_APP_ISOLATED values
  291. //
  292. APP_INPROC,
  293. APP_OUTOFPROC,
  294. APP_POOLEDPROC,
  295. };
  296. //
  297. // Constructor/Destructor
  298. //
  299. protected:
  300. //
  301. // Fully defined constructor that creates the interface.
  302. // Use NULL to create the interface on the local computer
  303. //
  304. CWamInterface(
  305. IN LPCTSTR lpszServerName = NULL
  306. );
  307. //
  308. // Construct from existing interface.
  309. //
  310. CWamInterface(
  311. IN const CWamInterface * pInterface
  312. );
  313. //
  314. // Destructor destroys the interface
  315. //
  316. ~CWamInterface();
  317. //
  318. // Virtual Interface:
  319. //
  320. public:
  321. virtual BOOL Succeeded() const;
  322. virtual HRESULT QueryResult() const;
  323. //
  324. // Conversion Operators
  325. //
  326. public:
  327. operator BOOL() const { return Succeeded(); }
  328. operator HRESULT() const { return m_hrInterface; }
  329. //
  330. // Access
  331. //
  332. public:
  333. BOOL SupportsPooledProc() const { return m_fSupportsPooledProc; }
  334. protected:
  335. //
  336. // Create a wam object in this server. This function initializes the
  337. // object with DCOM.
  338. //
  339. HRESULT Create(
  340. IN LPCTSTR lpszServerName = NULL
  341. );
  342. //
  343. // Make sure the interface has been created
  344. //
  345. BOOL HasInterface() const { return m_pInterface != NULL; }
  346. //
  347. // IWAM Interface
  348. //
  349. protected:
  350. HRESULT AppCreate(
  351. IN LPCTSTR szMDPath,
  352. IN DWORD dwAppProtection
  353. );
  354. HRESULT AppDelete(
  355. IN LPCTSTR szMDPath,
  356. IN BOOL fRecursive
  357. );
  358. HRESULT AppUnLoad(
  359. IN LPCTSTR szMDPath,
  360. IN BOOL fRecursive
  361. );
  362. HRESULT AppGetStatus(
  363. IN LPCTSTR szMDPath,
  364. OUT DWORD * pdwAppStatus
  365. );
  366. HRESULT AppDeleteRecoverable(
  367. IN LPCTSTR szMDPath,
  368. IN BOOL fRecursive
  369. );
  370. HRESULT AppRecover(
  371. IN LPCTSTR szMDPath,
  372. IN BOOL fRecursive
  373. );
  374. protected:
  375. CString m_strServerName;
  376. IWamAdmin * m_pInterface;
  377. private:
  378. HRESULT m_hrInterface;
  379. BOOL m_fSupportsPooledProc;
  380. };
  381. class COMDLL CMetaBack : public CMetaInterface, public CWamInterface
  382. /*++
  383. Class Description:
  384. Metabase backup/restore class
  385. Virtual Interface:
  386. Succeeded : Return TRUE if item constructed successfully
  387. QueryResult : Return construction error code
  388. Public Interface:
  389. Reset : Enum first existing backup
  390. Next : Enum next existing backup
  391. Backup : Create new backup
  392. Delete : Delete existing backup
  393. Restore : Restore from existing backup
  394. --*/
  395. {
  396. public:
  397. //
  398. // Construct and create the interfaces. Use NULL to create
  399. // on the local computer.
  400. //
  401. CMetaBack(
  402. IN LPCTSTR lpszServerName = NULL
  403. );
  404. //
  405. // Virtual Interface
  406. //
  407. public:
  408. virtual BOOL Succeeded() const;
  409. virtual HRESULT QueryResult() const;
  410. //
  411. // Interface
  412. //
  413. public:
  414. //
  415. // Reset counter
  416. //
  417. void Reset() { m_dwIndex = 0L; }
  418. HRESULT Next(
  419. OUT DWORD * pdwVersion,
  420. OUT LPTSTR lpszLocation,
  421. OUT FILETIME * pftBackupTime
  422. );
  423. HRESULT Backup(
  424. IN LPCTSTR lpszLocation
  425. );
  426. HRESULT BackupWithPassword(
  427. IN LPCTSTR lpszLocation,
  428. IN LPCTSTR lpszPassword
  429. );
  430. HRESULT Delete(
  431. IN LPCTSTR lpszLocation,
  432. IN DWORD dwVersion
  433. );
  434. HRESULT Restore(
  435. IN LPCTSTR lpszLocation,
  436. IN DWORD dwVersion
  437. );
  438. HRESULT RestoreWithPassword(
  439. IN LPCTSTR lpszLocation,
  440. IN DWORD dwVersion,
  441. IN LPCTSTR lpszPassword
  442. );
  443. protected:
  444. static const LPCTSTR s_szMasterAppRoot;
  445. private:
  446. DWORD m_dwIndex;
  447. };
  448. class COMDLL CMetaKey : public CMetaInterface
  449. /*++
  450. Class Description:
  451. Metabase key wrapper class
  452. Public Interface:
  453. CMetaKey : Constructor
  454. ~CMetaKey : Destructor
  455. Succeeded : TRUE if key opened successfully.
  456. QueryResult : Get the HRESULT status
  457. QueryValue : Various overloaded methods to get values
  458. SetValue : Various overloaded methods to set values
  459. DeleteValue : Delete a value
  460. Open : Open key
  461. ReOpen : Re key that was opened before
  462. Close : Close key
  463. ConvertToParentPath : Change path to parent path
  464. operator METADATA_HANDLE : Cast to a metadata handle
  465. operator LPCTSTR : Cast to the metabase path
  466. operator BOOL : Cast to TRUE if the key is open, FALSE if not
  467. GetHandle : Obtain metadata handle
  468. IsOpen : TRUE if a key is open
  469. QueryMetaPath : Get the relative metabase path
  470. QueryFlags : Get the open permissions
  471. --*/
  472. {
  473. //
  474. // Constructor/Destructor
  475. //
  476. public:
  477. //
  478. // Null constructor that only creates the interface.
  479. // A key constructed this way may read from META_ROOT_HANDLE.
  480. // This is not true of other constructors.
  481. //
  482. CMetaKey(
  483. IN LPCTSTR lpszServerName = NULL
  484. );
  485. //
  486. // As above, using an existing interface
  487. //
  488. CMetaKey(
  489. IN const CMetaInterface * pInterface
  490. );
  491. //
  492. // Fully defined constructor that opens a key
  493. //
  494. CMetaKey(
  495. IN LPCTSTR lpszServerName,
  496. IN DWORD dwFlags,
  497. IN METADATA_HANDLE hkBase = METADATA_MASTER_ROOT_HANDLE,
  498. IN LPCTSTR lpszMDPath = NULL
  499. );
  500. //
  501. // As above, using an existing interface
  502. //
  503. CMetaKey(
  504. IN const CMetaInterface * pInterface,
  505. IN DWORD dwFlags,
  506. IN METADATA_HANDLE hkBase = METADATA_MASTER_ROOT_HANDLE,
  507. IN LPCTSTR lpszMDPath = NULL
  508. );
  509. //
  510. // Constructor that takes portions of a metabase path.
  511. // and opens a key
  512. //
  513. CMetaKey(
  514. IN LPCTSTR lpszServerName,
  515. IN DWORD dwFlags,
  516. IN LPCTSTR lpSvc, // Or NULL or _T("")
  517. IN DWORD dwInstance = MASTER_INSTANCE,
  518. IN LPCTSTR lpParentPath = NULL,
  519. IN LPCTSTR lpAlias = NULL
  520. );
  521. //
  522. // As above, using an existing interface
  523. //
  524. CMetaKey(
  525. IN const CMetaInterface * pInterface,
  526. IN DWORD dwFlags,
  527. IN LPCTSTR lpSvc, // Or NULL or _T("")
  528. IN DWORD dwInstance = MASTER_INSTANCE,
  529. IN LPCTSTR lpParentPath = NULL,
  530. IN LPCTSTR lpAlias = NULL
  531. );
  532. //
  533. // Copy constructor, might or might not own the key
  534. //
  535. CMetaKey(
  536. IN BOOL fOwnKey,
  537. IN const CMetaKey * pKey
  538. );
  539. //
  540. // Destructor -- closes key.
  541. //
  542. ~CMetaKey();
  543. //
  544. // Interface
  545. //
  546. public:
  547. //
  548. // Fetch a DWORD
  549. //
  550. HRESULT QueryValue(
  551. IN DWORD dwID,
  552. OUT DWORD & dwValue,
  553. IN BOOL * pfInheritanceOverride = NULL,
  554. IN LPCTSTR lpszMDPath = NULL,
  555. OUT DWORD * pdwAttributes = NULL
  556. );
  557. //
  558. // Fetch a boolean
  559. //
  560. HRESULT QueryValue(
  561. IN DWORD dwID,
  562. OUT BOOL & fValue,
  563. IN BOOL * pfInheritanceOverride = NULL,
  564. IN LPCTSTR lpszMDPath = NULL,
  565. OUT DWORD * pdwAttributes = NULL
  566. );
  567. //
  568. // Fetch a string
  569. //
  570. HRESULT QueryValue(
  571. IN DWORD dwID,
  572. OUT CString & strValue,
  573. IN BOOL * pfInheritanceOverride = NULL,
  574. IN LPCTSTR lpszMDPath = NULL,
  575. OUT DWORD * pdwAttributes = NULL
  576. );
  577. //
  578. // Fetch a string list
  579. //
  580. HRESULT QueryValue(
  581. IN DWORD dwID,
  582. OUT CStringListEx & strlValue,
  583. IN BOOL * pfInheritanceOverride = NULL,
  584. IN LPCTSTR lpszMDPath = NULL,
  585. OUT DWORD * pdwAttributes = NULL
  586. );
  587. //
  588. // Fetch binary blob
  589. //
  590. HRESULT QueryValue(
  591. IN DWORD dwID,
  592. OUT CBlob & blValue,
  593. IN BOOL * pfInheritanceOverride = NULL,
  594. IN LPCTSTR lpszMDPath = NULL,
  595. OUT DWORD * pdwAttributes = NULL
  596. );
  597. //
  598. // Store a DWORD
  599. //
  600. HRESULT SetValue(
  601. IN DWORD dwID,
  602. IN DWORD dwValue,
  603. IN BOOL * pfInheritanceOverride = NULL,
  604. IN LPCTSTR lpszMDPath = NULL
  605. );
  606. //
  607. // Store a BOOL
  608. //
  609. HRESULT SetValue(
  610. IN DWORD dwID,
  611. IN BOOL fValue,
  612. IN BOOL * pfInheritanceOverride = NULL,
  613. IN LPCTSTR lpszMDPath = NULL
  614. );
  615. //
  616. // Store a string
  617. //
  618. HRESULT SetValue(
  619. IN DWORD dwID,
  620. IN CString & strValue,
  621. IN BOOL * pfInheritanceOverride = NULL,
  622. IN LPCTSTR lpszMDPath = NULL
  623. );
  624. //
  625. // Store a stringlist
  626. //
  627. HRESULT SetValue(
  628. IN DWORD dwID,
  629. IN CStringListEx & strlValue,
  630. IN BOOL * pfInheritanceOverride = NULL,
  631. IN LPCTSTR lpszMDPath = NULL
  632. );
  633. //
  634. // Store a binary blob
  635. //
  636. HRESULT SetValue(
  637. IN DWORD dwID,
  638. IN CBlob & blValue,
  639. IN BOOL * pfInheritanceOverride = NULL,
  640. IN LPCTSTR lpszMDPath = NULL
  641. );
  642. //
  643. // Delete Value:
  644. //
  645. HRESULT DeleteValue(
  646. IN DWORD dwID,
  647. IN LPCTSTR lpszMDPath = NULL
  648. );
  649. //
  650. // Check for path existance
  651. //
  652. HRESULT DoesPathExist(
  653. IN LPCTSTR lpszMDPath
  654. );
  655. //
  656. // Create current path (which we attempted to open, and got
  657. // a path not found error on).
  658. //
  659. HRESULT CreatePathFromFailedOpen();
  660. //
  661. // Check for descendant overrides
  662. //
  663. HRESULT CheckDescendants(
  664. IN DWORD dwID,
  665. IN LPCTSTR lpszServer,
  666. IN LPCTSTR lpszMDPath = NULL
  667. );
  668. //
  669. // Open key
  670. //
  671. HRESULT Open(
  672. IN DWORD dwFlags,
  673. IN METADATA_HANDLE hkBase,
  674. IN LPCTSTR lpszMDPath = NULL
  675. );
  676. //
  677. // Assemble metabase path and open key
  678. //
  679. HRESULT Open(
  680. IN DWORD dwFlags,
  681. IN LPCTSTR lpSvc = NULL,
  682. IN DWORD dwInstance = MASTER_INSTANCE,
  683. IN LPCTSTR lpParentPath = NULL,
  684. IN LPCTSTR lpAlias = NULL
  685. );
  686. //
  687. // Re-open previously opened key
  688. //
  689. HRESULT ReOpen(
  690. IN DWORD dwFlags
  691. );
  692. //
  693. // As above using the same permissions as before
  694. //
  695. HRESULT ReOpen();
  696. //
  697. // Open the parent object
  698. //
  699. HRESULT ConvertToParentPath(
  700. IN BOOL fImmediate
  701. );
  702. //
  703. // Close key, set it to NULL, but doesn't destroy the interface
  704. //
  705. HRESULT Close();
  706. //
  707. // Add key
  708. //
  709. HRESULT AddKey(
  710. IN LPCTSTR lpszMDPath
  711. );
  712. //
  713. // Delete key off currently open key
  714. //
  715. HRESULT DeleteKey(
  716. IN LPCTSTR lpszMDPath
  717. );
  718. //
  719. // Rename key off currently open key
  720. //
  721. HRESULT RenameKey(
  722. IN LPCTSTR lpszMDPath,
  723. IN LPCTSTR lpszNewName
  724. );
  725. //
  726. // Get list of descendant nodes that override
  727. // a specific value
  728. //
  729. HRESULT GetDataPaths(
  730. OUT CStringListEx & strlNodes,
  731. IN DWORD dwMDIdentifier,
  732. IN DWORD dwMDDataType,
  733. IN LPCTSTR lpszMDPath = NULL
  734. );
  735. //
  736. // Clean metabase path
  737. //
  738. static LPCTSTR CleanMetaPath(
  739. IN OUT CString & strMetaRoot
  740. );
  741. static void ConvertToParentPath(
  742. IN OUT CString & strService,
  743. IN OUT DWORD & dwInstance,
  744. IN OUT CString & strParent,
  745. IN OUT CString & strAlias
  746. );
  747. static LPCTSTR ConvertToParentPath(
  748. OUT IN CString & strMetaPath
  749. );
  750. static BOOL IsHomeDirectoryPath(
  751. IN LPCTSTR lpszMetaPath
  752. );
  753. //
  754. // Access
  755. //
  756. public:
  757. METADATA_HANDLE GetHandle() const { return m_hKey; }
  758. METADATA_HANDLE GetBase() const { return m_hBase; }
  759. LPCTSTR QueryMetaPath() const { return m_strMetaPath; }
  760. DWORD QueryFlags() const { return m_dwFlags; }
  761. BOOL IsOpen() const { return m_hKey != NULL; }
  762. BOOL IsHomeDirectoryPath();
  763. //
  764. // Conversion operators
  765. //
  766. public:
  767. operator METADATA_HANDLE() const { return GetHandle(); }
  768. operator LPCTSTR() const { return QueryMetaPath(); }
  769. operator BOOL() const { return IsOpen(); }
  770. //
  771. // Virtual Interface:
  772. //
  773. public:
  774. virtual BOOL Succeeded() const;
  775. virtual HRESULT QueryResult() const;
  776. protected:
  777. //
  778. // Split metapath into parent and single node
  779. //
  780. static void SplitMetaPath(
  781. IN LPCTSTR lpPath,
  782. OUT CString & strParent,
  783. OUT CString & strAlias
  784. );
  785. //
  786. // Split the metapath at the instance border
  787. //
  788. static void SplitMetaPathAtInstance(
  789. IN LPCTSTR lpPath,
  790. OUT CString & strParent,
  791. OUT CString & strAlias
  792. );
  793. static LPCTSTR BuildMetaPath(
  794. OUT CString & strPath,
  795. IN LPCTSTR lpSvc = NULL,
  796. IN DWORD dwInstance = NULL,
  797. IN LPCTSTR lpParentPath = NULL,
  798. IN LPCTSTR lpAlias = NULL
  799. );
  800. //
  801. // Protected members
  802. //
  803. protected:
  804. //
  805. // Get data
  806. //
  807. HRESULT GetPropertyValue(
  808. IN DWORD dwID,
  809. OUT IN DWORD & dwSize,
  810. OUT IN void *& pvData,
  811. OUT IN DWORD * pdwDataType = NULL,
  812. IN BOOL * pfInheritanceOverride = NULL,
  813. IN LPCTSTR lpszMDPath = NULL,
  814. OUT DWORD * pdwAttributes = NULL
  815. );
  816. //
  817. // Store data
  818. //
  819. HRESULT SetPropertyValue(
  820. IN DWORD dwID,
  821. IN DWORD dwSize,
  822. IN void * pvData,
  823. IN BOOL * pfInheritanceOverride = NULL,
  824. IN LPCTSTR lpszMDPath = NULL
  825. );
  826. //
  827. // Get All Data off the open key
  828. //
  829. HRESULT GetAllData(
  830. IN DWORD dwMDAttributes,
  831. IN DWORD dwMDUserType,
  832. IN DWORD dwMDDataType,
  833. OUT DWORD * pdwMDNumEntries,
  834. OUT DWORD * pdwMDDataLen,
  835. OUT PBYTE * ppbMDData,
  836. IN LPCTSTR lpszMDPath = NULL
  837. );
  838. //
  839. // Property Table Methods
  840. //
  841. protected:
  842. //
  843. // Metabase table entry definition
  844. //
  845. typedef struct tagMDFIELDDEF
  846. {
  847. DWORD dwMDIdentifier;
  848. DWORD dwMDAttributes;
  849. DWORD dwMDUserType;
  850. DWORD dwMDDataType;
  851. UINT uStringID;
  852. } MDFIELDDEF;
  853. static const MDFIELDDEF s_rgMetaTable[];
  854. //
  855. // CODEWORK: Ideally, these should be protected, but are used
  856. // by idlg.
  857. //
  858. public:
  859. static BOOL GetMDFieldDef(
  860. IN DWORD dwID,
  861. OUT DWORD & dwMDIdentifier,
  862. OUT DWORD & dwMDAttributes,
  863. OUT DWORD & dwMDUserType,
  864. OUT DWORD & dwMDDataType
  865. );
  866. //
  867. // Map metabase ID value to table index
  868. //
  869. static int MapMDIDToTableIndex(
  870. IN DWORD dwID
  871. );
  872. //
  873. // Allow limited access to the table
  874. //
  875. public:
  876. static BOOL IsPropertyInheritable(
  877. IN DWORD dwID
  878. );
  879. static BOOL GetPropertyDescription(
  880. IN DWORD dwID,
  881. OUT CString & strName
  882. );
  883. protected:
  884. static const LPCTSTR s_cszCompression;
  885. static const LPCTSTR s_cszMachine;
  886. static const LPCTSTR s_cszMimeMap;
  887. static const LPCTSTR s_cszRoot;
  888. static const LPCTSTR s_cszSep;
  889. static const LPCTSTR s_cszInfo;
  890. static const TCHAR s_chSep;
  891. protected:
  892. BOOL m_fAllowRootOperations;
  893. BOOL m_fOwnKey;
  894. DWORD m_cbInitialBufferSize;
  895. DWORD m_dwFlags;
  896. CString m_strMetaPath;
  897. HRESULT m_hrKey;
  898. METADATA_HANDLE m_hKey;
  899. METADATA_HANDLE m_hBase;
  900. };
  901. class COMDLL CMetaEnumerator : public CMetaKey
  902. /*++
  903. Class Description:
  904. Metabase key enumerator
  905. Public Interface:
  906. CMetaEnumerator : Constructor
  907. Reset : Reset the enumerator
  908. Next : Get next key
  909. --*/
  910. {
  911. public:
  912. CMetaEnumerator(
  913. IN LPCTSTR lpszServerName,
  914. IN LPCTSTR lpSvc = NULL,
  915. IN DWORD dwInstance = MASTER_INSTANCE,
  916. IN LPCTSTR lpParentPath = NULL,
  917. IN LPCTSTR lpAlias = NULL
  918. );
  919. //
  920. // Constructor with existing interface
  921. //
  922. CMetaEnumerator(
  923. IN CMetaInterface * pInterface,
  924. IN LPCTSTR lpSvc = NULL,
  925. IN DWORD dwInstance = MASTER_INSTANCE,
  926. IN LPCTSTR lpParentPath = NULL,
  927. IN LPCTSTR lpAlias = NULL
  928. );
  929. //
  930. // Interface:
  931. //
  932. public:
  933. //
  934. // Reset counter
  935. //
  936. void Reset() { m_dwIndex = 0L; }
  937. //
  938. // Get next key as string.
  939. //
  940. HRESULT Next(
  941. OUT CString & strKey,
  942. IN LPCTSTR lpszMDPath = NULL
  943. );
  944. //
  945. // Get next key as a DWORD (numeric keys only)
  946. //
  947. HRESULT Next(
  948. OUT DWORD & dwKey,
  949. IN LPCTSTR lpszMDPath = NULL
  950. );
  951. private:
  952. DWORD m_dwIndex;
  953. };
  954. class COMDLL CIISApplication : public CWamInterface, public CMetaKey
  955. /*++
  956. Class Description:
  957. IIS Application class
  958. Virtual Interface:
  959. Succeeded : Return TRUE if item constructed successfully
  960. QueryResult : Return construction error code
  961. Public Interface:
  962. RefreshState : Refresh application state
  963. QueryAppState : Return current application state
  964. IsEnabledApplication: Return TRUE if appplication is enabled.
  965. Create : Create app
  966. Delete : Delete app
  967. Unload : Unload app
  968. DeleteRecoverable : Delete w. recovery allowed
  969. Recover : Recover
  970. WriteFriendlyName : Write friendly name to metabase
  971. --*/
  972. {
  973. //
  974. // Constructor/Destructor
  975. //
  976. public:
  977. CIISApplication(
  978. IN LPCTSTR lpszServer,
  979. IN LPCTSTR lpszMetapath
  980. );
  981. CIISApplication(
  982. IN LPCTSTR lpszServer,
  983. IN LPCTSTR lpSvc,
  984. IN DWORD dwInstance,
  985. IN LPCTSTR lpParentPath = NULL,
  986. IN LPCTSTR lpAlias = NULL
  987. );
  988. //
  989. // Virtual Interface:
  990. //
  991. public:
  992. virtual BOOL Succeeded() const;
  993. virtual HRESULT QueryResult() const;
  994. //
  995. // Interface
  996. //
  997. public:
  998. DWORD QueryAppState() const { return m_dwAppState; }
  999. LPCTSTR QueryWamPath() const { return m_strWamPath; }
  1000. BOOL IsEnabledApplication() const;
  1001. HRESULT RefreshAppState();
  1002. HRESULT Create(LPCTSTR lpszName, DWORD dwAppProtection);
  1003. HRESULT Delete(BOOL fRecursive = FALSE);
  1004. HRESULT Unload(BOOL fRecursive = FALSE);
  1005. HRESULT DeleteRecoverable(BOOL fRecursive = FALSE);
  1006. HRESULT Recover(BOOL fRecursive = FALSE);
  1007. HRESULT WriteFriendlyName(LPCTSTR lpszName);
  1008. public:
  1009. BOOL IsInproc() const { return m_dwProcessProtection == APP_INPROC; }
  1010. BOOL IsOutOfProc() const { return m_dwProcessProtection == APP_OUTOFPROC; }
  1011. BOOL IsPooledProc() const { return m_dwProcessProtection == APP_POOLEDPROC; }
  1012. public:
  1013. DWORD m_dwProcessProtection;
  1014. CString m_strFriendlyName;
  1015. CString m_strAppRoot;
  1016. protected:
  1017. void CommonConstruct();
  1018. private:
  1019. DWORD m_dwAppState;
  1020. CString m_strWamPath;
  1021. HRESULT m_hrApp;
  1022. };
  1023. class COMDLL CIISSvcControl
  1024. /*++
  1025. Class description:
  1026. IIS Service control
  1027. Virtual Interface:
  1028. Succeeded : Return TRUE if item constructed successfully
  1029. QueryResult : Return construction error code
  1030. Public Interface:
  1031. operator BOOL : Cast to TRUE/FALSE depending on success
  1032. operator HRESULT : Cast to the HRESULT status
  1033. --*/
  1034. {
  1035. //
  1036. // Constructor/Destructor
  1037. //
  1038. public:
  1039. //
  1040. // Fully defined constructor that creates the interface.
  1041. // Use NULL to create the interface on the local computer
  1042. //
  1043. CIISSvcControl(
  1044. IN LPCTSTR lpszServerName = NULL
  1045. );
  1046. //
  1047. // Construct from existing interface.
  1048. //
  1049. CIISSvcControl(
  1050. IN const CIISSvcControl * pInterface
  1051. );
  1052. //
  1053. // Destructor destroys the interface
  1054. //
  1055. ~CIISSvcControl();
  1056. //
  1057. // Virtual Interface:
  1058. //
  1059. public:
  1060. virtual BOOL Succeeded() const;
  1061. virtual HRESULT QueryResult() const;
  1062. //
  1063. // Conversion Operators
  1064. //
  1065. public:
  1066. operator BOOL() const { return Succeeded(); }
  1067. operator HRESULT() const { return m_hrInterface; }
  1068. protected:
  1069. //
  1070. // Create an object in this server. This function initializes the
  1071. // object with DCOM.
  1072. //
  1073. HRESULT Create(
  1074. IN LPCTSTR lpszServerName = NULL
  1075. );
  1076. //
  1077. // Make sure the interface has been created
  1078. //
  1079. BOOL HasInterface() const { return m_pInterface != NULL; }
  1080. //
  1081. // Interface
  1082. //
  1083. public:
  1084. //
  1085. // Stop services
  1086. //
  1087. HRESULT Stop(
  1088. IN DWORD dwTimeoutMsecs,
  1089. IN BOOL fForce
  1090. );
  1091. //
  1092. // Start services
  1093. //
  1094. HRESULT Start(
  1095. IN DWORD dwTimeoutMsecs
  1096. );
  1097. //
  1098. // Reboot
  1099. //
  1100. HRESULT Reboot(
  1101. IN DWORD dwTimeouMsecs,
  1102. IN BOOL fForceAppsClosed
  1103. );
  1104. //
  1105. // Status
  1106. //
  1107. HRESULT Status(
  1108. IN DWORD dwBufferSize,
  1109. OUT LPBYTE pbBuffer,
  1110. OUT DWORD * MDRequiredBufferSize,
  1111. OUT DWORD * pdwNumServices
  1112. );
  1113. //
  1114. // Kill
  1115. //
  1116. HRESULT Kill();
  1117. protected:
  1118. CString m_strServerName;
  1119. IIisServiceControl * m_pInterface;
  1120. private:
  1121. HRESULT m_hrInterface;
  1122. };
  1123. //
  1124. // Inline Expansion
  1125. //
  1126. // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  1127. inline HRESULT CMetaInterface::OpenKey(
  1128. IN METADATA_HANDLE hkBase,
  1129. IN LPCTSTR lpszMDPath,
  1130. IN DWORD dwFlags,
  1131. OUT METADATA_HANDLE * phMDNewHandle
  1132. )
  1133. {
  1134. ASSERT(m_pInterface != NULL);
  1135. return m_pInterface->OpenKey(
  1136. hkBase,
  1137. lpszMDPath,
  1138. dwFlags,
  1139. m_iTimeOutValue,
  1140. phMDNewHandle
  1141. );
  1142. }
  1143. inline HRESULT CMetaInterface::CloseKey(
  1144. IN METADATA_HANDLE hKey
  1145. )
  1146. {
  1147. ASSERT(m_pInterface != NULL);
  1148. return m_pInterface->CloseKey(hKey);
  1149. }
  1150. inline HRESULT CMetaInterface::SetLastChangeTime(
  1151. IN METADATA_HANDLE hMDHandle,
  1152. IN LPCTSTR pszMDPath,
  1153. IN FILETIME * pftMDLastChangeTime,
  1154. IN BOOL bLocalTime
  1155. )
  1156. {
  1157. ASSERT(m_pInterface != NULL);
  1158. return m_pInterface->SetLastChangeTime(
  1159. hMDHandle,
  1160. pszMDPath,
  1161. pftMDLastChangeTime,
  1162. bLocalTime
  1163. );
  1164. }
  1165. inline HRESULT CMetaInterface::GetLastChangeTime(
  1166. IN METADATA_HANDLE hMDHandle,
  1167. IN LPCTSTR lpszMDPath,
  1168. OUT FILETIME * pftMDLastChangeTime,
  1169. IN BOOL bLocalTime
  1170. )
  1171. {
  1172. ASSERT(m_pInterface != NULL);
  1173. return m_pInterface->GetLastChangeTime(
  1174. hMDHandle,
  1175. lpszMDPath,
  1176. pftMDLastChangeTime,
  1177. bLocalTime
  1178. );
  1179. }
  1180. inline HRESULT CMetaInterface::AddKey(
  1181. IN METADATA_HANDLE hKey,
  1182. IN LPCTSTR lpszMDPath
  1183. )
  1184. {
  1185. ASSERT(m_pInterface != NULL);
  1186. return m_pInterface->AddKey(hKey, lpszMDPath);
  1187. }
  1188. inline HRESULT CMetaInterface::DeleteKey(
  1189. IN METADATA_HANDLE hKey,
  1190. IN LPCTSTR lpszMDPath
  1191. )
  1192. {
  1193. ASSERT(m_pInterface != NULL);
  1194. return m_pInterface->DeleteKey(hKey, lpszMDPath);
  1195. }
  1196. inline HRESULT CMetaInterface::DeleteChildKeys(
  1197. IN METADATA_HANDLE hKey,
  1198. IN LPCTSTR lpszMDPath
  1199. )
  1200. {
  1201. ASSERT(m_pInterface != NULL);
  1202. return m_pInterface->DeleteChildKeys(hKey, lpszMDPath);
  1203. }
  1204. inline HRESULT CMetaInterface::EnumKeys(
  1205. IN METADATA_HANDLE hKey,
  1206. IN LPCTSTR lpszMDPath,
  1207. OUT LPTSTR lpszMDName,
  1208. IN DWORD dwIndex
  1209. )
  1210. {
  1211. ASSERT(m_pInterface != NULL);
  1212. return m_pInterface->EnumKeys(hKey, lpszMDPath, lpszMDName, dwIndex);
  1213. }
  1214. inline HRESULT CMetaInterface::CopyKey(
  1215. IN METADATA_HANDLE hSourceKey,
  1216. IN LPCTSTR lpszMDSourcePath,
  1217. IN METADATA_HANDLE hDestKey,
  1218. IN LPCTSTR lpszMDDestPath,
  1219. IN BOOL fOverwrite,
  1220. IN BOOL fCopy
  1221. )
  1222. {
  1223. ASSERT(m_pInterface != NULL);
  1224. return m_pInterface->CopyKey(
  1225. hSourceKey,
  1226. lpszMDSourcePath,
  1227. hDestKey,
  1228. lpszMDDestPath,
  1229. fOverwrite,
  1230. fCopy
  1231. );
  1232. }
  1233. inline HRESULT CMetaInterface::RenameKey(
  1234. IN METADATA_HANDLE hKey,
  1235. IN LPCTSTR lpszMDPath,
  1236. IN LPCTSTR lpszNewName
  1237. )
  1238. {
  1239. ASSERT(m_pInterface != NULL);
  1240. return m_pInterface->RenameKey(hKey, lpszMDPath, lpszNewName);
  1241. }
  1242. inline HRESULT CMetaInterface::GetData(
  1243. IN METADATA_HANDLE hKey,
  1244. IN LPCTSTR lpszMDPath,
  1245. OUT METADATA_RECORD * pmdRecord,
  1246. OUT DWORD * pdwRequiredDataLen
  1247. )
  1248. {
  1249. ASSERT(m_pInterface != NULL);
  1250. return m_pInterface->GetData(
  1251. hKey,
  1252. lpszMDPath,
  1253. pmdRecord,
  1254. pdwRequiredDataLen
  1255. );
  1256. }
  1257. inline HRESULT CMetaInterface::SetData(
  1258. IN METADATA_HANDLE hKey,
  1259. IN LPCTSTR lpszMDPath,
  1260. IN METADATA_RECORD * pmdRecord
  1261. )
  1262. {
  1263. ASSERT(m_pInterface != NULL);
  1264. return m_pInterface->SetData(
  1265. hKey,
  1266. lpszMDPath,
  1267. pmdRecord
  1268. );
  1269. }
  1270. inline HRESULT CMetaInterface::DeleteData(
  1271. IN METADATA_HANDLE hKey,
  1272. IN LPCTSTR lpszMDPath,
  1273. IN DWORD dwMDIdentifier,
  1274. IN DWORD dwMDDataType
  1275. )
  1276. {
  1277. ASSERT(m_pInterface != NULL);
  1278. return m_pInterface->DeleteData(
  1279. hKey,
  1280. lpszMDPath,
  1281. dwMDIdentifier,
  1282. dwMDDataType
  1283. );
  1284. }
  1285. inline HRESULT CMetaInterface::EnumData(
  1286. IN METADATA_HANDLE hKey,
  1287. IN LPCTSTR lpszMDPath,
  1288. OUT METADATA_RECORD * pmdRecord,
  1289. IN DWORD dwIndex,
  1290. OUT DWORD * pdwRequiredDataLen
  1291. )
  1292. {
  1293. ASSERT(m_pInterface != NULL);
  1294. return m_pInterface->EnumData(
  1295. hKey,
  1296. lpszMDPath,
  1297. pmdRecord,
  1298. dwIndex,
  1299. pdwRequiredDataLen
  1300. );
  1301. }
  1302. inline HRESULT CMetaInterface::GetAllData(
  1303. IN METADATA_HANDLE hKey,
  1304. IN LPCTSTR lpszMDPath,
  1305. IN DWORD dwMDAttributes,
  1306. IN DWORD dwMDUserType,
  1307. IN DWORD dwMDDataType,
  1308. OUT DWORD * pdwMDNumDataEntries,
  1309. OUT DWORD * pdwMDDataSetNumber,
  1310. IN DWORD dwMDBufferSize,
  1311. OUT LPBYTE pbMDBuffer,
  1312. OUT DWORD * pdwRequiredBufferSize
  1313. )
  1314. {
  1315. ASSERT(m_pInterface != NULL);
  1316. return m_pInterface->GetAllData(
  1317. hKey,
  1318. lpszMDPath,
  1319. dwMDAttributes,
  1320. dwMDUserType,
  1321. dwMDDataType,
  1322. pdwMDNumDataEntries,
  1323. pdwMDDataSetNumber,
  1324. dwMDBufferSize,
  1325. pbMDBuffer,
  1326. pdwRequiredBufferSize
  1327. );
  1328. }
  1329. inline HRESULT CMetaInterface::DeleteAllData(
  1330. IN METADATA_HANDLE hKey,
  1331. IN LPCTSTR lpszMDPath,
  1332. IN DWORD dwMDUserType,
  1333. IN DWORD dwMDDataType
  1334. )
  1335. {
  1336. ASSERT(m_pInterface != NULL);
  1337. return m_pInterface->DeleteAllData(
  1338. hKey,
  1339. lpszMDPath,
  1340. dwMDUserType,
  1341. dwMDDataType
  1342. );
  1343. }
  1344. inline HRESULT CMetaInterface::CopyData(
  1345. IN METADATA_HANDLE hMDSourceKey,
  1346. IN LPCTSTR lpszMDSourcePath,
  1347. IN METADATA_HANDLE hMDDestKey,
  1348. IN LPCTSTR lpszMDDestPath,
  1349. IN DWORD dwMDAttributes,
  1350. IN DWORD dwMDUserType,
  1351. IN DWORD dwMDDataType,
  1352. IN BOOL fCopy
  1353. )
  1354. {
  1355. ASSERT(m_pInterface != NULL);
  1356. return m_pInterface->CopyData(
  1357. hMDSourceKey,
  1358. lpszMDSourcePath,
  1359. hMDDestKey,
  1360. lpszMDDestPath,
  1361. dwMDAttributes,
  1362. dwMDUserType,
  1363. dwMDDataType,
  1364. fCopy
  1365. );
  1366. }
  1367. inline HRESULT CMetaInterface::GetDataPaths(
  1368. IN METADATA_HANDLE hKey,
  1369. IN LPCTSTR lpszMDPath,
  1370. IN DWORD dwMDIdentifier,
  1371. IN DWORD dwMDDataType,
  1372. IN DWORD dwMDBufferSize,
  1373. OUT LPTSTR lpszBuffer,
  1374. OUT DWORD * pdwMDRequiredBufferSize
  1375. )
  1376. {
  1377. ASSERT(m_pInterface != NULL);
  1378. return m_pInterface->GetDataPaths(
  1379. hKey,
  1380. lpszMDPath,
  1381. dwMDIdentifier,
  1382. dwMDDataType,
  1383. dwMDBufferSize,
  1384. lpszBuffer,
  1385. pdwMDRequiredBufferSize
  1386. );
  1387. }
  1388. inline HRESULT CMetaInterface::Backup(
  1389. IN LPCTSTR lpszBackupLocation,
  1390. IN DWORD dwMDVersion,
  1391. IN DWORD dwMDFlags
  1392. )
  1393. {
  1394. ASSERT(m_pInterface != NULL);
  1395. return m_pInterface->Backup(lpszBackupLocation, dwMDVersion, dwMDFlags);
  1396. }
  1397. inline HRESULT CMetaInterface::BackupWithPassword(
  1398. IN LPCTSTR lpszBackupLocation,
  1399. IN DWORD dwMDVersion,
  1400. IN DWORD dwMDFlags,
  1401. IN LPCTSTR lpszPassword
  1402. )
  1403. {
  1404. ASSERT(m_pInterface != NULL);
  1405. HRESULT hr = S_OK;
  1406. IMSAdminBase2 * pInterface2 = NULL;
  1407. if (SUCCEEDED(hr = m_pInterface->QueryInterface(IID_IMSAdminBase2, (void **)&pInterface2)))
  1408. {
  1409. hr = pInterface2->BackupWithPasswd(lpszBackupLocation, dwMDVersion, dwMDFlags, lpszPassword);
  1410. pInterface2->Release();
  1411. }
  1412. return hr;
  1413. }
  1414. inline HRESULT CMetaInterface::Restore(
  1415. IN LPCTSTR lpszBackupLocation,
  1416. IN DWORD dwMDVersion,
  1417. IN DWORD dwMDFlags
  1418. )
  1419. {
  1420. ASSERT(m_pInterface != NULL);
  1421. return m_pInterface->Restore(lpszBackupLocation, dwMDVersion, dwMDFlags);
  1422. }
  1423. inline HRESULT CMetaInterface::RestoreWithPassword(
  1424. IN LPCTSTR lpszBackupLocation,
  1425. IN DWORD dwMDVersion,
  1426. IN DWORD dwMDFlags,
  1427. IN LPCTSTR lpszPassword
  1428. )
  1429. {
  1430. ASSERT(m_pInterface != NULL);
  1431. HRESULT hr = S_OK;
  1432. IMSAdminBase2 * pInterface2 = NULL;
  1433. if (SUCCEEDED(hr = m_pInterface->QueryInterface(IID_IMSAdminBase2, (void **)&pInterface2)))
  1434. {
  1435. hr = pInterface2->RestoreWithPasswd(lpszBackupLocation, dwMDVersion, dwMDFlags, lpszPassword);
  1436. pInterface2->Release();
  1437. }
  1438. return hr;
  1439. }
  1440. inline HRESULT CMetaInterface::EnumBackups(
  1441. OUT LPTSTR lpszBackupLocation,
  1442. OUT DWORD * pdwMDVersion,
  1443. OUT FILETIME * pftMDBackupTime,
  1444. IN DWORD dwIndex
  1445. )
  1446. {
  1447. ASSERT(m_pInterface != NULL);
  1448. return m_pInterface->EnumBackups(
  1449. lpszBackupLocation,
  1450. pdwMDVersion,
  1451. pftMDBackupTime,
  1452. dwIndex
  1453. );
  1454. }
  1455. inline HRESULT CMetaInterface::DeleteBackup(
  1456. IN LPCTSTR lpszBackupLocation,
  1457. IN DWORD dwMDVersion
  1458. )
  1459. {
  1460. ASSERT(m_pInterface != NULL);
  1461. return m_pInterface->DeleteBackup(lpszBackupLocation, dwMDVersion);
  1462. }
  1463. inline HRESULT CWamInterface::AppDelete(
  1464. IN LPCTSTR szMDPath,
  1465. IN BOOL fRecursive
  1466. )
  1467. {
  1468. ASSERT(m_pInterface != NULL);
  1469. return m_pInterface->AppDelete(szMDPath, fRecursive);
  1470. }
  1471. inline HRESULT CWamInterface::AppUnLoad(
  1472. IN LPCTSTR szMDPath,
  1473. IN BOOL fRecursive
  1474. )
  1475. {
  1476. ASSERT(m_pInterface != NULL);
  1477. return m_pInterface->AppUnLoad(szMDPath, fRecursive);
  1478. }
  1479. inline HRESULT CWamInterface::AppGetStatus(
  1480. IN LPCTSTR szMDPath,
  1481. OUT DWORD * pdwAppStatus
  1482. )
  1483. {
  1484. ASSERT(m_pInterface != NULL);
  1485. return m_pInterface->AppGetStatus(szMDPath, pdwAppStatus);
  1486. }
  1487. inline HRESULT CWamInterface::AppDeleteRecoverable(
  1488. IN LPCTSTR szMDPath,
  1489. IN BOOL fRecursive
  1490. )
  1491. {
  1492. ASSERT(m_pInterface != NULL);
  1493. return m_pInterface->AppDeleteRecoverable(szMDPath, fRecursive);
  1494. }
  1495. inline HRESULT CWamInterface::AppRecover(
  1496. IN LPCTSTR szMDPath,
  1497. IN BOOL fRecursive
  1498. )
  1499. {
  1500. ASSERT(m_pInterface != NULL);
  1501. return m_pInterface->AppRecover(szMDPath, fRecursive);
  1502. }
  1503. inline HRESULT CMetaBack::Next(
  1504. OUT DWORD * pdwVersion,
  1505. OUT LPTSTR lpszLocation,
  1506. OUT FILETIME * pftBackupTime
  1507. )
  1508. {
  1509. return EnumBackups(
  1510. lpszLocation,
  1511. pdwVersion,
  1512. pftBackupTime,
  1513. m_dwIndex++
  1514. );
  1515. }
  1516. inline HRESULT CMetaBack::Backup(
  1517. IN LPCTSTR lpszLocation
  1518. )
  1519. {
  1520. return CMetaInterface::Backup(
  1521. lpszLocation,
  1522. MD_BACKUP_NEXT_VERSION,
  1523. MD_BACKUP_SAVE_FIRST
  1524. );
  1525. }
  1526. inline HRESULT CMetaBack::Delete(
  1527. IN LPCTSTR lpszLocation,
  1528. IN DWORD dwVersion
  1529. )
  1530. {
  1531. return DeleteBackup(lpszLocation, dwVersion);
  1532. }
  1533. inline HRESULT CMetaKey::AddKey(
  1534. IN LPCTSTR lpszMDPath
  1535. )
  1536. {
  1537. return CMetaInterface::AddKey(m_hKey, lpszMDPath);
  1538. }
  1539. inline HRESULT CMetaKey::DeleteKey(
  1540. IN LPCTSTR lpszMDPath
  1541. )
  1542. {
  1543. return CMetaInterface::DeleteKey(m_hKey, lpszMDPath);
  1544. }
  1545. inline HRESULT CMetaKey::RenameKey(
  1546. IN LPCTSTR lpszMDPath,
  1547. IN LPCTSTR lpszNewName
  1548. )
  1549. {
  1550. return CMetaInterface::RenameKey(m_hKey, lpszMDPath, lpszNewName);
  1551. }
  1552. inline HRESULT CMetaKey::ReOpen()
  1553. {
  1554. return Open(m_dwFlags, m_hBase, m_strMetaPath);
  1555. }
  1556. inline HRESULT CMetaKey::ReOpen(DWORD dwFlags)
  1557. {
  1558. return Open(dwFlags, m_hBase, m_strMetaPath);
  1559. }
  1560. inline BOOL CMetaKey::IsHomeDirectoryPath()
  1561. {
  1562. return IsHomeDirectoryPath(m_strMetaPath);
  1563. }
  1564. inline HRESULT CMetaKey::QueryValue(
  1565. IN DWORD dwID,
  1566. OUT BOOL & fValue,
  1567. IN BOOL * pfInheritanceOverride,
  1568. IN LPCTSTR lpszMDPath,
  1569. OUT DWORD * pdwAttributes
  1570. )
  1571. {
  1572. ASSERT(sizeof(DWORD) == sizeof(BOOL));
  1573. return CMetaKey::QueryValue(
  1574. dwID,
  1575. (DWORD &)fValue,
  1576. pfInheritanceOverride,
  1577. lpszMDPath,
  1578. pdwAttributes
  1579. );
  1580. }
  1581. inline HRESULT CMetaKey::SetValue(
  1582. IN DWORD dwID,
  1583. IN DWORD dwValue,
  1584. IN BOOL * pfInheritanceOverride, OPTIONAL
  1585. IN LPCTSTR lpszMDPath OPTIONAL
  1586. )
  1587. {
  1588. return SetPropertyValue(
  1589. dwID,
  1590. sizeof(dwValue),
  1591. &dwValue,
  1592. pfInheritanceOverride,
  1593. lpszMDPath
  1594. );
  1595. }
  1596. inline HRESULT CMetaKey::SetValue(
  1597. IN DWORD dwID,
  1598. IN BOOL fValue,
  1599. IN BOOL * pfInheritanceOverride,
  1600. IN LPCTSTR lpszMDPath
  1601. )
  1602. {
  1603. ASSERT(sizeof(DWORD) == sizeof(BOOL));
  1604. return CMetaKey::SetValue(
  1605. dwID,
  1606. (DWORD)fValue,
  1607. pfInheritanceOverride,
  1608. lpszMDPath
  1609. );
  1610. }
  1611. inline HRESULT CMetaKey::SetValue(
  1612. IN DWORD dwID,
  1613. IN CString & strValue,
  1614. IN BOOL * pfInheritanceOverride, OPTIONAL
  1615. IN LPCTSTR lpszMDPath OPTIONAL
  1616. )
  1617. {
  1618. return SetPropertyValue(
  1619. dwID,
  1620. (strValue.GetLength() + 1) * sizeof(TCHAR),
  1621. (void *)(LPCTSTR)strValue,
  1622. pfInheritanceOverride,
  1623. lpszMDPath
  1624. );
  1625. }
  1626. inline BOOL CIISApplication::IsEnabledApplication() const
  1627. {
  1628. return m_dwAppState == APPSTATUS_STOPPED
  1629. || m_dwAppState == APPSTATUS_RUNNING;
  1630. }
  1631. inline HRESULT CIISApplication::Delete(
  1632. IN BOOL fRecursive
  1633. )
  1634. {
  1635. ASSERT(!m_strWamPath.IsEmpty());
  1636. return AppDelete(m_strWamPath, fRecursive);
  1637. }
  1638. inline HRESULT CIISApplication::Unload(
  1639. IN BOOL fRecursive
  1640. )
  1641. {
  1642. ASSERT(!m_strWamPath.IsEmpty());
  1643. return AppUnLoad(m_strWamPath, fRecursive);
  1644. }
  1645. inline HRESULT CIISApplication::DeleteRecoverable(
  1646. IN BOOL fRecursive
  1647. )
  1648. {
  1649. ASSERT(!m_strWamPath.IsEmpty());
  1650. return AppDeleteRecoverable(m_strWamPath, fRecursive);
  1651. }
  1652. inline HRESULT CIISApplication::Recover(
  1653. IN BOOL fRecursive
  1654. )
  1655. {
  1656. ASSERT(!m_strWamPath.IsEmpty());
  1657. return AppRecover(m_strWamPath, fRecursive);
  1658. }
  1659. inline HRESULT CIISSvcControl::Stop(
  1660. IN DWORD dwTimeoutMsecs,
  1661. IN BOOL fForce
  1662. )
  1663. {
  1664. ASSERT(m_pInterface != NULL);
  1665. return m_pInterface->Stop(dwTimeoutMsecs, (DWORD)fForce);
  1666. }
  1667. inline HRESULT CIISSvcControl::Start(
  1668. IN DWORD dwTimeoutMsecs
  1669. )
  1670. {
  1671. ASSERT(m_pInterface != NULL);
  1672. return m_pInterface->Start(dwTimeoutMsecs);
  1673. }
  1674. inline HRESULT CIISSvcControl::Reboot(
  1675. IN DWORD dwTimeouMsecs,
  1676. IN BOOL fForceAppsClosed
  1677. )
  1678. {
  1679. ASSERT(m_pInterface != NULL);
  1680. return m_pInterface->Reboot(dwTimeouMsecs, (DWORD)fForceAppsClosed);
  1681. }
  1682. inline HRESULT CIISSvcControl::Status(
  1683. IN DWORD dwBufferSize,
  1684. OUT LPBYTE pbBuffer,
  1685. OUT DWORD * MDRequiredBufferSize,
  1686. OUT DWORD * pdwNumServices
  1687. )
  1688. {
  1689. ASSERT(m_pInterface != NULL);
  1690. return m_pInterface->Status(
  1691. dwBufferSize,
  1692. pbBuffer,
  1693. MDRequiredBufferSize,
  1694. pdwNumServices
  1695. );
  1696. }
  1697. inline HRESULT CIISSvcControl::Kill()
  1698. {
  1699. ASSERT(m_pInterface != NULL);
  1700. return m_pInterface->Kill();
  1701. }
  1702. #endif // _MDKEYS_H_