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.

162 lines
5.1 KiB

  1. // GenericClass.h: interface for the CGenericClass class.
  2. // Copyright (c) 1997-2001 Microsoft Corporation, All Rights Reserved
  3. //
  4. //////////////////////////////////////////////////////////////////////
  5. #if !defined(AFX_GENERICCLASS_H__F370C612_D96E_11D1_8B5D_00A0C9954921__INCLUDED_)
  6. #define AFX_GENERICCLASS_H__F370C612_D96E_11D1_8B5D_00A0C9954921__INCLUDED_
  7. #include "requestobject.h"
  8. #include "MSIDataLock.h"
  9. #if _MSC_VER >= 1000
  10. #pragma once
  11. #endif // _MSC_VER >= 1000
  12. class CGenericClass
  13. {
  14. friend BOOL WINAPI DllMain(HINSTANCE, ULONG, LPVOID );
  15. public:
  16. CGenericClass(CRequestObject *pObj, IWbemServices *pNamespace, IWbemContext *pCtx = NULL);
  17. virtual ~CGenericClass();
  18. //The instance write class which can optionally be implemented
  19. virtual HRESULT PutInst ( CRequestObject *pObj,
  20. IWbemClassObject *pInst,
  21. IWbemObjectSink *pHandler,
  22. IWbemContext *pCtx
  23. ) = 0;
  24. IWbemClassObject *m_pObj;
  25. //The instance creation class which must be implemented
  26. virtual HRESULT CreateObject ( IWbemObjectSink *pHandler,
  27. ACTIONTYPE atAction
  28. ) = 0;
  29. void CleanUp();
  30. CRequestObject *m_pRequest;
  31. protected:
  32. // is get buffer neccessary ?
  33. HRESULT GetBufferNeccessary ( MSIHANDLE& handle, DWORD dwIndex, DWORD& dwSize, LPWSTR staticBuffer, BOOL bThrow = TRUE );
  34. // get buffer ( caller has to delete )
  35. HRESULT GetBuffer ( MSIHANDLE& handle, DWORD dwIndex, DWORD& dwSize, DWORD& dwdynSize, LPWSTR & dynBuffer, BOOL bThrow = TRUE );
  36. // special get buffer whic hold pointer for buffer to be used
  37. HRESULT GetBufferToPut ( MSIHANDLE& handle,
  38. DWORD dwIndex,
  39. DWORD& dwSize,
  40. LPWSTR staticBuffer,
  41. DWORD& dwdynSize,
  42. LPWSTR& dynBuffer,
  43. LPWSTR& Buffer,
  44. BOOL bThrow = TRUE
  45. );
  46. //Property Methods
  47. HRESULT PutProperty(IWbemClassObject *pObj, const char *wcProperty, WCHAR *wcValue);
  48. HRESULT PutProperty(IWbemClassObject *pObj, const char *wcProperty, int iValue);
  49. HRESULT PutProperty(IWbemClassObject *pObj, const char *wcProperty, float dValue);
  50. HRESULT PutProperty(IWbemClassObject *pObj, const char *wcProperty, bool bValue);
  51. //Special Property Methods
  52. HRESULT PutProperty(IWbemClassObject *pObj, const char *wcProperty, WCHAR *wcValue, DWORD dwCount, ... );
  53. //Key Property Methods
  54. HRESULT PutKeyProperty ( IWbemClassObject *pObj,
  55. const char *wcProperty,
  56. WCHAR *wcValue,
  57. bool *bKey,
  58. CRequestObject *pRequest
  59. );
  60. HRESULT PutKeyProperty ( IWbemClassObject *pObj,
  61. const char *wcProperty,
  62. int iValue,
  63. bool *bKey,
  64. CRequestObject *pRequest
  65. );
  66. //Special Key Property Methods
  67. HRESULT PutKeyProperty ( IWbemClassObject *pObj,
  68. const char *wcProperty,
  69. WCHAR *wcValue,
  70. bool *bKey,
  71. CRequestObject *pRequest,
  72. DWORD dwCount,
  73. ...
  74. );
  75. HRESULT PutPropertySpecial ( MSIHANDLE& handle,
  76. DWORD dwIndex,
  77. DWORD& dwSize,
  78. LPWSTR staticBuffer,
  79. DWORD& dwdynSize,
  80. LPWSTR& dynBuffer,
  81. LPCSTR wszPropName,
  82. BOOL bThrow = TRUE
  83. );
  84. HRESULT PutPropertySpecial ( MSIHANDLE& handle,
  85. DWORD dwIndex,
  86. DWORD& dwSize,
  87. LPWSTR staticBuffer,
  88. DWORD& dwdynSize,
  89. LPWSTR& dynBuffer,
  90. BOOL bThrow,
  91. DWORD dwCount,
  92. ...
  93. );
  94. //This handles initialization of views
  95. bool GetView (
  96. MSIHANDLE *phView,
  97. WCHAR *wcPackage,
  98. WCHAR *wcQuery,
  99. WCHAR *wcTable,
  100. BOOL bCloseProduct,
  101. BOOL bCloseDatabase
  102. );
  103. //Utility Methods
  104. void CheckMSI(UINT uiStatus);
  105. HRESULT CheckOpen(UINT uiStatus);
  106. bool FindIn(BSTR bstrProp[], BSTR bstrSearch, int *iPos);
  107. HRESULT SetSinglePropertyPath(WCHAR wcProperty[]);
  108. HRESULT GetProperty(IWbemClassObject *pObj, const char *cProperty, BSTR *wcValue);
  109. HRESULT GetProperty(IWbemClassObject *pObj, const char *cProperty, int *piValue);
  110. HRESULT GetProperty(IWbemClassObject *pObj, const char *cProperty, bool *pbValue);
  111. WCHAR * GetFirstGUID(WCHAR wcIn[], WCHAR wcOut[]);
  112. WCHAR * RemoveFinalGUID(WCHAR wcIn[], WCHAR wcOut[]);
  113. HRESULT SpawnAnInstance ( IWbemServices *pNamespace,
  114. IWbemContext *pCtx,
  115. IWbemClassObject **pObj,
  116. BSTR bstrName
  117. );
  118. HRESULT SpawnAnInstance ( IWbemClassObject **pObj );
  119. INSTALLUI_HANDLER SetupExternalUI (); //Requires a current CRequestObject
  120. void RestoreExternalUI ( INSTALLUI_HANDLER ui ); //Restore UI handle
  121. MSIDataLock msidata;
  122. IWbemServices *m_pNamespace;
  123. IWbemClassObject *m_pClassForSpawning;
  124. IWbemContext *m_pCtx;
  125. //functions/members for NT4 install fix
  126. HRESULT LaunchProcess(WCHAR *wcAction, WCHAR *wcCommandLine, UINT *uiStatus);
  127. WCHAR * GetNextVar(WCHAR *pwcStart);
  128. long GetVarCount(void * pEnv);
  129. static CRITICAL_SECTION m_cs;
  130. };
  131. #endif // !defined(AFX_GENERICCLASS_H__F370C612_D96E_11D1_8B5D_00A0C9954921__INCLUDED_)