Documentation
¶
Index ¶
- Constants
- Variables
- func CoSetProxyBlanket(service *ole.IUnknown) (err error)
- func CreateNumericArrayVariant(array interface{}, itemType ole.VT) (ole.VARIANT, error)
- func CreateStringArrayVariant(array []string) (ole.VARIANT, error)
- func NewAutomationVariant(value interface{}) (ole.VARIANT, error)
- func NextObject(enum *Enum, target interface{}) (bool, error)
- func WaitJob(service *Service, job *Instance) error
- type CIMTYPE_ENUMERATION
- type Enum
- type IEnumWbemClassObjectVtbl
- type IWbemClassObjectVtbl
- type IWbemLocatorVtbl
- type IWbemServicesVtbl
- type Instance
- func (i *Instance) BeginEnumeration() error
- func (i *Instance) BeginInvoke(method string) *MethodExecutor
- func (i *Instance) CloneInstance() (*Instance, error)
- func (i *Instance) Close()
- func (i *Instance) EndEnumeration() error
- func (i *Instance) GetAll(target interface{}) error
- func (i *Instance) GetAllProperties() (map[string]interface{}, error)
- func (i *Instance) GetAsAny(name string) (interface{}, CIMTYPE_ENUMERATION, WBEM_FLAVOR_TYPE, error)
- func (i *Instance) GetAsString(name string) (value string, err error)
- func (i *Instance) GetAsUint(name string) (uint, error)
- func (i *Instance) GetAsVariant(name string) (*ole.VARIANT, CIMTYPE_ENUMERATION, WBEM_FLAVOR_TYPE, error)
- func (i *Instance) GetCimText() string
- func (i *Instance) GetClassName() (className string, err error)
- func (i *Instance) GetMethodParameters(method string) (*Instance, error)
- func (i *Instance) IsReferenceProperty(name string) (bool, error)
- func (i *Instance) Next() (done bool, name string, value interface{}, cimType CIMTYPE_ENUMERATION, ...)
- func (i *Instance) NextAsVariant() (bool, string, *ole.VARIANT, CIMTYPE_ENUMERATION, WBEM_FLAVOR_TYPE, error)
- func (i *Instance) Path() (string, error)
- func (i *Instance) Put(name string, value interface{}) (err error)
- func (i *Instance) PutAll(src interface{}) error
- func (i *Instance) SpawnInstance() (instance *Instance, err error)
- type JobError
- type MethodExecutor
- type Service
- func (s *Service) Close()
- func (s *Service) CreateInstance(className string, src interface{}) (*Instance, error)
- func (s *Service) CreateInstanceEnum(className string) (*Enum, error)
- func (s *Service) ExecMethod(className string, methodName string, inParams *Instance) (*Instance, error)
- func (s *Service) ExecQuery(wqlQuery string) (*Enum, error)
- func (s *Service) FindFirstInstance(wql string) (*Instance, error)
- func (s *Service) FindFirstObject(wql string, target interface{}) error
- func (s *Service) FindFirstRelatedInstance(objPath string, className string) (*Instance, error)
- func (s *Service) GetClassInstance(obj *Instance) (*Instance, error)
- func (s *Service) GetObject(objectPath string) (instance *Instance, err error)
- func (s *Service) GetObjectAsObject(objPath string, target interface{}) error
- func (s *Service) GetSingletonInstance(className string) (*Instance, error)
- func (s *Service) RefetchObject(instance *Instance) (*Instance, error)
- func (s *Service) SpawnInstance(className string) (*Instance, error)
- type WBEM_FLAVOR_TYPE
Constants ¶
const ( // WMI HRESULT values WBEM_S_NO_ERROR = 0 WBEM_S_FALSE = 1 WBEM_S_NO_MORE_DATA = 0x40005 // WMI Generic flags WBEM_FLAG_RETURN_WBEM_COMPLETE = 0x0 WBEM_FLAG_RETURN_IMMEDIATELY = 0x10 WBEM_FLAG_FORWARD_ONLY = 0x20 // WMI Query flags WBEM_FLAG_SHALLOW = 1 // Timeout flags WBEM_NO_WAIT = 0 WBEM_INFINITE = 0xFFFFFFFF // COM Auth Flags EOAC_NONE = 0 // RPC Authentication RPC_C_AUTHN_WINNT = 10 // RPC Authentication Level RPC_C_AUTHN_LEVEL_DEFAULT = 0 RPC_C_AUTHN_LEVEL_CALL = 3 // RPC Authorization RPC_C_AUTHZ_NONE = 0 // RPC Impersonation RPC_C_IMP_LEVEL_IMPERSONATE = 3 )
const (
WBEM_FLAG_CONNECT_USE_MAX_WAIT = 0x80
)
const (
WmiPathKey = "__PATH"
)
Variables ¶
var (
WindowsEpoch = time.Date(1601, 1, 1, 0, 0, 0, 0, time.UTC)
)
Functions ¶
func CoSetProxyBlanket ¶
func CoSetProxyBlanket(service *ole.IUnknown) (err error)
func CreateNumericArrayVariant ¶
func CreateNumericArrayVariant(array interface{}, itemType ole.VT) (ole.VARIANT, error)
func NewAutomationVariant ¶
func NewAutomationVariant(value interface{}) (ole.VARIANT, error)
NewAutomationVariant returns a new VARIANT com
func NextObject ¶
NextObject obtains the next instance in an enumeration and sets all fields of the struct pointer passed through the target parameter. Otherwise, if the target parameter is not a struct pointer type, an error will be returned.
Types ¶
type CIMTYPE_ENUMERATION ¶
type CIMTYPE_ENUMERATION uint32
const ( CIM_ILLEGAL CIMTYPE_ENUMERATION = 0xFFF CIM_EMPTY CIMTYPE_ENUMERATION = 0 CIM_SINT8 CIMTYPE_ENUMERATION = 16 CIM_UINT8 CIMTYPE_ENUMERATION = 17 CIM_SINT16 CIMTYPE_ENUMERATION = 2 CIM_UINT16 CIMTYPE_ENUMERATION = 18 CIM_SINT32 CIMTYPE_ENUMERATION = 3 CIM_UINT32 CIMTYPE_ENUMERATION = 19 CIM_SINT64 CIMTYPE_ENUMERATION = 20 CIM_UINT64 CIMTYPE_ENUMERATION = 21 CIM_REAL32 CIMTYPE_ENUMERATION = 4 CIM_REAL64 CIMTYPE_ENUMERATION = 5 CIM_BOOLEAN CIMTYPE_ENUMERATION = 11 CIM_STRING CIMTYPE_ENUMERATION = 8 CIM_DATETIME CIMTYPE_ENUMERATION = 101 CIM_REFERENCE CIMTYPE_ENUMERATION = 102 CIM_CHAR16 CIMTYPE_ENUMERATION = 103 CIM_OBJECT CIMTYPE_ENUMERATION = 13 CIM_FLAG_ARRAY CIMTYPE_ENUMERATION = 0x2000 )
type IWbemClassObjectVtbl ¶
type IWbemClassObjectVtbl struct { QueryInterface uintptr AddRef uintptr Release uintptr GetQualifierSet uintptr Get uintptr Put uintptr Delete uintptr GetNames uintptr BeginEnumeration uintptr Next uintptr EndEnumeration uintptr GetPropertyQualifierSet uintptr Clone uintptr GetObjectText uintptr SpawnDerivedClass uintptr SpawnInstance uintptr CompareTo uintptr GetPropertyOrigin uintptr InheritsFrom uintptr GetMethod uintptr PutMethod uintptr DeleteMethod uintptr BeginMethodEnumeration uintptr NextMethod uintptr EndMethodEnumeration uintptr GetMethodQualifierSet uintptr GetMethodOrigin uintptr }
type IWbemLocatorVtbl ¶
type IWbemServicesVtbl ¶
type IWbemServicesVtbl struct { QueryInterface uintptr AddRef uintptr Release uintptr OpenNamespace uintptr CancelAsyncCall uintptr QueryObjectSink uintptr GetObject uintptr GetObjectAsync uintptr PutClass uintptr PutClassAsync uintptr DeleteClass uintptr DeleteClassAsync uintptr CreateClassEnum uintptr CreateClassEnumAsync uintptr PutInstance uintptr PutInstanceAsync uintptr DeleteInstance uintptr DeleteInstanceAsync uintptr CreateInstanceEnum uintptr CreateInstanceEnumAsync uintptr ExecQuery uintptr ExecQueryAsync uintptr ExecNotificationQuery uintptr ExecNotificationQueryAsync uintptr ExecMethod uintptr ExecMethodAsync uintptr }
type Instance ¶
type Instance struct {
// contains filtered or unexported fields
}
func (*Instance) BeginEnumeration ¶
BeginEnumeration begins iterating the property list on this instance. This is an advanced method. In most cases, the GetAsXXX() methods, GetAll(), and GetAllProperties() methods should be preferred.
func (*Instance) BeginInvoke ¶
func (i *Instance) BeginInvoke(method string) *MethodExecutor
BeginInvoke invokes a method on this Instance. Returns a MethodExecutor builder object that is used to construct the input parameters (via calls to In()), perform the invocation (using calls to Execute()), retrieve output parameters (via calls to Out()), and finally the method return value (using a call to End())
func (*Instance) CloneInstance ¶
CloneInstance create a new cloned copy of this WMI instance.
func (*Instance) Close ¶
func (i *Instance) Close()
Close cleans up all memory associated with this instance.
func (*Instance) EndEnumeration ¶
EndEnumeration completes iterating a property list on this instance. This is an advanced method. In most cases, the GetAsXXX() methods, GetAll(), and GetAllProperties() methods should be preferred.
func (*Instance) GetAll ¶
GetAll gets all fields that map to a target struct and populates all struct fields according to the expected type information. The target parameter should be a pointer to a struct, and will return an error otherwise.
func (*Instance) GetAllProperties ¶
GetAllProperties gets all properties on this instance. The returned map is keyed by the field name and the value is a Golang type which matches the WMI internal implementation. For static type conversions, it's recommended to use either GetAll(), which uses struct fields for type information, or the GetAsXXX() methods.
func (*Instance) GetAsAny ¶
func (i *Instance) GetAsAny(name string) (interface{}, CIMTYPE_ENUMERATION, WBEM_FLAVOR_TYPE, error)
GetAsAny gets a property and converts it to a Golang type that matches the internal variant automation type passed back from WMI. For usage with predictable static type mapping, use GetAsString(), GetAsUint(), or GetAll() instead of this method.
func (*Instance) GetAsString ¶
GetAsString gets a property value as a string value, converting if necessary
func (*Instance) GetAsUint ¶
GetAsUint gets a property value as a uint value, if conversion is possible. Otherwise, returns an error.
func (*Instance) GetAsVariant ¶
func (i *Instance) GetAsVariant(name string) (*ole.VARIANT, CIMTYPE_ENUMERATION, WBEM_FLAVOR_TYPE, error)
GetAsVariant obtains a specified property value, if it exists.
func (*Instance) GetCimText ¶
GetCimText returns the CIM XML representation of this instance. Some WMI methods use a string parameter to represent a full complex object, and this method is used to generate the expected format.
func (*Instance) GetClassName ¶
GetClassName Gets the WMI class name for this WMI object instance
func (*Instance) GetMethodParameters ¶
GetMethodParameters returns a WMI class object which represents the [in] method parameters for a method invocation. This is an advanced method, used for dynamic introspection or manual method invocation. In most cases it is recommended to use BeginInvoke() instead, which constructs the parameter payload automatically.
func (*Instance) IsReferenceProperty ¶
IsReferenceProperty returns whether the property is of type CIM_REFERENCE, a string which points to an object path of another instance.
func (*Instance) Next ¶
func (i *Instance) Next() (done bool, name string, value interface{}, cimType CIMTYPE_ENUMERATION, flavor WBEM_FLAVOR_TYPE, err error)
Next retrieves the next property as a Golang type when iterating the properties using an enumerator created by BeginEnumeration(). The returned value's type represents the internal automation type used by WMI. It is usually preferred to use GetAsXXX(), GetAll(), or GetAll Properties() over this method.
func (*Instance) NextAsVariant ¶
func (i *Instance) NextAsVariant() (bool, string, *ole.VARIANT, CIMTYPE_ENUMERATION, WBEM_FLAVOR_TYPE, error)
NextAsVariant retrieves the next property as a VARIANT type when iterating the properties using an enumerator created by BeginEnumeration(). The returned value's type represents the internal automation type used by WMI. It is usually preferred to use GetAsXXX(), GetAll(), or GetAllProperties() over this method. Callers are responsible for clearing the VARIANT, otherwise associated memory will leak.
func (*Instance) Put ¶
Put sets the specified property to the passed Golang value, converting appropriately.
func (*Instance) PutAll ¶
PutAll sets all fields of this instance to the passed src parameter's fields, converting accordingly. The src parameter must be a pointer to a struct, otherwise an error will be returned.
func (*Instance) SpawnInstance ¶
SpawnInstance create a new WMI object instance that is zero-initialized. The returned instance will not respect expected default values, which must be populated by other means.
type MethodExecutor ¶
type MethodExecutor struct {
// contains filtered or unexported fields
}
func (*MethodExecutor) End ¶
func (e *MethodExecutor) End() error
End completes the method invocation and returns an error indicating the return code of the underlying method
func (*MethodExecutor) Error ¶
func (e *MethodExecutor) Error() error
Obtains the last error that occurred while building the invocation. Once an error has occurred, all future operations are treated as a no-op.
func (*MethodExecutor) Execute ¶
func (e *MethodExecutor) Execute() *MethodExecutor
Execute executes the method after in parameters have been specified using In()
func (*MethodExecutor) In ¶
func (e *MethodExecutor) In(name string, value interface{}) *MethodExecutor
In sets an input parameter for the method of this invocation, converting appropriately
func (*MethodExecutor) Out ¶
func (e *MethodExecutor) Out(name string, value interface{}) *MethodExecutor
Out sets the specified output parameter, and assigns the value parameter to the result. The value parameter must be a reference to the field that should be set.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func NewLocalService ¶
NewLocalService creates a service and connect it to the local system at the specified namespace
func (*Service) Close ¶
func (s *Service) Close()
Close frees all associated memory with this service
func (*Service) CreateInstance ¶
CreateInstance creates a new WMI object class instance of the specified className, and sets all properties according to the passed in struct pointer through the src parameter, converting appropriately.
func (*Service) CreateInstanceEnum ¶
CreateInstanceEnum creates an enumerator that iterates all registered object instances for a given className.
func (*Service) ExecMethod ¶
func (s *Service) ExecMethod(className string, methodName string, inParams *Instance) (*Instance, error)
ExecMethod executes a method using the specified class and parameter payload instance. The parameter payload instance can be constructed using Instance.GetMethodParameters(). This is an advanced method, it is recommended to use BeginInvoke() instead, where possible.
func (*Service) ExecQuery ¶
ExecQuery executes a WQL query and returns an enumeration to iterate the result set. Queries are executed in a semi-synchronous fashion.
func (*Service) FindFirstInstance ¶
FindFirstInstance find and returns the first WMI Instance in the result set for a WSL query.
func (*Service) FindFirstObject ¶
FindFirstObject finds and returns the first WMI Instance in the result set for a WSL query, and populates the specified struct pointer passed in through the target parameter.
func (*Service) FindFirstRelatedInstance ¶
FindFirstRelatedInstance finds and returns a related associator of the specified WMI object path of the expected className type.
func (*Service) GetClassInstance ¶
GetClassInstance gets the WMI class instance associated with the specified object instance. This method is used to perform schema queries.
func (*Service) GetObjectAsObject ¶
GetObjectAsObject gets an object by its path and set all fields of the passed in target to match the instance's properties. Conversion is performed as appropriate.
func (*Service) GetSingletonInstance ¶
GetSingletonInstance gets the first WMI instance of the specified object class type. This is a shortcut method for uses where only one instance is expected.
func (*Service) RefetchObject ¶
RefetchObject re-fetches the object and returns a new instance. The original instance will not automatically Close(). Callers of this method will need to manually close the original.
type WBEM_FLAVOR_TYPE ¶
type WBEM_FLAVOR_TYPE uint32
const ( WBEM_FLAVOR_DONT_PROPAGATE WBEM_FLAVOR_TYPE = 0 WBEM_FLAVOR_FLAG_PROPAGATE_TO_INSTANCE WBEM_FLAVOR_TYPE = 0x1 WBEM_FLAVOR_FLAG_PROPAGATE_TO_DERIVED_CLASS WBEM_FLAVOR_TYPE = 0x2 WBEM_FLAVOR_MASK_PROPAGATION WBEM_FLAVOR_TYPE = 0xf WBEM_FLAVOR_OVERRIDABLE WBEM_FLAVOR_TYPE = 0 WBEM_FLAVOR_NOT_OVERRIDABLE WBEM_FLAVOR_TYPE = 0x10 WBEM_FLAVOR_MASK_PERMISSIONS WBEM_FLAVOR_TYPE = 0x10 WBEM_FLAVOR_ORIGIN_LOCAL WBEM_FLAVOR_TYPE = 0 WBEM_FLAVOR_ORIGIN_PROPAGATED WBEM_FLAVOR_TYPE = 0x20 WBEM_FLAVOR_ORIGIN_SYSTEM WBEM_FLAVOR_TYPE = 0x40 WBEM_FLAVOR_MASK_ORIGIN WBEM_FLAVOR_TYPE = 0x60 WBEM_FLAVOR_NOT_AMENDED WBEM_FLAVOR_TYPE = 0 WBEM_FLAVOR_AMENDED WBEM_FLAVOR_TYPE = 0x80 WBEM_FLAVOR_MASK_AMENDED WBEM_FLAVOR_TYPE = 0x80 )