go-ole: github.com/go-ole/go-ole Index | Examples | Files | Directories

package ole

import "github.com/go-ole/go-ole"


var err error

connection := &Connection{nil}

err = connection.Initialize()
if err != nil {
defer connection.Uninitialize()

err = connection.Create("QBXMLRP2.RequestProcessor.1")
if err != nil {
    if err.(*OleError).Code() == CO_E_CLASSSTRING {
defer connection.Release()

dispatch, err := connection.Dispatch()
if err != nil {
defer dispatch.Release()


var err error

connection := &Connection{nil}

err = connection.Initialize()
if err != nil {
defer connection.Uninitialize()

err = connection.Create("QBXMLRP2.RequestProcessor.1")
if err != nil {
    if err.(*OleError).Code() == CO_E_CLASSSTRING {
defer connection.Release()

dispatch, err := connection.Dispatch()
if err != nil {
defer dispatch.Release()

var result *VARIANT

_, err = dispatch.Call("OpenConnection2", "", "Test Application 1", 1)
if err != nil {

result, err = dispatch.Call("BeginSession", "", 2)
if err != nil {

ticket := result.ToString()

_, err = dispatch.Call("EndSession", ticket)
if err != nil {

_, err = dispatch.Call("CloseConnection")
if err != nil {


var err error

connection := &Connection{nil}

err = connection.Initialize()
if err != nil {
defer connection.Uninitialize()

err = connection.Create("QBXMLRP2.RequestProcessor.1")
if err != nil {
    if err.(*OleError).Code() == CO_E_CLASSSTRING {
defer connection.Release()

dispatch, err := connection.Dispatch()
if err != nil {
defer dispatch.Release()

var result *VARIANT

_, err = dispatch.Call("OpenConnection2", "", "Test Application 1", 1)
if err != nil {

result, err = dispatch.Call("BeginSession", "", 2)
if err != nil {

ticket := result.ToString()

result, err = dispatch.Get("QBXMLVersionsForSession", ticket)
if err != nil {

conversion := result.ToArray()

totalElements, _ := conversion.TotalElements(0)
if totalElements != 13 {

versions := conversion.ToStringArray()
expectedVersionString := "1.0, 1.1, 2.0, 2.1, 3.0, 4.0, 4.1, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0"
versionString := strings.Join(versions, ", ")

if len(versions) != 13 {

if expectedVersionString != versionString {


_, err = dispatch.Call("EndSession", ticket)
if err != nil {

_, err = dispatch.Call("CloseConnection")
if err != nil {

This tests more than one function. It tests all of the functions needed in order to retrieve an SafeArray populated with Strings.


defer CoUninitialize()

clsid, err := CLSIDFromProgID("QBXMLRP2.RequestProcessor.1")
if err != nil {
    if err.(*OleError).Code() == CO_E_CLASSSTRING {

unknown, err := CreateInstance(clsid, IID_IUnknown)
if err != nil {
defer unknown.Release()

dispatch, err := unknown.QueryInterface(IID_IDispatch)
if err != nil {

var dispid []int32
dispid, err = dispatch.GetIDsOfName([]string{"OpenConnection2"})
if err != nil {

var result *VARIANT
_, err = dispatch.Invoke(dispid[0], DISPATCH_METHOD, "", "Test Application 1", 1)
if err != nil {

dispid, err = dispatch.GetIDsOfName([]string{"BeginSession"})
if err != nil {

result, err = dispatch.Invoke(dispid[0], DISPATCH_METHOD, "", 2)
if err != nil {

ticket := result.ToString()

dispid, err = dispatch.GetIDsOfName([]string{"QBXMLVersionsForSession"})
if err != nil {

result, err = dispatch.Invoke(dispid[0], DISPATCH_PROPERTYGET, ticket)
if err != nil {

// 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 {

UpperBounds, err = safeArrayGetUBound(qbXMLVersions, 1)
if err != nil {

totalElements := UpperBounds - LowerBounds + 1
qbXmlVersionStrings = make([]string, totalElements)

for i := int32(0); i < totalElements; i++ {
    qbXmlVersionStrings[i], _ = safeArrayGetElementString(qbXMLVersions, i)

// Release Safe Array memory

dispid, err = dispatch.GetIDsOfName([]string{"EndSession"})
if err != nil {

_, err = dispatch.Invoke(dispid[0], DISPATCH_METHOD, ticket)
if err != nil {

dispid, err = dispatch.GetIDsOfName([]string{"CloseConnection"})
if err != nil {

_, err = dispatch.Invoke(dispid[0], DISPATCH_METHOD)
if err != nil {



Package Files

com_func.go connect.go constants.go error.go error_func.go guid.go iconnectionpoint.go iconnectionpoint_func.go iconnectionpointcontainer.go iconnectionpointcontainer_func.go idispatch.go idispatch_func.go ienumvariant.go ienumvariant_func.go iinspectable.go iinspectable_func.go iprovideclassinfo.go iprovideclassinfo_func.go itypeinfo.go itypeinfo_func.go iunknown.go iunknown_func.go ole.go safearray.go safearray_func.go safearrayconversion.go utility.go variant.go variant_amd64.go vt_string.go winrt_doc.go


const (
const (
const (
    DISPATCH_METHOD         = 1
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
const (
    DISPID_UNKNOWN     = -1
    DISPID_VALUE       = 0
    DISPID_NEWENUM     = -4
    DISPID_COLLECT     = -8
const (
    TKIND_ENUM      = 1
    TKIND_RECORD    = 2
    TKIND_MODULE    = 3
    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_BSTR        = 0x0100
    FADF_UNKNOWN     = 0x0200
    FADF_DISPATCH    = 0x0400
    FADF_VARIANT     = 0x0800
    FADF_RESERVED    = 0xF008


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.

func BstrToString Uses

func BstrToString(p *uint16) string

BstrToString converts COM binary string to Go string.

func BytePtrToString Uses

func BytePtrToString(p *byte) string

BytePtrToString converts byte pointer to a Go string.

func CoInitialize Uses

func CoInitialize(p uintptr) error

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 Uses

func CoInitializeEx(p uintptr, coinit uint32) error

CoInitializeEx initializes COM library with concurrency model.

func CoTaskMemFree Uses

func CoTaskMemFree(memptr uintptr)

CoTaskMemFree frees memory pointer.

func CoUninitialize Uses

func CoUninitialize()

CoUninitialize uninitializes COM Library.

func DeleteHString Uses

func DeleteHString(hstring HString) (err error)

DeleteHString deletes HString.

func DispatchMessage Uses

func DispatchMessage(msg *Msg) int32

DispatchMessage to window procedure.

func GetMessage Uses

func GetMessage(msg *Msg, hwnd uint32, MsgFilterMin uint32, MsgFilterMax uint32) (int32, error)

GetMessage in message queue from runtime.

This function appears to block. PeekMessage does not block.

func GetUserDefaultLCID Uses

func GetUserDefaultLCID() uint32

GetUserDefaultLCID retrieves current user default locale.

func GetVariantDate Uses

func GetVariantDate(value uint64) (time.Time, error)

func IsEqualGUID Uses

func IsEqualGUID(guid1 *GUID, guid2 *GUID) bool

IsEqualGUID compares two GUID.

Not constant time comparison.

func LpOleStrToString Uses

func LpOleStrToString(p *uint16) string

LpOleStrToString converts COM Unicode to Go string.

func RoInitialize Uses

func RoInitialize(thread_type uint32) (err error)


func StringFromCLSID Uses

func StringFromCLSID(clsid *GUID) (string, error)

StringFromCLSID returns GUID formated string from GUID object.

func StringFromIID Uses

func StringFromIID(iid *GUID) (string, error)

StringFromIID returns GUID formatted string from GUID object.

func SysAllocString Uses

func SysAllocString(v string) *int16

SysAllocString allocates memory for string and copies string into memory.

func SysAllocStringLen Uses

func SysAllocStringLen(v string) *int16

SysAllocStringLen copies up to length of given string returning pointer.

func SysFreeString Uses

func SysFreeString(v *int16) error

SysFreeString frees string system memory. This must be called with SysAllocString.

func SysStringLen Uses

func SysStringLen(v *int16) uint32

SysStringLen is the length of the system allocated string.

func UTF16PtrToString Uses

func UTF16PtrToString(p *uint16) string

UTF16PtrToString is alias for LpOleStrToString.

Kept for compatibility reasons.

func VariantClear Uses

func VariantClear(v *VARIANT) error

VariantClear clears value in Variant settings to VT_EMPTY.

func VariantInit Uses

func VariantInit(v *VARIANT) error

VariantInit initializes variant.

type Connection Uses

type Connection struct {
    Object *IUnknown // Access COM

Connection contains IUnknown for fluent interface interaction.

Deprecated. Use oleutil package instead.

func Connect Uses

func Connect(names ...string) (connection *Connection)

Connect initializes COM and attempts to load IUnknown based on given names.

func (*Connection) Create Uses

func (c *Connection) Create(progId string) (err error)

Create IUnknown object based first on ProgId and then from String.

func (*Connection) Dispatch Uses

func (c *Connection) Dispatch() (object *Dispatch, err error)

Dispatch returns Dispatch object.

func (*Connection) Initialize Uses

func (*Connection) Initialize() (err error)

Initialize COM.

func (*Connection) Load Uses

func (c *Connection) Load(names ...string) (errors []error)

Load COM object from list of programIDs or strings.

func (*Connection) Release Uses

func (c *Connection) Release()

Release IUnknown object.

func (*Connection) Uninitialize Uses

func (*Connection) Uninitialize()

Uninitialize COM.


type DISPPARAMS struct {
    // contains filtered or unexported fields

DISPPARAMS are the arguments that passed to methods or property.

type Dispatch Uses

type Dispatch struct {
    Object *IDispatch // Dispatch object.

Dispatch stores IDispatch object.

func (*Dispatch) Call Uses

func (d *Dispatch) Call(method string, params ...interface{}) (result *VARIANT, err error)

Call method on IDispatch with parameters.

func (*Dispatch) Get Uses

func (d *Dispatch) Get(name string, params ...interface{}) (result *VARIANT, err error)

Get property on IDispatch with parameters.

func (*Dispatch) GetId Uses

func (d *Dispatch) GetId(name string) (id int32, err error)

GetId retrieves ID of name on IDispatch.

func (*Dispatch) GetIds Uses

func (d *Dispatch) GetIds(names ...string) (dispid []int32, err error)

GetIds retrieves all IDs of names on IDispatch.

func (*Dispatch) Invoke Uses

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.

func (*Dispatch) MustCall Uses

func (d *Dispatch) MustCall(method string, params ...interface{}) (result *VARIANT)

MustCall method on IDispatch with parameters.

func (*Dispatch) MustGet Uses

func (d *Dispatch) MustGet(name string, params ...interface{}) (result *VARIANT)

MustGet property on IDispatch with parameters.

func (*Dispatch) MustSet Uses

func (d *Dispatch) MustSet(name string, params ...interface{}) (result *VARIANT)

MustSet property on IDispatch with parameters.

func (*Dispatch) Release Uses

func (d *Dispatch) Release()

Release IDispatch object.

func (*Dispatch) Set Uses

func (d *Dispatch) Set(name string, params ...interface{}) (result *VARIANT, err error)

Set property on IDispatch with parameters.


type EXCEPINFO struct {
    // contains filtered or unexported fields

EXCEPINFO defines exception info.

func (EXCEPINFO) Error Uses

func (e EXCEPINFO) Error() string

Error implements error interface and returns error string.


func (e EXCEPINFO) SCODE() uint32

SCODE return scode in EXCEPINFO.

func (EXCEPINFO) String Uses

func (e EXCEPINFO) String() string

String convert EXCEPINFO to string.

func (EXCEPINFO) WCode Uses

func (e EXCEPINFO) WCode() uint16

WCode return wCode in EXCEPINFO.

type GUID Uses

type GUID struct {
    Data1 uint32
    Data2 uint16
    Data3 uint16
    Data4 [8]byte

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 Uses

func CLSIDFromProgID(progId string) (*GUID, error)

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 Uses

func CLSIDFromString(str string) (*GUID, error)

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 Uses

func ClassIDFrom(programID string) (classID *GUID, err error)

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 Uses

func IIDFromString(progId string) (*GUID, error)

IIDFromString returns GUID from program ID.

func NewGUID Uses

func NewGUID(guid string) *GUID

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:


The conversion of the supplied string is not case-sensitive.

func (*GUID) String Uses

func (guid *GUID) String() string

String converts the GUID to string form. It will adhere to this pattern:


If the GUID is nil, the string representation of an empty GUID is returned:


type HString Uses

type HString uintptr

HString is handle string for pointers.

func NewHString Uses

func NewHString(s string) (hstring HString, err error)

NewHString returns a new HString for Go string.

func (HString) String Uses

func (h HString) String() string

String returns Go string value of HString.

type IConnectionPoint Uses

type IConnectionPoint struct {

func (*IConnectionPoint) Advise Uses

func (v *IConnectionPoint) Advise(unknown *IUnknown) (uint32, error)

func (*IConnectionPoint) EnumConnections Uses

func (v *IConnectionPoint) EnumConnections(p *unsafe.Pointer) (err error)

func (*IConnectionPoint) GetConnectionInterface Uses

func (v *IConnectionPoint) GetConnectionInterface(piid **GUID) int32

func (*IConnectionPoint) Unadvise Uses

func (v *IConnectionPoint) Unadvise(cookie uint32) error

func (*IConnectionPoint) VTable Uses

func (v *IConnectionPoint) VTable() *IConnectionPointVtbl

type IConnectionPointContainer Uses

type IConnectionPointContainer struct {

func (*IConnectionPointContainer) EnumConnectionPoints Uses

func (v *IConnectionPointContainer) EnumConnectionPoints(points interface{}) error

func (*IConnectionPointContainer) FindConnectionPoint Uses

func (v *IConnectionPointContainer) FindConnectionPoint(iid *GUID, point **IConnectionPoint) error

func (*IConnectionPointContainer) VTable Uses

func (v *IConnectionPointContainer) VTable() *IConnectionPointContainerVtbl

type IConnectionPointContainerVtbl Uses

type IConnectionPointContainerVtbl struct {
    EnumConnectionPoints uintptr
    FindConnectionPoint  uintptr

type IConnectionPointVtbl Uses

type IConnectionPointVtbl struct {
    GetConnectionInterface      uintptr
    GetConnectionPointContainer uintptr
    Advise                      uintptr
    Unadvise                    uintptr
    EnumConnections             uintptr

type IDLDESC Uses

type IDLDESC struct {
    DwReserved uint32
    WIDLFlags  uint16

IDLDESC defines IDL info.

type IDispatch Uses

type IDispatch struct {

func CreateStdDispatch Uses

func CreateStdDispatch(unk *IUnknown, v uintptr, ptinfo *IUnknown) (*IDispatch, error)

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 Uses

func (v *IDispatch) CallMethod(name string, params ...interface{}) (*VARIANT, error)

CallMethod invokes named function with arguments on object.

func (*IDispatch) GetIDsOfName Uses

func (v *IDispatch) GetIDsOfName(names []string) (dispid []int32, err error)

func (*IDispatch) GetProperty Uses

func (v *IDispatch) GetProperty(name string, params ...interface{}) (*VARIANT, error)

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 Uses

func (v *IDispatch) GetSingleIDOfName(name string) (displayID int32, err error)

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 Uses

func (v *IDispatch) GetTypeInfo() (tinfo *ITypeInfo, err error)

func (*IDispatch) GetTypeInfoCount Uses

func (v *IDispatch) GetTypeInfoCount() (c uint32, err error)

func (*IDispatch) Invoke Uses

func (v *IDispatch) Invoke(dispid int32, dispatch int16, params ...interface{}) (result *VARIANT, err error)

func (*IDispatch) InvokeWithOptionalArgs Uses

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 Uses

func (v *IDispatch) PutProperty(name string, params ...interface{}) (*VARIANT, error)

PutProperty attempts to mutate a property in the object.

func (*IDispatch) VTable Uses

func (v *IDispatch) VTable() *IDispatchVtbl

type IDispatchVtbl Uses

type IDispatchVtbl struct {
    GetTypeInfoCount uintptr
    GetTypeInfo      uintptr
    GetIDsOfNames    uintptr
    Invoke           uintptr

type IEnumVARIANT Uses

type IEnumVARIANT struct {

func (*IEnumVARIANT) Clone Uses

func (enum *IEnumVARIANT) Clone() (*IEnumVARIANT, error)

func (*IEnumVARIANT) Next Uses

func (enum *IEnumVARIANT) Next(celt uint) (VARIANT, uint, error)

func (*IEnumVARIANT) Reset Uses

func (enum *IEnumVARIANT) Reset() error

func (*IEnumVARIANT) Skip Uses

func (enum *IEnumVARIANT) Skip(celt uint) error

func (*IEnumVARIANT) VTable Uses

func (v *IEnumVARIANT) VTable() *IEnumVARIANTVtbl

type IEnumVARIANTVtbl Uses

type IEnumVARIANTVtbl struct {
    Next  uintptr
    Skip  uintptr
    Reset uintptr
    Clone uintptr

type IInspectable Uses

type IInspectable struct {

func RoActivateInstance Uses

func RoActivateInstance(clsid string) (ins *IInspectable, err error)


func RoGetActivationFactory Uses

func RoGetActivationFactory(clsid string, iid *GUID) (ins *IInspectable, err error)


func (*IInspectable) GetIids Uses

func (v *IInspectable) GetIids() ([]*GUID, error)

func (*IInspectable) GetRuntimeClassName Uses

func (v *IInspectable) GetRuntimeClassName() (string, error)

func (*IInspectable) GetTrustLevel Uses

func (v *IInspectable) GetTrustLevel() (uint32, error)

func (*IInspectable) VTable Uses

func (v *IInspectable) VTable() *IInspectableVtbl

type IInspectableVtbl Uses

type IInspectableVtbl struct {
    GetIIds             uintptr
    GetRuntimeClassName uintptr
    GetTrustLevel       uintptr


type INTERFACEDATA struct {
    MethodData *METHODDATA
    CMembers   uint32

INTERFACEDATA defines interface info.

type IProvideClassInfo Uses

type IProvideClassInfo struct {

func (*IProvideClassInfo) GetClassInfo Uses

func (v *IProvideClassInfo) GetClassInfo() (cinfo *ITypeInfo, err error)

func (*IProvideClassInfo) VTable Uses

func (v *IProvideClassInfo) VTable() *IProvideClassInfoVtbl

type IProvideClassInfoVtbl Uses

type IProvideClassInfoVtbl struct {
    GetClassInfo uintptr

type ITypeInfo Uses

type ITypeInfo struct {

func (*ITypeInfo) GetTypeAttr Uses

func (v *ITypeInfo) GetTypeAttr() (*TYPEATTR, error)

func (*ITypeInfo) VTable Uses

func (v *ITypeInfo) VTable() *ITypeInfoVtbl

type ITypeInfoVtbl Uses

type ITypeInfoVtbl struct {
    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 Uses

type IUnknown struct {
    RawVTable *interface{}

func CreateDispTypeInfo Uses

func CreateDispTypeInfo(idata *INTERFACEDATA) (*IUnknown, error)

CreateDispTypeInfo provides default ITypeInfo implementation for IDispatch.

This will not handle the full implementation of the interface.

func CreateInstance Uses

func CreateInstance(clsid *GUID, iid *GUID) (*IUnknown, error)

CreateInstance of single uninitialized object with GUID.

func GetActiveObject Uses

func GetActiveObject(clsid *GUID, iid *GUID) (*IUnknown, error)

GetActiveObject retrieves pointer to active object.

func (*IUnknown) AddRef Uses

func (v *IUnknown) AddRef() int32

func (*IUnknown) IDispatch Uses

func (v *IUnknown) IDispatch(interfaceID *GUID) (dispatch *IDispatch, err error)

func (*IUnknown) IEnumVARIANT Uses

func (v *IUnknown) IEnumVARIANT(interfaceID *GUID) (enum *IEnumVARIANT, err error)

func (*IUnknown) MustQueryInterface Uses

func (v *IUnknown) MustQueryInterface(iid *GUID) (disp *IDispatch)

func (*IUnknown) PutQueryInterface Uses

func (v *IUnknown) PutQueryInterface(interfaceID *GUID, obj interface{}) error

func (*IUnknown) QueryInterface Uses

func (v *IUnknown) QueryInterface(iid *GUID) (*IDispatch, error)

func (*IUnknown) Release Uses

func (v *IUnknown) Release() int32

func (*IUnknown) VTable Uses

func (v *IUnknown) VTable() *IUnknownVtbl

type IUnknownVtbl Uses

type IUnknownVtbl struct {
    QueryInterface uintptr
    AddRef         uintptr
    Release        uintptr


type METHODDATA struct {
    Name     *uint16
    Data     *PARAMDATA
    Dispid   int32
    Meth     uint32
    CC       int32
    CArgs    uint32
    Flags    uint16
    VtReturn uint32

METHODDATA defines method info.

type Msg Uses

type Msg struct {
    Hwnd    uint32
    Message uint32
    Wparam  int32
    Lparam  int32
    Time    uint32
    Pt      Point

Msg is message between processes.

type OleError Uses

type OleError struct {
    // contains filtered or unexported fields

OleError stores COM errors.

func NewError Uses

func NewError(hr uintptr) *OleError

NewError creates new error with HResult.

func NewErrorWithDescription Uses

func NewErrorWithDescription(hr uintptr, description string) *OleError

NewErrorWithDescription creates new COM error with HResult and description.

func NewErrorWithSubError Uses

func NewErrorWithSubError(hr uintptr, description string, err error) *OleError

NewErrorWithSubError creates new COM error with parent error.

func (*OleError) Code Uses

func (v *OleError) Code() uintptr

Code is the HResult.

func (*OleError) Description Uses

func (v *OleError) Description() string

Description retrieves error summary, if there is one.

func (*OleError) Error Uses

func (v *OleError) Error() string

Error implements error interface.

func (*OleError) String Uses

func (v *OleError) String() string

String description, either manually set or format message with error code.

func (*OleError) SubError Uses

func (v *OleError) SubError() error

SubError returns parent error, if there is one.


type PARAMDATA struct {
    Name *int16
    Vt   uint16

PARAMDATA defines parameter data type.

type Point Uses

type Point struct {
    X   int32
    Y   int32

Point is 2D vector type.


type SAFEARRAY SafeArray

SAFEARRAY is obsolete, exists for backwards compatibility. Use SafeArray


type SAFEARRAYBOUND SafeArrayBound

SAFEARRAYBOUND is obsolete, exists for backwards compatibility. Use SafeArrayBound

type SafeArray Uses

type SafeArray struct {
    Dimensions   uint16
    FeaturesFlag uint16
    ElementsSize uint32
    LocksAmount  uint32
    Data         uint32
    Bounds       [16]byte

SafeArray is how COM handles arrays.

type SafeArrayBound Uses

type SafeArrayBound struct {
    Elements   uint32
    LowerBound int32

SafeArrayBound defines the SafeArray boundaries.

type SafeArrayConversion Uses

type SafeArrayConversion struct {
    Array *SafeArray

func (*SafeArrayConversion) GetDimensions Uses

func (sac *SafeArrayConversion) GetDimensions() (dimensions *uint32, err error)

func (*SafeArrayConversion) GetSize Uses

func (sac *SafeArrayConversion) GetSize() (length *uint32, err error)

func (*SafeArrayConversion) GetType Uses

func (sac *SafeArrayConversion) GetType() (varType uint16, err error)

func (*SafeArrayConversion) Release Uses

func (sac *SafeArrayConversion) Release()

Release Safe Array memory

func (*SafeArrayConversion) ToByteArray Uses

func (sac *SafeArrayConversion) ToByteArray() (bytes []byte)

func (*SafeArrayConversion) ToStringArray Uses

func (sac *SafeArrayConversion) ToStringArray() (strings []string)

func (*SafeArrayConversion) ToValueArray Uses

func (sac *SafeArrayConversion) ToValueArray() (values []interface{})

func (*SafeArrayConversion) TotalElements Uses

func (sac *SafeArrayConversion) TotalElements(index uint32) (totalElements int32, err error)

type TYPEATTR Uses

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 TYPEDESC Uses

type TYPEDESC struct {
    Hreftype uint32
    VT       uint16

TYPEDESC defines data type.

type UnknownLike Uses

type UnknownLike interface {
    QueryInterface(iid *GUID) (disp *IDispatch, err error)
    AddRef() int32
    Release() int32

type VARIANT Uses

type VARIANT struct {
    VT  VT  //  2

    Val int64 // 16
    // contains filtered or unexported fields

func NewVariant Uses

func NewVariant(vt VT, val int64) VARIANT

NewVariant returns new variant based on type and value.

func (*VARIANT) Clear Uses

func (v *VARIANT) Clear() error

Clear the memory of variant object.

func (*VARIANT) ToArray Uses

func (v *VARIANT) ToArray() *SafeArrayConversion

ToArray converts variant to SafeArray helper.

func (*VARIANT) ToIDispatch Uses

func (v *VARIANT) ToIDispatch() *IDispatch

ToIDispatch converts variant to dispatch object.

func (*VARIANT) ToIUnknown Uses

func (v *VARIANT) ToIUnknown() *IUnknown

ToIUnknown converts Variant to Unknown object.

func (*VARIANT) ToString Uses

func (v *VARIANT) ToString() string

ToString converts variant to Go string.

func (*VARIANT) Value Uses

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 Uses

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_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

func (VT) String Uses

func (i VT) String() string



Package ole imports 5 packages (graph) and is imported by 64 packages. Updated 2019-09-20. Refresh now. Tools for package owners.