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.

129 lines
2.9 KiB

  1. ////////////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 2000-2001 Microsoft Corporation, All Rights Reserved
  4. //
  5. // All rights reserved.
  6. //
  7. // Module Name:
  8. //
  9. // MSIDataLock.h
  10. //
  11. // Abstract:
  12. //
  13. // declaration of lock for msi handles
  14. //
  15. ////////////////////////////////////////////////////////////////////////////////////
  16. #ifndef __MSIDATALOCK_H__
  17. #define __MSIDATALOCK_H__
  18. #if _MSC_VER > 1000
  19. #pragma once
  20. #endif _MSC_VER > 1000
  21. //would need msi
  22. #ifndef _MSI_H_
  23. #include <msi.h>
  24. #endif _MSI_H_
  25. ////////////////////////////////////////////////////////////////////////////////////
  26. // base class for lock
  27. ////////////////////////////////////////////////////////////////////////////////////
  28. class MSIDataLockBase
  29. {
  30. protected:
  31. static HANDLE m_hOwn; // event to mark owner
  32. static LPWSTR m_wszProduct;
  33. static MSIHANDLE m_hProduct; // msi handle to product
  34. static LONG m_lRefProduct; // msi handle to product ref count
  35. static BOOL m_bProductOwn; // msi handle to product own ?
  36. static MSIHANDLE m_hDatabase; // msi handle to database
  37. static LONG m_lRefDatabase; // msi handle to database ref count
  38. static BOOL m_bDatabaseOwn; // msi handle to database own ?
  39. static DWORD m_ThreadID; // id of thread that has locked/unlocked
  40. static LONG m_lRef; // reference count
  41. public:
  42. MSIDataLockBase ();
  43. virtual ~MSIDataLockBase ();
  44. BOOL Lock ( void );
  45. void Unlock ( void );
  46. private:
  47. BOOL Initialize ();
  48. void Uninitialize ();
  49. };
  50. ////////////////////////////////////////////////////////////////////////////////////
  51. // class for lock
  52. ////////////////////////////////////////////////////////////////////////////////////
  53. class MSIDataLock : public MSIDataLockBase
  54. {
  55. public:
  56. MSIDataLock()
  57. {
  58. }
  59. ~MSIDataLock()
  60. {
  61. }
  62. #ifdef __SUPPORT_STATIC
  63. static const MSIHANDLE GetProduct ()
  64. {
  65. return static_cast < MSIHANDLE > ( m_hProduct );
  66. }
  67. static const MSIHANDLE GetDatabase ()
  68. {
  69. return static_cast < MSIHANDLE > ( m_hDatabase );
  70. }
  71. #else __SUPPORT_STATIC
  72. const MSIHANDLE GetProduct ()
  73. {
  74. return static_cast < MSIHANDLE > ( m_hProduct );
  75. }
  76. const MSIHANDLE GetDatabase ()
  77. {
  78. return static_cast < MSIHANDLE > ( m_hDatabase );
  79. }
  80. #endif __SUPPORT_STATIC
  81. bool GetView ( MSIHANDLE *phView,
  82. WCHAR *wcPackage,
  83. WCHAR *wcQuery,
  84. WCHAR *wcTable,
  85. BOOL bCloseProduct,
  86. BOOL bCloseDatabase
  87. );
  88. HRESULT CloseProduct ( void );
  89. HRESULT CloseDatabase ( void );
  90. private:
  91. HRESULT OpenProduct ( LPCWSTR wszProduct );
  92. HRESULT OpenDatabase ( );
  93. HRESULT OpenDatabase ( LPCWSTR wszProduct );
  94. HRESULT Query ( MSIHANDLE* pView, LPCWSTR wszQuery, LPCWSTR wszTable = NULL );
  95. HRESULT OpenProductAlloc ( LPCWSTR wszProduct );
  96. HRESULT OpenProductInternal ( LPCWSTR wszProduct );
  97. };
  98. #endif __MSIDATALOCK_H__