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.

141 lines
4.6 KiB

  1. // *********************************************************************************
  2. //
  3. // Copyright (c) Microsoft Corporation
  4. //
  5. // Module Name:
  6. //
  7. // WMI.h
  8. //
  9. // Abstract:
  10. //
  11. // Common functionality for WMI
  12. //
  13. // Author:
  14. //
  15. // Sunil G.V.N. Murali ([email protected]) 22-Dec-2000
  16. //
  17. // Revision History:
  18. //
  19. // Sunil G.V.N. Murali ([email protected]) 22-Dec-2000 : Created It.
  20. //
  21. // *********************************************************************************
  22. #ifndef __WMI_H
  23. #define __WMI_H
  24. //
  25. // macros
  26. //
  27. #define SAFE_RELEASE( interfacepointer ) \
  28. if ( (interfacepointer) != NULL ) \
  29. { \
  30. (interfacepointer)->Release(); \
  31. (interfacepointer) = NULL; \
  32. } \
  33. 1
  34. #define SAFE_EXECUTE( statement ) \
  35. hr = statement; \
  36. if ( FAILED( hr ) ) \
  37. { \
  38. _com_issue_error( hr ); \
  39. } \
  40. 1
  41. //
  42. // define(s) / enumerators / constants
  43. //
  44. #define WMI_NAMESPACE_CIMV2 L"root\\cimv2"
  45. #define WMI_NAMESPACE_DEFAULT L"root\\default"
  46. #define WMI_CLAUSE_AND L"AND"
  47. #define WMI_CLAUSE_OR L"OR"
  48. #define WMI_CLAUSE_WHERE L"WHERE"
  49. #define CLASS_CIMV2_Win32_OperatingSystem L"Win32_OperatingSystem"
  50. #define CLASS_CIMV2_Win32_ComputerSystem L"Win32_ComputerSystem"
  51. #define WMI_REGISTRY L"StdRegProv"
  52. #define WMI_REGISTRY_M_STRINGVALUE L"GetStringValue"
  53. #define WMI_REGISTRY_IN_HDEFKEY L"hDefKey"
  54. #define WMI_REGISTRY_IN_SUBKEY L"sSubKeyName"
  55. #define WMI_REGISTRY_IN_VALUENAME L"sValueName"
  56. #define WMI_REGISTRY_OUT_VALUE L"sValue"
  57. #define WMI_REGISTRY_OUT_RETURNVALUE L"ReturnValue"
  58. #define WMI_HKEY_CLASSES_ROOT 2147483648
  59. #define WMI_HKEY_CURRENT_USER 2147483649
  60. #define WMI_HKEY_LOCAL_MACHINE 2147483650
  61. #define WMI_HKEY_USERS 2147483651
  62. #define WMI_HKEY_CURRENT_CONFIG 2147482652
  63. #define PLATFORM_UNKNOWN 0
  64. #define PLATFORM_X86 1
  65. #define PLATFORM_IA64 2
  66. #define PLATFORM_AMD64 3
  67. #define TEXT_X86 L"X86"
  68. #define TEXT_IA64 L"IA64"
  69. #define TEXT_AMD64 L"AMD64"
  70. // messages
  71. // #define ERROR_COM_ERROR GetResString( IDS_ERROR_COM_ERROR )
  72. //
  73. // function prototype(s)
  74. //
  75. BOOL InitializeCom( IWbemLocator** ppLocator );
  76. BOOL ConnectWmi( IWbemLocator* pLocator,
  77. IWbemServices** ppServices,
  78. LPCWSTR pwszServer, LPCWSTR pwszUser, LPCWSTR pwszPassword,
  79. COAUTHIDENTITY** ppAuthIdentity,
  80. BOOL bCheckWithNullPwd = FALSE,
  81. LPCWSTR pwszNamespace = WMI_NAMESPACE_CIMV2,
  82. HRESULT* phr = NULL, BOOL* pbLocalSystem = NULL );
  83. BOOL ConnectWmiEx( IWbemLocator* pLocator,
  84. IWbemServices** ppServices,
  85. LPCWSTR pwszServer, CHString& strUserName, CHString& strPassword,
  86. COAUTHIDENTITY** ppAuthIdentity, BOOL bNeedPassword = FALSE,
  87. LPCWSTR pszNamespace = WMI_NAMESPACE_CIMV2, BOOL* pbLocalSystem = NULL );
  88. BOOL IsValidServerEx( LPCWSTR pwszServer, BOOL& bLocalSystem );
  89. HRESULT SetInterfaceSecurity( IUnknown* pInterface, COAUTHIDENTITY* pAuthIdentity );
  90. VOID WINAPI WbemFreeAuthIdentity( COAUTHIDENTITY** ppAuthIdentity );
  91. VOID WMISaveError( HRESULT hrError );
  92. HRESULT PropertyGet( IWbemClassObject* pWmiObject,
  93. LPCWSTR pwszProperty, _variant_t& varValue );
  94. BOOL PropertyGet( IWbemClassObject* pWmiObject, LPCWSTR pwszProperty,
  95. CHString& strValue, LPCWSTR pwszDefault = V_NOT_AVAILABLE );
  96. BOOL PropertyGet( IWbemClassObject* pWmiObject,
  97. LPCWSTR pwszProperty, DWORD& dwValue, DWORD dwDefault = 0 );
  98. BOOL PropertyGet( IWbemClassObject* pWmiObject, LPCWSTR pwszProperty, ULONGLONG& ullValue );
  99. BOOL PropertyGet( IWbemClassObject* pWmiObject, LPCWSTR pwszProperty, WBEMTime& wbemtime );
  100. BOOL PropertyGet( IWbemClassObject* pWmiObject, LPCWSTR pwszProperty, SYSTEMTIME& systime );
  101. BOOL PropertyGet( IWbemClassObject* pWmiObject, LPCWSTR pwszProperty, TARRAY arr );
  102. HRESULT PropertyPut( IWbemClassObject* pWmiObject, LPCWSTR pwszProperty, DWORD dwValue );
  103. HRESULT PropertyPut( IWbemClassObject* pWmiObject, LPCWSTR pwszProperty, LPCWSTR pwszValue );
  104. HRESULT PropertyPut( IWbemClassObject* pWmiObject, LPCWSTR pwszProperty, _variant_t& varValue );
  105. DWORD GetTargetVersionEx( IWbemServices* pWbemServices, COAUTHIDENTITY* pAuthIdentity );
  106. DWORD GetTargetPlatformEx( IWbemServices* pWbemServices, COAUTHIDENTITY* pAuthIdentity );
  107. BOOL RegQueryValueWMI( IWbemServices* pWbemServices, DWORD dwHDefKey,
  108. LPCWSTR pwszSubKeyName, LPCWSTR pwszValueName,
  109. CHString& strValue, LPCWSTR pwszDefault = V_NOT_AVAILABLE );
  110. //
  111. // inline functions
  112. //
  113. // ***************************************************************************
  114. // Routine Description:
  115. //
  116. // Arguments:
  117. //
  118. // Return Value:
  119. //
  120. // ***************************************************************************
  121. inline VOID WMISaveError( _com_error& e )
  122. {
  123. WMISaveError( e.Error() );
  124. }
  125. #endif // __WMI_H