ole

package
v1.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 13, 2016 License: Apache-2.0 Imports: 5 Imported by: 0

README

#Go OLE

Build status Build Status GoDoc

Go bindings for Windows COM using shared libraries instead of cgo.

By Yasuhiro Matsumoto.

Install

To experiment with go-ole, you can just compile and run the example program:

go get github.com/go-ole/go-ole
cd /path/to/go-ole/
go test

cd /path/to/go-ole/example/excel
go run excel.go

Continuous Integration

Continuous integration configuration has been added for both Travis-CI and AppVeyor. You will have to add these to your own account for your fork in order for it to run.

Travis-CI

Travis-CI was added to check builds on Linux to ensure that go get works when cross building. Currently, Travis-CI is not used to test cross-building, but this may be changed in the future. It is also not currently possible to test the library on Linux, since COM API is specific to Windows and it is not currently possible to run a COM server on Linux or even connect to a remote COM server.

AppVeyor

AppVeyor is used to build on Windows using the (in-development) test COM server. It is currently only used to test the build and ensure that the code works on Windows. It will be used to register a COM server and then run the test cases based on the test COM server.

The tests currently do run and do pass and this should be maintained with commits.

##Versioning

Go OLE uses semantic versioning for version numbers, which is similar to the version contract of the Go language. Which means that the major version will always maintain backwards compatibility with minor versions. Minor versions will only add new additions and changes. Fixes will always be in patch.

This contract should allow you to upgrade to new minor and patch versions without breakage or modifications to your existing code. Leave a ticket, if there is breakage, so that it could be fixed.

##LICENSE

Under the MIT License: http://mattn.mit-license.org/2013

Documentation

Index

Constants

View Source
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
)
View Source
const (
	COINIT_APARTMENTTHREADED = 0x2
	COINIT_MULTITHREADED     = 0x0
	COINIT_DISABLE_OLE1DDE   = 0x4
	COINIT_SPEED_OVER_MEMORY = 0x8
)
View Source
const (
	DISPATCH_METHOD         = 1
	DISPATCH_PROPERTYGET    = 2
	DISPATCH_PROPERTYPUT    = 4
	DISPATCH_PROPERTYPUTREF = 8
)
View Source
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
)
View Source
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
)
View Source
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
)
View Source
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
)
View Source
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

View Source
var (
	// IID_NULL is null Interface ID, used when no other Interface ID is known.
	IID_NULL = &GUID{0x00000000, 0x0000, 0x0000, [8]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}

	// IID_IUnknown is for IUnknown interfaces.
	IID_IUnknown = &GUID{0x00000000, 0x0000, 0x0000, [8]byte{0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}}

	// IID_IDispatch is for IDispatch interfaces.
	IID_IDispatch = &GUID{0x00020400, 0x0000, 0x0000, [8]byte{0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}}

	// IID_IEnumVariant is for IEnumVariant interfaces
	IID_IEnumVariant = &GUID{0x00020404, 0x0000, 0x0000, [8]byte{0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}}

	// IID_IConnectionPointContainer is for IConnectionPointContainer interfaces.
	IID_IConnectionPointContainer = &GUID{0xB196B284, 0xBAB4, 0x101A, [8]byte{0xB6, 0x9C, 0x00, 0xAA, 0x00, 0x34, 0x1D, 0x07}}

	// IID_IConnectionPoint is for IConnectionPoint interfaces.
	IID_IConnectionPoint = &GUID{0xB196B286, 0xBAB4, 0x101A, [8]byte{0xB6, 0x9C, 0x00, 0xAA, 0x00, 0x34, 0x1D, 0x07}}

	// IID_IInspectable is for IInspectable interfaces.
	IID_IInspectable = &GUID{0xaf86e2e0, 0xb12d, 0x4c6a, [8]byte{0x9c, 0x5a, 0xd7, 0xaa, 0x65, 0x10, 0x1e, 0x90}}

	// IID_IProvideClassInfo is for IProvideClassInfo interfaces.
	IID_IProvideClassInfo = &GUID{0xb196b283, 0xbab4, 0x101a, [8]byte{0xB6, 0x9C, 0x00, 0xAA, 0x00, 0x34, 0x1D, 0x07}}
)
View Source
var (
	// IID_ICOMTestString is for ICOMTestString interfaces.
	//
	// {E0133EB4-C36F-469A-9D3D-C66B84BE19ED}
	IID_ICOMTestString = &GUID{0xe0133eb4, 0xc36f, 0x469a, [8]byte{0x9d, 0x3d, 0xc6, 0x6b, 0x84, 0xbe, 0x19, 0xed}}

	// IID_ICOMTestInt8 is for ICOMTestInt8 interfaces.
	//
	// {BEB06610-EB84-4155-AF58-E2BFF53608B4}
	IID_ICOMTestInt8 = &GUID{0xbeb06610, 0xeb84, 0x4155, [8]byte{0xaf, 0x58, 0xe2, 0xbf, 0xf5, 0x36, 0x80, 0xb4}}

	// IID_ICOMTestInt16 is for ICOMTestInt16 interfaces.
	//
	// {DAA3F9FA-761E-4976-A860-8364CE55F6FC}
	IID_ICOMTestInt16 = &GUID{0xdaa3f9fa, 0x761e, 0x4976, [8]byte{0xa8, 0x60, 0x83, 0x64, 0xce, 0x55, 0xf6, 0xfc}}

	// IID_ICOMTestInt32 is for ICOMTestInt32 interfaces.
	//
	// {E3DEDEE7-38A2-4540-91D1-2EEF1D8891B0}
	IID_ICOMTestInt32 = &GUID{0xe3dedee7, 0x38a2, 0x4540, [8]byte{0x91, 0xd1, 0x2e, 0xef, 0x1d, 0x88, 0x91, 0xb0}}

	// IID_ICOMTestInt64 is for ICOMTestInt64 interfaces.
	//
	// {8D437CBC-B3ED-485C-BC32-C336432A1623}
	IID_ICOMTestInt64 = &GUID{0x8d437cbc, 0xb3ed, 0x485c, [8]byte{0xbc, 0x32, 0xc3, 0x36, 0x43, 0x2a, 0x16, 0x23}}

	// IID_ICOMTestFloat is for ICOMTestFloat interfaces.
	//
	// {BF1ED004-EA02-456A-AA55-2AC8AC6B054C}
	IID_ICOMTestFloat = &GUID{0xbf1ed004, 0xea02, 0x456a, [8]byte{0xaa, 0x55, 0x2a, 0xc8, 0xac, 0x6b, 0x5, 0x4c}}

	// IID_ICOMTestDouble is for ICOMTestDouble interfaces.
	//
	// {BF908A81-8687-4E93-999F-D86FAB284BA0}
	IID_ICOMTestDouble = &GUID{0xbf908a81, 0x8687, 0x4e93, [8]byte{0x99, 0x9f, 0xd8, 0x6f, 0xab, 0x28, 0x4b, 0xa0}}

	// IID_ICOMTestBoolean is for ICOMTestBoolean interfaces.
	//
	// {D530E7A6-4EE8-40D1-8931-3D63B8605001}
	IID_ICOMTestBoolean = &GUID{0xd530e7a6, 0x4ee8, 0x40d1, [8]byte{0x89, 0x31, 0x3d, 0x63, 0xb8, 0x60, 0x50, 0x10}}

	// IID_ICOMEchoTestObject is for ICOMEchoTestObject interfaces.
	//
	// {6485B1EF-D780-4834-A4FE-1EBB51746CA3}
	IID_ICOMEchoTestObject = &GUID{0x6485b1ef, 0xd780, 0x4834, [8]byte{0xa4, 0xfe, 0x1e, 0xbb, 0x51, 0x74, 0x6c, 0xa3}}

	// IID_ICOMTestTypes is for ICOMTestTypes interfaces.
	//
	// {CCA8D7AE-91C0-4277-A8B3-FF4EDF28D3C0}
	IID_ICOMTestTypes = &GUID{0xcca8d7ae, 0x91c0, 0x4277, [8]byte{0xa8, 0xb3, 0xff, 0x4e, 0xdf, 0x28, 0xd3, 0xc0}}

	// CLSID_COMEchoTestObject is for COMEchoTestObject class.
	//
	// {3C24506A-AE9E-4D50-9157-EF317281F1B0}
	CLSID_COMEchoTestObject = &GUID{0x3c24506a, 0xae9e, 0x4d50, [8]byte{0x91, 0x57, 0xef, 0x31, 0x72, 0x81, 0xf1, 0xb0}}

	// CLSID_COMTestScalarClass is for COMTestScalarClass class.
	//
	// {865B85C5-0334-4AC6-9EF6-AACEC8FC5E86}
	CLSID_COMTestScalarClass = &GUID{0x865b85c5, 0x0334, 0x4ac6, [8]byte{0x9e, 0xf6, 0xaa, 0xce, 0xc8, 0xfc, 0x5e, 0x86}}
)

These are for testing and not part of any library.

Functions

func BstrToString

func BstrToString(p *uint16) string

BstrToString converts COM binary string to Go string.

func BytePtrToString

func BytePtrToString(p *byte) string

BytePtrToString converts byte pointer to a Go string.

func CoInitialize

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

func CoInitializeEx(p uintptr, coinit uint32) error

CoInitializeEx initializes COM library with concurrency model.

func CoTaskMemFree

func CoTaskMemFree(memptr uintptr)

CoTaskMemFree frees memory pointer.

func CoUninitialize

func CoUninitialize()

CoUninitialize uninitializes COM Library.

func DeleteHString

func DeleteHString(hstring HString) (err error)

DeleteHString deletes HString.

func DispatchMessage

func DispatchMessage(msg *Msg) int32

DispatchMessage to window procedure.

func GetMessage

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

func GetUserDefaultLCID() uint32

GetUserDefaultLCID retrieves current user default locale.

func GetVariantDate

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

func IsEqualGUID

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

IsEqualGUID compares two GUID.

Not constant time comparison.

func LpOleStrToString

func LpOleStrToString(p *uint16) string

LpOleStrToString converts COM Unicode to Go string.

func RoInitialize

func RoInitialize(thread_type uint32) (err error)

RoInitialize

func StringFromCLSID

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

StringFromCLSID returns GUID formated string from GUID object.

func StringFromIID

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

StringFromIID returns GUID formatted string from GUID object.

func SysAllocString

func SysAllocString(v string) *int16

SysAllocString allocates memory for string and copies string into memory.

func SysAllocStringLen

func SysAllocStringLen(v string) *int16

SysAllocStringLen copies up to length of given string returning pointer.

func SysFreeString

func SysFreeString(v *int16) error

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

func SysStringLen

func SysStringLen(v *int16) uint32

SysStringLen is the length of the system allocated string.

func UTF16PtrToString

func UTF16PtrToString(p *uint16) string

UTF16PtrToString is alias for LpOleStrToString.

Kept for compatibility reasons.

func VariantClear

func VariantClear(v *VARIANT) error

VariantClear clears value in Variant settings to VT_EMPTY.

func VariantInit

func VariantInit(v *VARIANT) error

VariantInit initializes variant.

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) Initialize

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

Initialize COM.

func (*Connection) Load

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

Load COM object from list of programIDs or strings.

func (*Connection) Release

func (c *Connection) Release()

Release IUnknown object.

func (*Connection) Uninitialize

func (*Connection) Uninitialize()

Uninitialize COM.

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) Call

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

Call method on IDispatch with parameters.

func (*Dispatch) Get

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

Get property on IDispatch with parameters.

func (*Dispatch) GetId

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

GetId retrieves ID of name on IDispatch.

func (*Dispatch) GetIds

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

GetIds retrieves all IDs of names on IDispatch.

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.

func (*Dispatch) MustCall

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

MustCall method on IDispatch with parameters.

func (*Dispatch) MustGet

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

MustGet property on IDispatch with parameters.

func (*Dispatch) MustSet

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

MustSet property on IDispatch with parameters.

func (*Dispatch) Release

func (d *Dispatch) Release()

Release IDispatch object.

func (*Dispatch) Set

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

Set property on IDispatch with parameters.

type EXCEPINFO

type EXCEPINFO struct {
	// contains filtered or unexported fields
}

EXCEPINFO defines exception info.

func (EXCEPINFO) Error

func (e EXCEPINFO) Error() string

Error implements error interface and returns error string.

func (EXCEPINFO) String

func (e EXCEPINFO) String() string

String convert EXCEPINFO to string.

type GUID

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

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

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

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

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

IIDFromString returns GUID from program ID.

type HString

type HString uintptr

HString is handle string for pointers.

func NewHString

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

NewHString returns a new HString for Go string.

func (HString) String

func (h HString) String() string

String returns Go string value of HString.

type IConnectionPoint

type IConnectionPoint struct {
	IUnknown
}

func (*IConnectionPoint) Advise

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

func (*IConnectionPoint) EnumConnections

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

func (*IConnectionPoint) GetConnectionInterface

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

func (*IConnectionPoint) Unadvise

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

func (*IConnectionPoint) VTable

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) error

func (*IConnectionPointContainer) VTable

type IConnectionPointContainerVtbl

type IConnectionPointContainerVtbl struct {
	IUnknownVtbl
	EnumConnectionPoints uintptr
	FindConnectionPoint  uintptr
}

type IConnectionPointVtbl

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

type IDLDESC

type IDLDESC struct {
	DwReserved uint32
	WIDLFlags  uint16
}

IDLDESC defines IDL info.

type IDispatch

type IDispatch struct {
	IUnknown
}

func CreateStdDispatch

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

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

CallMethod invokes named function with arguments on object.

func (*IDispatch) GetIDsOfName

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

func (*IDispatch) GetProperty

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

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

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

func (*IDispatch) GetTypeInfoCount

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

func (*IDispatch) Invoke

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

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

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

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() (*IEnumVARIANT, error)

func (*IEnumVARIANT) Next

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

func (*IEnumVARIANT) Reset

func (enum *IEnumVARIANT) Reset() error

func (*IEnumVARIANT) Skip

func (enum *IEnumVARIANT) Skip(celt uint) 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)

RoActivateInstance

func RoGetActivationFactory

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

RoGetActivationFactory

func (*IInspectable) GetIids

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

func (*IInspectable) GetRuntimeClassName

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

func (*IInspectable) GetTrustLevel

func (v *IInspectable) GetTrustLevel() (uint32, 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

type IProvideClassInfoVtbl

type IProvideClassInfoVtbl struct {
	IUnknownVtbl
	GetClassInfo uintptr
}

type ITypeInfo

type ITypeInfo struct {
	IUnknown
}

func (*ITypeInfo) GetTypeAttr

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

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) (*IUnknown, error)

CreateDispTypeInfo provides default ITypeInfo implementation for IDispatch.

This will not handle the full implementation of the interface.

func CreateInstance

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

CreateInstance of single uninitialized object with GUID.

func GetActiveObject

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

GetActiveObject retrieves pointer to active object.

func (*IUnknown) AddRef

func (v *IUnknown) AddRef() int32

func (*IUnknown) IDispatch

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

func (*IUnknown) IEnumVARIANT

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

func (*IUnknown) MustQueryInterface

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

func (*IUnknown) PutQueryInterface

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

func (*IUnknown) QueryInterface

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

func (*IUnknown) Release

func (v *IUnknown) Release() int32

func (*IUnknown) VTable

func (v *IUnknown) VTable() *IUnknownVtbl

type IUnknownVtbl

type IUnknownVtbl struct {
	QueryInterface uintptr
	AddRef         uintptr
	Release        uintptr
}

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 Msg

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

Msg is message between processes.

type OleError

type OleError struct {
	// contains filtered or unexported fields
}

OleError stores COM errors.

func NewError

func NewError(hr uintptr) *OleError

NewError creates new error with HResult.

func NewErrorWithDescription

func NewErrorWithDescription(hr uintptr, description string) *OleError

NewErrorWithDescription creates new COM error with HResult and description.

func NewErrorWithSubError

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

NewErrorWithSubError creates new COM error with parent error.

func (*OleError) Code

func (v *OleError) Code() uintptr

Code is the HResult.

func (*OleError) Description

func (v *OleError) Description() string

Description retrieves error summary, if there is one.

func (*OleError) Error

func (v *OleError) Error() string

Error implements error interface.

func (*OleError) String

func (v *OleError) String() string

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

func (*OleError) SubError

func (v *OleError) SubError() error

SubError returns parent error, if there is one.

type PARAMDATA

type PARAMDATA struct {
	Name *int16
	Vt   uint16
}

PARAMDATA defines parameter data type.

type Point

type Point struct {
	X int32
	Y int32
}

Point is 2D vector type.

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

type SafeArrayBound struct {
	Elements   uint32
	LowerBound int32
}

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 int64, 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 TYPEDESC

type TYPEDESC struct {
	Hreftype uint32
	VT       uint16
}

TYPEDESC defines data type.

type UnknownLike

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

type VARIANT

type VARIANT struct {
	VT VT //  2

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

func NewVariant

func NewVariant(vt VT, val int64) VARIANT

NewVariant returns new variant based on type and value.

func (*VARIANT) Clear

func (v *VARIANT) Clear() error

Clear the memory of variant object.

func (*VARIANT) ToArray

func (v *VARIANT) ToArray() *SafeArrayConversion

ToArray converts variant to SafeArray helper.

func (*VARIANT) ToIDispatch

func (v *VARIANT) ToIDispatch() *IDispatch

ToIDispatch converts variant to dispatch object.

func (*VARIANT) ToIUnknown

func (v *VARIANT) ToIUnknown() *IUnknown

ToIUnknown converts Variant to Unknown object.

func (*VARIANT) ToString

func (v *VARIANT) ToString() string

ToString converts variant to Go string.

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
)

func (VT) String

func (i VT) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL