Documentation ¶
Overview ¶
Example (Quickbooks) ¶
var err error connection := &Connection{nil} err = connection.Initialize() if err != nil { return } defer connection.Uninitialize() err = connection.Create("QBXMLRP2.RequestProcessor.1") if err != nil { if err.(*OleError).Code() == CO_E_CLASSSTRING { return } } defer connection.Release() dispatch, err := connection.Dispatch() if err != nil { return } defer dispatch.Release()
Output:
Example (SafeArrayGetElementString) ¶
This tests more than one function. It tests all of the functions needed in order to retrieve an SafeArray populated with Strings.
CoInitialize(0) defer CoUninitialize() clsid, err := CLSIDFromProgID("QBXMLRP2.RequestProcessor.1") if err != nil { if err.(*OleError).Code() == CO_E_CLASSSTRING { return } } unknown, err := CreateInstance(clsid, IID_IUnknown) if err != nil { return } defer unknown.Release() dispatch, err := unknown.QueryInterface(IID_IDispatch) if err != nil { return } var dispid []int32 dispid, err = dispatch.GetIDsOfName([]string{"OpenConnection2"}) if err != nil { return } var result *VARIANT _, err = dispatch.Invoke(dispid[0], DISPATCH_METHOD, "", "Test Application 1", 1) if err != nil { return } dispid, err = dispatch.GetIDsOfName([]string{"BeginSession"}) if err != nil { return } result, err = dispatch.Invoke(dispid[0], DISPATCH_METHOD, "", 2) if err != nil { return } ticket := result.ToString() dispid, err = dispatch.GetIDsOfName([]string{"QBXMLVersionsForSession"}) if err != nil { return } result, err = dispatch.Invoke(dispid[0], DISPATCH_PROPERTYGET, ticket) if err != nil { return } // Where the real tests begin. var qbXMLVersions *SafeArray var qbXmlVersionStrings []string qbXMLVersions = result.ToArray().Array // Get array bounds var LowerBounds int32 var UpperBounds int32 LowerBounds, err = safeArrayGetLBound(qbXMLVersions, 1) if err != nil { return } UpperBounds, err = safeArrayGetUBound(qbXMLVersions, 1) if err != nil { return } totalElements := UpperBounds - LowerBounds + 1 qbXmlVersionStrings = make([]string, totalElements) for i := int32(0); i < totalElements; i++ { qbXmlVersionStrings[i], _ = safeArrayGetElementString(qbXMLVersions, i) } // Release Safe Array memory safeArrayDestroy(qbXMLVersions) dispid, err = dispatch.GetIDsOfName([]string{"EndSession"}) if err != nil { return } _, err = dispatch.Invoke(dispid[0], DISPATCH_METHOD, ticket) if err != nil { return } dispid, err = dispatch.GetIDsOfName([]string{"CloseConnection"}) if err != nil { return } _, err = dispatch.Invoke(dispid[0], DISPATCH_METHOD) if err != nil { return }
Output:
Index ¶
- Constants
- Variables
- func BstrToString(p *uint16) string
- func BytePtrToString(p *byte) string
- func CoInitialize(p uintptr) (err error)
- func CoInitializeEx(p uintptr, coinit uint32) (err error)
- func CoTaskMemFree(memptr uintptr)
- func CoUninitialize()
- func DeleteHString(hstring HString) (err error)
- func DispatchMessage(msg *Msg) (ret int32)
- func GetMessage(msg *Msg, hwnd uint32, MsgFilterMin uint32, MsgFilterMax uint32) (ret int32, err error)
- func GetUserDefaultLCID() (lcid uint32)
- func GetVariantDate(value uint64) (time.Time, error)
- func IsEqualGUID(guid1 *GUID, guid2 *GUID) bool
- func LpOleStrToString(p *uint16) string
- func RoInitialize(thread_type uint32) (err error)
- func StringFromCLSID(clsid *GUID) (str string, err error)
- func StringFromIID(iid *GUID) (str string, err error)
- func SysAllocString(v string) (ss *int16)
- func SysAllocStringLen(v string) (ss *int16)
- func SysFreeString(v *int16) (err error)
- func SysStringLen(v *int16) uint32
- func UTF16PtrToString(p *uint16) string
- func VariantClear(v *VARIANT) (err error)
- func VariantInit(v *VARIANT) (err error)
- type BindOpts
- type Connection
- type DISPPARAMS
- type Dispatch
- func (d *Dispatch) Call(method string, params ...interface{}) (result *VARIANT, err error)
- func (d *Dispatch) Get(name string, params ...interface{}) (result *VARIANT, err error)
- func (d *Dispatch) GetId(name string) (id int32, err error)
- func (d *Dispatch) GetIds(names ...string) (dispid []int32, err error)
- func (d *Dispatch) Invoke(id int32, dispatch int16, params []interface{}) (result *VARIANT, err error)
- func (d *Dispatch) MustCall(method string, params ...interface{}) (result *VARIANT)
- func (d *Dispatch) MustGet(name string, params ...interface{}) (result *VARIANT)
- func (d *Dispatch) MustSet(name string, params ...interface{}) (result *VARIANT)
- func (d *Dispatch) Release()
- func (d *Dispatch) Set(name string, params ...interface{}) (result *VARIANT, err error)
- type EXCEPINFO
- type GUID
- type HString
- type IConnectionPoint
- func (v *IConnectionPoint) Advise(unknown *IUnknown) (cookie uint32, err error)
- func (v *IConnectionPoint) EnumConnections(p *unsafe.Pointer) error
- func (v *IConnectionPoint) GetConnectionInterface(piid **GUID) int32
- func (v *IConnectionPoint) Unadvise(cookie uint32) (err error)
- func (v *IConnectionPoint) VTable() *IConnectionPointVtbl
- type IConnectionPointContainer
- type IConnectionPointContainerVtbl
- type IConnectionPointVtbl
- type IDLDESC
- type IDispatch
- func (v *IDispatch) CallMethod(name string, params ...interface{}) (*VARIANT, error)
- func (v *IDispatch) GetIDsOfName(names []string) (dispid []int32, err error)
- func (v *IDispatch) GetProperty(name string, params ...interface{}) (*VARIANT, error)
- func (v *IDispatch) GetSingleIDOfName(name string) (displayID int32, err error)
- func (v *IDispatch) GetTypeInfo() (tinfo *ITypeInfo, err error)
- func (v *IDispatch) GetTypeInfoCount() (c uint32, err error)
- func (v *IDispatch) Invoke(dispid int32, dispatch int16, params ...interface{}) (result *VARIANT, err error)
- func (v *IDispatch) InvokeWithOptionalArgs(name string, dispatch int16, params []interface{}) (result *VARIANT, err error)
- func (v *IDispatch) PutProperty(name string, params ...interface{}) (*VARIANT, error)
- func (v *IDispatch) VTable() *IDispatchVtbl
- type IDispatchVtbl
- type IEnumVARIANT
- type IEnumVARIANTVtbl
- type IInspectable
- type IInspectableVtbl
- type INTERFACEDATA
- type IProvideClassInfo
- type IProvideClassInfoVtbl
- type ITypeInfo
- type ITypeInfoVtbl
- type IUnknown
- func CreateDispTypeInfo(idata *INTERFACEDATA) (pptinfo *IUnknown, err error)
- func CreateInstance(clsid *GUID, iid *GUID) (unk *IUnknown, err error)
- func GetActiveObject(clsid *GUID, iid *GUID) (unk *IUnknown, err error)
- func GetObject(programID string, bindOpts *BindOpts, iid *GUID) (unk *IUnknown, err error)
- func (v *IUnknown) AddRef() int32
- func (v *IUnknown) IDispatch(interfaceID *GUID) (dispatch *IDispatch, err error)
- func (v *IUnknown) IEnumVARIANT(interfaceID *GUID) (enum *IEnumVARIANT, err error)
- func (v *IUnknown) MustQueryInterface(iid *GUID) (disp *IDispatch)
- func (v *IUnknown) PutQueryInterface(interfaceID *GUID, obj interface{}) error
- func (v *IUnknown) QueryInterface(iid *GUID) (*IDispatch, error)
- func (v *IUnknown) Release() int32
- func (v *IUnknown) VTable() *IUnknownVtbl
- type IUnknownVtbl
- type METHODDATA
- type Msg
- type OleError
- type PARAMDATA
- type Point
- type SAFEARRAY
- type SAFEARRAYBOUND
- type SafeArray
- type SafeArrayBound
- type SafeArrayConversion
- func (sac *SafeArrayConversion) GetDimensions() (dimensions *uint32, err error)
- func (sac *SafeArrayConversion) GetSize() (length *uint32, err error)
- func (sac *SafeArrayConversion) GetType() (varType uint16, err error)
- func (sac *SafeArrayConversion) Release()
- func (sac *SafeArrayConversion) ToByteArray() (bytes []byte)
- func (sac *SafeArrayConversion) ToStringArray() (strings []string)
- func (sac *SafeArrayConversion) ToValueArray() (values []interface{})
- func (sac *SafeArrayConversion) TotalElements(index uint32) (totalElements int32, err error)
- type TYPEATTR
- type TYPEDESC
- type UnknownLike
- type VARIANT
- type VT
Examples ¶
Constants ¶
const ( CLSCTX_INPROC_SERVER = 1 CLSCTX_INPROC_HANDLER = 2 CLSCTX_LOCAL_SERVER = 4 CLSCTX_INPROC_SERVER16 = 8 CLSCTX_REMOTE_SERVER = 16 CLSCTX_ALL = CLSCTX_INPROC_SERVER | CLSCTX_INPROC_HANDLER | CLSCTX_LOCAL_SERVER CLSCTX_INPROC = CLSCTX_INPROC_SERVER | CLSCTX_INPROC_HANDLER CLSCTX_SERVER = CLSCTX_INPROC_SERVER | CLSCTX_LOCAL_SERVER | CLSCTX_REMOTE_SERVER )
const ( COINIT_APARTMENTTHREADED = 0x2 COINIT_MULTITHREADED = 0x0 COINIT_DISABLE_OLE1DDE = 0x4 COINIT_SPEED_OVER_MEMORY = 0x8 )
const ( DISPATCH_METHOD = 1 DISPATCH_PROPERTYGET = 2 DISPATCH_PROPERTYPUT = 4 DISPATCH_PROPERTYPUTREF = 8 )
const ( S_OK = 0x00000000 E_UNEXPECTED = 0x8000FFFF E_NOTIMPL = 0x80004001 E_OUTOFMEMORY = 0x8007000E E_INVALIDARG = 0x80070057 E_NOINTERFACE = 0x80004002 E_POINTER = 0x80004003 E_HANDLE = 0x80070006 E_ABORT = 0x80004004 E_FAIL = 0x80004005 E_ACCESSDENIED = 0x80070005 E_PENDING = 0x8000000A CO_E_CLASSSTRING = 0x800401F3 )
const ( CC_FASTCALL = iota CC_CDECL CC_MSCPASCAL CC_PASCAL = CC_MSCPASCAL CC_MACPASCAL CC_STDCALL CC_FPFASTCALL CC_SYSCALL CC_MPWCDECL CC_MPWPASCAL CC_MAX = CC_MPWPASCAL )
const ( DISPID_UNKNOWN = -1 DISPID_VALUE = 0 DISPID_PROPERTYPUT = -3 DISPID_NEWENUM = -4 DISPID_EVALUATE = -5 DISPID_CONSTRUCTOR = -6 DISPID_DESTRUCTOR = -7 DISPID_COLLECT = -8 )
const ( TKIND_ENUM = 1 TKIND_RECORD = 2 TKIND_MODULE = 3 TKIND_INTERFACE = 4 TKIND_DISPATCH = 5 TKIND_COCLASS = 6 TKIND_ALIAS = 7 TKIND_UNION = 8 TKIND_MAX = 9 )
const ( FADF_AUTO = 0x0001 FADF_STATIC = 0x0002 FADF_EMBEDDED = 0x0004 FADF_FIXEDSIZE = 0x0010 FADF_RECORD = 0x0020 FADF_HAVEIID = 0x0040 FADF_HAVEVARTYPE = 0x0080 FADF_BSTR = 0x0100 FADF_UNKNOWN = 0x0200 FADF_DISPATCH = 0x0400 FADF_VARIANT = 0x0800 FADF_RESERVED = 0xF008 )
Variables ¶
var ( // IID_NULL is null Interface ID, used when no other Interface ID is known. IID_NULL = NewGUID("{00000000-0000-0000-0000-000000000000}") // IID_IUnknown is for IUnknown interfaces. IID_IUnknown = NewGUID("{00000000-0000-0000-C000-000000000046}") // IID_IDispatch is for IDispatch interfaces. IID_IDispatch = NewGUID("{00020400-0000-0000-C000-000000000046}") // IID_IEnumVariant is for IEnumVariant interfaces IID_IEnumVariant = NewGUID("{00020404-0000-0000-C000-000000000046}") // IID_IConnectionPointContainer is for IConnectionPointContainer interfaces. IID_IConnectionPointContainer = NewGUID("{B196B284-BAB4-101A-B69C-00AA00341D07}") // IID_IConnectionPoint is for IConnectionPoint interfaces. IID_IConnectionPoint = NewGUID("{B196B286-BAB4-101A-B69C-00AA00341D07}") // IID_IInspectable is for IInspectable interfaces. IID_IInspectable = NewGUID("{AF86E2E0-B12D-4C6A-9C5A-D7AA65101E90}") // IID_IProvideClassInfo is for IProvideClassInfo interfaces. IID_IProvideClassInfo = NewGUID("{B196B283-BAB4-101A-B69C-00AA00341D07}") )
var ( // IID_ICOMTestString is for ICOMTestString interfaces. // // {E0133EB4-C36F-469A-9D3D-C66B84BE19ED} IID_ICOMTestString = NewGUID("{E0133EB4-C36F-469A-9D3D-C66B84BE19ED}") // IID_ICOMTestInt8 is for ICOMTestInt8 interfaces. // // {BEB06610-EB84-4155-AF58-E2BFF53680B4} IID_ICOMTestInt8 = NewGUID("{BEB06610-EB84-4155-AF58-E2BFF53680B4}") // IID_ICOMTestInt16 is for ICOMTestInt16 interfaces. // // {DAA3F9FA-761E-4976-A860-8364CE55F6FC} IID_ICOMTestInt16 = NewGUID("{DAA3F9FA-761E-4976-A860-8364CE55F6FC}") // IID_ICOMTestInt32 is for ICOMTestInt32 interfaces. // // {E3DEDEE7-38A2-4540-91D1-2EEF1D8891B0} IID_ICOMTestInt32 = NewGUID("{E3DEDEE7-38A2-4540-91D1-2EEF1D8891B0}") // IID_ICOMTestInt64 is for ICOMTestInt64 interfaces. // // {8D437CBC-B3ED-485C-BC32-C336432A1623} IID_ICOMTestInt64 = NewGUID("{8D437CBC-B3ED-485C-BC32-C336432A1623}") // IID_ICOMTestFloat is for ICOMTestFloat interfaces. // // {BF1ED004-EA02-456A-AA55-2AC8AC6B054C} IID_ICOMTestFloat = NewGUID("{BF1ED004-EA02-456A-AA55-2AC8AC6B054C}") // IID_ICOMTestDouble is for ICOMTestDouble interfaces. // // {BF908A81-8687-4E93-999F-D86FAB284BA0} IID_ICOMTestDouble = NewGUID("{BF908A81-8687-4E93-999F-D86FAB284BA0}") // IID_ICOMTestBoolean is for ICOMTestBoolean interfaces. // // {D530E7A6-4EE8-40D1-8931-3D63B8605010} IID_ICOMTestBoolean = NewGUID("{D530E7A6-4EE8-40D1-8931-3D63B8605010}") // IID_ICOMEchoTestObject is for ICOMEchoTestObject interfaces. // // {6485B1EF-D780-4834-A4FE-1EBB51746CA3} IID_ICOMEchoTestObject = NewGUID("{6485B1EF-D780-4834-A4FE-1EBB51746CA3}") // IID_ICOMTestTypes is for ICOMTestTypes interfaces. // // {CCA8D7AE-91C0-4277-A8B3-FF4EDF28D3C0} IID_ICOMTestTypes = NewGUID("{CCA8D7AE-91C0-4277-A8B3-FF4EDF28D3C0}") // CLSID_COMEchoTestObject is for COMEchoTestObject class. // // {3C24506A-AE9E-4D50-9157-EF317281F1B0} CLSID_COMEchoTestObject = NewGUID("{3C24506A-AE9E-4D50-9157-EF317281F1B0}") // CLSID_COMTestScalarClass is for COMTestScalarClass class. // // {865B85C5-0334-4AC6-9EF6-AACEC8FC5E86} CLSID_COMTestScalarClass = NewGUID("{865B85C5-0334-4AC6-9EF6-AACEC8FC5E86}") )
These are for testing and not part of any library.
Functions ¶
func BstrToString ¶
BstrToString converts COM binary string to Go string.
func BytePtrToString ¶
BytePtrToString converts byte pointer to a Go string.
func CoInitialize ¶
CoInitialize initializes COM library on current thread.
MSDN documentation suggests that this function should not be called. Call CoInitializeEx() instead. The reason has to do with threading and this function is only for single-threaded apartments.
That said, most users of the library have gotten away with just this function. If you are experiencing threading issues, then use CoInitializeEx().
func CoInitializeEx ¶
CoInitializeEx initializes COM library with concurrency model.
func DispatchMessage ¶
DispatchMessage to window procedure.
func GetMessage ¶
func GetMessage(msg *Msg, hwnd uint32, MsgFilterMin uint32, MsgFilterMax uint32) (ret int32, err error)
GetMessage in message queue from runtime.
This function appears to block. PeekMessage does not block.
func GetUserDefaultLCID ¶
func GetUserDefaultLCID() (lcid uint32)
GetUserDefaultLCID retrieves current user default locale.
func GetVariantDate ¶
GetVariantDate converts COM Variant Time value to Go time.Time.
func LpOleStrToString ¶
LpOleStrToString converts COM Unicode to Go string.
func RoInitialize ¶
func StringFromCLSID ¶
StringFromCLSID returns GUID formated string from GUID object.
func StringFromIID ¶
StringFromIID returns GUID formatted string from GUID object.
func SysAllocString ¶
SysAllocString allocates memory for string and copies string into memory.
func SysAllocStringLen ¶
SysAllocStringLen copies up to length of given string returning pointer.
func SysFreeString ¶
SysFreeString frees string system memory. This must be called with SysAllocString.
func SysStringLen ¶
SysStringLen is the length of the system allocated string.
func UTF16PtrToString ¶
UTF16PtrToString is alias for LpOleStrToString.
Kept for compatibility reasons.
func VariantClear ¶
VariantClear clears value in Variant settings to VT_EMPTY.
Types ¶
type Connection ¶
type Connection struct {
Object *IUnknown // Access COM
}
Connection contains IUnknown for fluent interface interaction.
Deprecated. Use oleutil package instead.
func Connect ¶
func Connect(names ...string) (connection *Connection)
Connect initializes COM and attempts to load IUnknown based on given names.
func (*Connection) Create ¶
func (c *Connection) Create(progId string) (err error)
Create IUnknown object based first on ProgId and then from String.
func (*Connection) Dispatch ¶
func (c *Connection) Dispatch() (object *Dispatch, err error)
Dispatch returns Dispatch object.
func (*Connection) Load ¶
func (c *Connection) Load(names ...string) (errors []error)
Load COM object from list of programIDs or strings.
type DISPPARAMS ¶
type DISPPARAMS struct {
// contains filtered or unexported fields
}
DISPPARAMS are the arguments that passed to methods or property.
type Dispatch ¶
type Dispatch struct {
Object *IDispatch // Dispatch object.
}
Dispatch stores IDispatch object.
func (*Dispatch) Invoke ¶
func (d *Dispatch) Invoke(id int32, dispatch int16, params []interface{}) (result *VARIANT, err error)
Invoke IDispatch on DisplayID of dispatch type with parameters.
There have been problems where if send cascading params..., it would error out because the parameters would be empty.
type EXCEPINFO ¶
type EXCEPINFO struct {
// contains filtered or unexported fields
}
EXCEPINFO defines exception info.
func (*EXCEPINFO) Clear ¶ added in v1.2.6
func (e *EXCEPINFO) Clear()
Clear frees BSTR strings inside an EXCEPINFO and set it to NULL.
type GUID ¶
GUID is Windows API specific GUID type.
This exists to match Windows GUID type for direct passing for COM. Format is in xxxxxxxx-xxxx-xxxx-xxxxxxxxxxxxxxxx.
func CLSIDFromProgID ¶
CLSIDFromProgID retrieves Class Identifier with the given Program Identifier.
The Programmatic Identifier must be registered, because it will be looked up in the Windows Registry. The registry entry has the following keys: CLSID, Insertable, Protocol and Shell (https://msdn.microsoft.com/en-us/library/dd542719(v=vs.85).aspx).
programID identifies the class id with less precision and is not guaranteed to be unique. These are usually found in the registry under HKEY_LOCAL_MACHINE\SOFTWARE\Classes, usually with the format of "Program.Component.Version" with version being optional.
CLSIDFromProgID in Windows API.
func CLSIDFromString ¶
CLSIDFromString retrieves Class ID from string representation.
This is technically the string version of the GUID and will convert the string to object.
CLSIDFromString in Windows API.
func ClassIDFrom ¶
ClassIDFrom retrieves class ID whether given is program ID or application string.
Helper that provides check against both Class ID from Program ID and Class ID from string. It is faster, if you know which you are using, to use the individual functions, but this will check against available functions for you.
func IIDFromString ¶
IIDFromString returns GUID from program ID.
func NewGUID ¶
NewGUID converts the given string into a globally unique identifier that is compliant with the Windows API.
The supplied string may be in any of these formats:
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX {XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}
The conversion of the supplied string is not case-sensitive.
type HString ¶
type HString uintptr
HString is handle string for pointers.
func NewHString ¶
NewHString returns a new HString for Go string.
type IConnectionPoint ¶
type IConnectionPoint struct {
IUnknown
}
func (*IConnectionPoint) Advise ¶
func (v *IConnectionPoint) Advise(unknown *IUnknown) (cookie uint32, err error)
func (*IConnectionPoint) EnumConnections ¶
func (v *IConnectionPoint) EnumConnections(p *unsafe.Pointer) error
func (*IConnectionPoint) GetConnectionInterface ¶
func (v *IConnectionPoint) GetConnectionInterface(piid **GUID) int32
func (*IConnectionPoint) Unadvise ¶
func (v *IConnectionPoint) Unadvise(cookie uint32) (err error)
func (*IConnectionPoint) VTable ¶
func (v *IConnectionPoint) VTable() *IConnectionPointVtbl
type IConnectionPointContainer ¶
type IConnectionPointContainer struct {
IUnknown
}
func (*IConnectionPointContainer) EnumConnectionPoints ¶
func (v *IConnectionPointContainer) EnumConnectionPoints(points interface{}) error
func (*IConnectionPointContainer) FindConnectionPoint ¶
func (v *IConnectionPointContainer) FindConnectionPoint(iid *GUID, point **IConnectionPoint) (err error)
func (*IConnectionPointContainer) VTable ¶
func (v *IConnectionPointContainer) VTable() *IConnectionPointContainerVtbl
type IConnectionPointContainerVtbl ¶
type IConnectionPointContainerVtbl struct { IUnknownVtbl EnumConnectionPoints uintptr FindConnectionPoint uintptr }
type IConnectionPointVtbl ¶
type IDispatch ¶
type IDispatch struct {
IUnknown
}
func CreateStdDispatch ¶
CreateStdDispatch provides default IDispatch implementation for IUnknown.
This handles default IDispatch implementation for objects. It haves a few limitations with only supporting one language. It will also only return default exception codes.
func (*IDispatch) CallMethod ¶
CallMethod invokes named function with arguments on object.
func (*IDispatch) GetIDsOfName ¶
func (*IDispatch) GetProperty ¶
GetProperty retrieves the property with the name with the ability to pass arguments.
Most of the time you will not need to pass arguments as most objects do not allow for this feature. Or at least, should not allow for this feature. Some servers don't follow best practices and this is provided for those edge cases.
func (*IDispatch) GetSingleIDOfName ¶
GetSingleIDOfName is a helper that returns single display ID for IDispatch name.
This replaces the common pattern of attempting to get a single name from the list of available IDs. It gives the first ID, if it is available.
func (*IDispatch) GetTypeInfo ¶
func (*IDispatch) GetTypeInfoCount ¶
func (*IDispatch) InvokeWithOptionalArgs ¶
func (v *IDispatch) InvokeWithOptionalArgs(name string, dispatch int16, params []interface{}) (result *VARIANT, err error)
InvokeWithOptionalArgs accepts arguments as an array, works like Invoke.
Accepts name and will attempt to retrieve Display ID to pass to Invoke.
Passing params as an array is a workaround that could be fixed in later versions of Go that prevent passing empty params. During testing it was discovered that this is an acceptable way of getting around not being able to pass params normally.
func (*IDispatch) PutProperty ¶
PutProperty attempts to mutate a property in the object.
func (*IDispatch) VTable ¶
func (v *IDispatch) VTable() *IDispatchVtbl
type IDispatchVtbl ¶
type IDispatchVtbl struct { IUnknownVtbl GetTypeInfoCount uintptr GetTypeInfo uintptr GetIDsOfNames uintptr Invoke uintptr }
type IEnumVARIANT ¶
type IEnumVARIANT struct {
IUnknown
}
func (*IEnumVARIANT) Clone ¶
func (enum *IEnumVARIANT) Clone() (cloned *IEnumVARIANT, err error)
func (*IEnumVARIANT) Next ¶
func (enum *IEnumVARIANT) Next(celt uint) (array VARIANT, length uint, err error)
func (*IEnumVARIANT) Reset ¶
func (enum *IEnumVARIANT) Reset() (err error)
func (*IEnumVARIANT) Skip ¶
func (enum *IEnumVARIANT) Skip(celt uint) (err error)
func (*IEnumVARIANT) VTable ¶
func (v *IEnumVARIANT) VTable() *IEnumVARIANTVtbl
type IEnumVARIANTVtbl ¶
type IEnumVARIANTVtbl struct { IUnknownVtbl Next uintptr Skip uintptr Reset uintptr Clone uintptr }
type IInspectable ¶
type IInspectable struct {
IUnknown
}
func RoActivateInstance ¶
func RoActivateInstance(clsid string) (ins *IInspectable, err error)
func RoGetActivationFactory ¶
func RoGetActivationFactory(clsid string, iid *GUID) (ins *IInspectable, err error)
func (*IInspectable) GetIids ¶
func (v *IInspectable) GetIids() (iids []*GUID, err error)
func (*IInspectable) GetRuntimeClassName ¶
func (v *IInspectable) GetRuntimeClassName() (s string, err error)
func (*IInspectable) GetTrustLevel ¶
func (v *IInspectable) GetTrustLevel() (level uint32, err error)
func (*IInspectable) VTable ¶
func (v *IInspectable) VTable() *IInspectableVtbl
type IInspectableVtbl ¶
type IInspectableVtbl struct { IUnknownVtbl GetIIds uintptr GetRuntimeClassName uintptr GetTrustLevel uintptr }
type INTERFACEDATA ¶
type INTERFACEDATA struct { MethodData *METHODDATA CMembers uint32 }
INTERFACEDATA defines interface info.
type IProvideClassInfo ¶
type IProvideClassInfo struct {
IUnknown
}
func (*IProvideClassInfo) GetClassInfo ¶
func (v *IProvideClassInfo) GetClassInfo() (cinfo *ITypeInfo, err error)
func (*IProvideClassInfo) VTable ¶
func (v *IProvideClassInfo) VTable() *IProvideClassInfoVtbl
type IProvideClassInfoVtbl ¶
type IProvideClassInfoVtbl struct { IUnknownVtbl GetClassInfo uintptr }
type ITypeInfo ¶
type ITypeInfo struct {
IUnknown
}
func (*ITypeInfo) GetTypeAttr ¶
func (*ITypeInfo) VTable ¶
func (v *ITypeInfo) VTable() *ITypeInfoVtbl
type ITypeInfoVtbl ¶
type ITypeInfoVtbl struct { IUnknownVtbl GetTypeAttr uintptr GetTypeComp uintptr GetFuncDesc uintptr GetVarDesc uintptr GetNames uintptr GetRefTypeOfImplType uintptr GetImplTypeFlags uintptr GetIDsOfNames uintptr Invoke uintptr GetDocumentation uintptr GetDllEntry uintptr GetRefTypeInfo uintptr AddressOfMember uintptr CreateInstance uintptr GetMops uintptr GetContainingTypeLib uintptr ReleaseTypeAttr uintptr ReleaseFuncDesc uintptr ReleaseVarDesc uintptr }
type IUnknown ¶
type IUnknown struct {
RawVTable *interface{}
}
func CreateDispTypeInfo ¶
func CreateDispTypeInfo(idata *INTERFACEDATA) (pptinfo *IUnknown, err error)
CreateDispTypeInfo provides default ITypeInfo implementation for IDispatch.
This will not handle the full implementation of the interface.
func CreateInstance ¶
CreateInstance of single uninitialized object with GUID.
func GetActiveObject ¶
GetActiveObject retrieves pointer to active object.
func (*IUnknown) IEnumVARIANT ¶
func (v *IUnknown) IEnumVARIANT(interfaceID *GUID) (enum *IEnumVARIANT, err error)
func (*IUnknown) MustQueryInterface ¶
func (*IUnknown) PutQueryInterface ¶
func (*IUnknown) VTable ¶
func (v *IUnknown) VTable() *IUnknownVtbl
type IUnknownVtbl ¶
type METHODDATA ¶
type METHODDATA struct { Name *uint16 Data *PARAMDATA Dispid int32 Meth uint32 CC int32 CArgs uint32 Flags uint16 VtReturn uint32 }
METHODDATA defines method info.
type OleError ¶
type OleError struct {
// contains filtered or unexported fields
}
OleError stores COM errors.
func NewErrorWithDescription ¶
NewErrorWithDescription creates new COM error with HResult and description.
func NewErrorWithSubError ¶
NewErrorWithSubError creates new COM error with parent error.
func (*OleError) Description ¶
Description retrieves error summary, if there is one.
type SAFEARRAY ¶
type SAFEARRAY SafeArray
SAFEARRAY is obsolete, exists for backwards compatibility. Use SafeArray
type SAFEARRAYBOUND ¶
type SAFEARRAYBOUND SafeArrayBound
SAFEARRAYBOUND is obsolete, exists for backwards compatibility. Use SafeArrayBound
type SafeArray ¶
type SafeArray struct { Dimensions uint16 FeaturesFlag uint16 ElementsSize uint32 LocksAmount uint32 Data uint32 Bounds [16]byte }
SafeArray is how COM handles arrays.
type SafeArrayBound ¶
SafeArrayBound defines the SafeArray boundaries.
type SafeArrayConversion ¶
type SafeArrayConversion struct {
Array *SafeArray
}
func (*SafeArrayConversion) GetDimensions ¶
func (sac *SafeArrayConversion) GetDimensions() (dimensions *uint32, err error)
func (*SafeArrayConversion) GetSize ¶
func (sac *SafeArrayConversion) GetSize() (length *uint32, err error)
func (*SafeArrayConversion) GetType ¶
func (sac *SafeArrayConversion) GetType() (varType uint16, err error)
func (*SafeArrayConversion) Release ¶
func (sac *SafeArrayConversion) Release()
Release Safe Array memory
func (*SafeArrayConversion) ToByteArray ¶
func (sac *SafeArrayConversion) ToByteArray() (bytes []byte)
func (*SafeArrayConversion) ToStringArray ¶
func (sac *SafeArrayConversion) ToStringArray() (strings []string)
func (*SafeArrayConversion) ToValueArray ¶
func (sac *SafeArrayConversion) ToValueArray() (values []interface{})
func (*SafeArrayConversion) TotalElements ¶
func (sac *SafeArrayConversion) TotalElements(index uint32) (totalElements int32, err error)
type TYPEATTR ¶
type TYPEATTR struct { Guid GUID Lcid uint32 MemidConstructor int32 MemidDestructor int32 LpstrSchema *uint16 CbSizeInstance uint32 Typekind int32 CFuncs uint16 CVars uint16 CImplTypes uint16 CbSizeVft uint16 CbAlignment uint16 WTypeFlags uint16 WMajorVerNum uint16 WMinorVerNum uint16 TdescAlias TYPEDESC IdldescType IDLDESC // contains filtered or unexported fields }
TYPEATTR defines type info.
type UnknownLike ¶
type VARIANT ¶
func NewVariant ¶
NewVariant returns new variant based on type and value.
func (*VARIANT) ToArray ¶
func (v *VARIANT) ToArray() *SafeArrayConversion
ToArray converts variant to SafeArray helper.
func (*VARIANT) ToIDispatch ¶
ToIDispatch converts variant to dispatch object.
func (*VARIANT) ToIUnknown ¶
ToIUnknown converts Variant to Unknown object.
func (*VARIANT) Value ¶
func (v *VARIANT) Value() interface{}
Value returns variant value based on its type.
Currently supported types: 2- and 4-byte integers, strings, bools. Note that 64-bit integers, datetimes, and other types are stored as strings and will be returned as strings.
Needs to be further converted, because this returns an interface{}.
type VT ¶
type VT uint16
const ( VT_EMPTY VT = 0x0 VT_NULL VT = 0x1 VT_I2 VT = 0x2 VT_I4 VT = 0x3 VT_R4 VT = 0x4 VT_R8 VT = 0x5 VT_CY VT = 0x6 VT_DATE VT = 0x7 VT_BSTR VT = 0x8 VT_DISPATCH VT = 0x9 VT_ERROR VT = 0xa VT_BOOL VT = 0xb VT_VARIANT VT = 0xc VT_UNKNOWN VT = 0xd VT_DECIMAL VT = 0xe VT_I1 VT = 0x10 VT_UI1 VT = 0x11 VT_UI2 VT = 0x12 VT_UI4 VT = 0x13 VT_I8 VT = 0x14 VT_UI8 VT = 0x15 VT_INT VT = 0x16 VT_UINT VT = 0x17 VT_VOID VT = 0x18 VT_HRESULT VT = 0x19 VT_PTR VT = 0x1a VT_SAFEARRAY VT = 0x1b VT_CARRAY VT = 0x1c VT_USERDEFINED VT = 0x1d VT_LPSTR VT = 0x1e VT_LPWSTR VT = 0x1f VT_RECORD VT = 0x24 VT_INT_PTR VT = 0x25 VT_UINT_PTR VT = 0x26 VT_FILETIME VT = 0x40 VT_BLOB VT = 0x41 VT_STREAM VT = 0x42 VT_STORAGE VT = 0x43 VT_STREAMED_OBJECT VT = 0x44 VT_STORED_OBJECT VT = 0x45 VT_BLOB_OBJECT VT = 0x46 VT_CF VT = 0x47 VT_CLSID VT = 0x48 VT_BSTR_BLOB VT = 0xfff VT_VECTOR VT = 0x1000 VT_ARRAY VT = 0x2000 VT_BYREF VT = 0x4000 VT_RESERVED VT = 0x8000 VT_ILLEGAL VT = 0xffff VT_ILLEGALMASKED VT = 0xfff VT_TYPEMASK VT = 0xfff )
Source Files ¶
- com.go
- connect.go
- constants.go
- error.go
- error_windows.go
- guid.go
- iconnectionpoint.go
- iconnectionpoint_windows.go
- iconnectionpointcontainer.go
- iconnectionpointcontainer_windows.go
- idispatch.go
- idispatch_windows.go
- ienumvariant.go
- ienumvariant_windows.go
- iinspectable.go
- iinspectable_windows.go
- iprovideclassinfo.go
- iprovideclassinfo_windows.go
- itypeinfo.go
- itypeinfo_windows.go
- iunknown.go
- iunknown_windows.go
- ole.go
- safearray.go
- safearray_windows.go
- safearrayconversion.go
- safearrayslices.go
- utility.go
- variables.go
- variant.go
- variant_amd64.go
- variant_date_amd64.go
- vt_string.go
- winrt.go