Example #1
0
// GetUpperBound returns upper bounds of SafeArray.
//
// SafeArrays may have multiple dimensions. Meaning, it could be
// multidimensional array.
//
// AKA: SafeArrayGetUBound in Windows API.
func GetUpperBound(safearray *COMArray, dimension uint32) (upperBound int64, err error) {
	err = com.HResultToError(procSafeArrayGetUBound.Call(
		uintptr(unsafe.Pointer(safearray)),
		uintptr(dimension),
		uintptr(unsafe.Pointer(&upperBound))))
	return
}
Example #2
0
// PutElement stores the data element at the specified location in the
// array.
//
// AKA: SafeArrayPutElement in Windows API.
func PutElement(safearray *COMArray, index int64, element interface{}) (err error) {
	err = com.HResultToError(procSafeArrayPutElement.Call(
		uintptr(unsafe.Pointer(safearray)),
		uintptr(index),
		uintptr(unsafe.Pointer(&element))))
	return
}
Example #3
0
// AllocateArrayDescriptorEx allocates SafeArray.
//
// AKA: SafeArrayAllocDescriptorEx in Windows API.
func AllocateArrayDescriptorEx(variantType com.VariantType, dimensions uint32) (safearray *COMArray, err error) {
	err = com.HResultToError(procSafeArrayAllocDescriptorEx.Call(
		uintptr(variantType),
		uintptr(dimensions),
		uintptr(unsafe.Pointer(&safearray))))
	return
}
Example #4
0
// GetPointerOfIndex gets a pointer to an array element.
//
// This must be locked before use.
//
// AKA: SafeArrayPtrOfIndex in Windows API.
func GetPointerOfIndex(safearray *COMArray, index int64) (ref uintptr, err error) {
	err = com.HResultToError(procSafeArrayPtrOfIndex.Call(
		uintptr(unsafe.Pointer(safearray)),
		uintptr(index),
		uintptr(unsafe.Pointer(&ref))))
	return
}
Example #5
0
func GetIDsOfName(obj interface{}, method uintptr, names []string) (displayIDs []int32, err error) {
	wnames := make([]*uint16, len(names))
	for i := 0; i < len(names); i++ {
		ptr, err := syscall.UTF16PtrFromString(names[i])
		if err != nil {
			return
		}
		wnames[i] = ptr
	}

	displayIDs = make([]int32, len(names))
	dispIDs := make([]int32, len(names))
	namelen := uint32(len(names))

	err = com.HResultToError(syscall.Syscall6(
		method,
		uintptr(6),
		uintptr(unsafe.Pointer(obj)),
		uintptr(unsafe.Pointer(com.NullInterfaceID)),
		uintptr(unsafe.Pointer(&wnames[0])),
		uintptr(namelen),
		uintptr(com.GetDefaultUserLocaleID()),
		uintptr(unsafe.Pointer(&dispIDs[0]))))

	displayIDs = dispIDs[0:namelen]

	return
}
Example #6
0
// GetVariantType returns data type of SafeArray.
//
// AKA: SafeArrayGetVartype in Windows API.
func GetVariantType(safearray *COMArray) (varType com.VariantType, err error) {
	var vt uint16
	err = com.HResultToError(procSafeArrayGetVartype.Call(
		uintptr(unsafe.Pointer(safearray)),
		uintptr(unsafe.Pointer(&vt))))
	varType = com.VariantType(vt)
	return
}
Example #7
0
func Unadvise(obj interface{}, method uintptr, cookie uint32) error {
	return com.HResultToError(syscall.Syscall(
		method,
		uintptr(2),
		uintptr(unsafe.Pointer(obj)),
		uintptr(cookie),
		uintptr(0)))
}
Example #8
0
func FindConnectionPoint(obj interface{}, method uintptr, interfaceID *com.GUID) (element *iconnectionpoint.ConnectionPoint, err error) {
	err = com.HResultToError(syscall.Syscall(
		method,
		uintptr(3),
		uintptr(unsafe.Pointer(obj)),
		uintptr(unsafe.Pointer(interfaceID)),
		uintptr(unsafe.Pointer(&element))))
	return
}
Example #9
0
// EnumConnections creates an enumerator object to iterate through current
// connections.
//
// XXX: Need IEnumConnections structure
func EnumConnections(obj interface{}, method uintptr) (element *interface{}, err error) {
	err = com.HResultToError(syscall.Syscall(
		method,
		uintptr(2),
		uintptr(unsafe.Pointer(obj)),
		uintptr(unsafe.Pointer(&element)),
		uintptr(0)))
	return 0
}
Example #10
0
func GetConnectionInterface(obj interface{}, method uintptr) (interfaceID *com.GUID, err error) {
	err = com.HResultToError(syscall.Syscall(
		method,
		uintptr(2),
		uintptr(unsafe.Pointer(obj)),
		uintptr(unsafe.Pointer(&interfaceID)),
		uintptr(0)))
	return
}
Example #11
0
func GetConnectionPointContainer(obj interface{}, method uintptr) (element *iconnectionpointcontainer.ConnectionPointContainer, err error) {
	err = com.HResultToError(syscall.Syscall(
		method,
		uintptr(2),
		uintptr(unsafe.Pointer(obj)),
		uintptr(unsafe.Pointer(&element)),
		uintptr(0)))
	return 0
}
Example #12
0
func Advise(obj interface{}, method uintptr, unknown *iunknown.IUnknown) (cookie uint32, err error) {
	err = com.HResultToError(syscall.Syscall(
		method,
		uintptr(3),
		uintptr(unsafe.Pointer(obj)),
		uintptr(unsafe.Pointer(unknown)),
		uintptr(unsafe.Pointer(&cookie))))
	return
}
Example #13
0
func GetTypeInfoCount(obj interface{}, method uintptr) (c uint32, err error) {
	err = com.HResultToError(syscall.Syscall(
		method,
		uintptr(2),
		uintptr(unsafe.Pointer(obj)),
		uintptr(unsafe.Pointer(&c)),
		uintptr(0)))
	return
}
Example #14
0
// EnumConnectionPoints creates an enumerator object to iterate through
// connection points.
//
// XXX: Need to implement IEnumConnectionPoints structure.
func EnumConnectionPoints(obj interface{}, method uintptr) (element interface{}, err error) {
	err = com.HResultToError(syscall.Syscall(
		method,
		uintptr(2),
		uintptr(unsafe.Pointer(obj)),
		reflect.ValueOf(element).UnsafeAddr(),
		uintptr(0)))
	return
}
Example #15
0
func GetTypeInfo(obj interface{}, method uintptr, num uint32) (tinfo *itypeinfo.TypeInfo, err error) {
	err = com.HResultToError(syscall.Syscall6(
		method,
		uintptr(4),
		uintptr(unsafe.Pointer(obj)),
		uintptr(num),
		uintptr(com.GetDefaultUserLocaleID()),
		uintptr(unsafe.Pointer(&tinfo)),
		uintptr(0),
		uintptr(0)))
	return
}
Example #16
0
// DuplicateData duplicates SafeArray into another SafeArray object.
//
// AKA: SafeArrayCopyData in Windows API.
func DuplicateData(original, duplicate *COMArray) (err error) {
	err = com.HResultToError(procSafeArrayCopyData.Call(
		uintptr(unsafe.Pointer(original)),
		uintptr(unsafe.Pointer(&duplicate))))
	return
}
Example #17
0
// SetInterfaceID sets the GUID of the interface for the specified safe
// array.
//
// AKA: SafeArraySetIID in Windows API.
func SetInterfaceID(safearray *COMArray, interfaceID *com.GUID) (err error) {
	err = com.HResultToError(procSafeArraySetIID.Call(
		uintptr(unsafe.Pointer(safearray)),
		uintptr(unsafe.Pointer(interfaceID))))
	return
}
Example #18
0
// DestroyDescriptor destroys SafeArray object.
//
// AKA: SafeArrayDestroyDescriptor in Windows API.
func DestroyDescriptor(safearray *COMArray) error {
	return com.HResultToError(procSafeArrayDestroyDescriptor.Call(uintptr(unsafe.Pointer(safearray))))
}
Example #19
0
// AllocateArrayData allocates SafeArray.
//
// AKA: SafeArrayAllocData in Windows API.
func AllocateArrayData(safearray *COMArray) (err error) {
	err = com.HResultToError(procSafeArrayAllocData.Call(uintptr(unsafe.Pointer(safearray))))
	return
}
Example #20
0
// UnaccessData releases raw array.
//
// AKA: SafeArrayUnaccessData in Windows API.
func UnaccessData(safearray *COMArray) (err error) {
	err = com.HResultToError(procSafeArrayUnaccessData.Call(uintptr(unsafe.Pointer(safearray))))
	return
}
Example #21
0
// SetRecordInfo mutates IRecordInfo info for custom types.
//
// AKA: SafeArraySetRecordInfo in Windows API.
//
// XXX: Must implement IRecordInfo interface for this to return.
func SetRecordInfo(safearray *COMArray, recordInfo interface{}) (err error) {
	err = com.HResultToError(procSafeArraySetRecordInfo.Call(
		uintptr(unsafe.Pointer(safearray)),
		uintptr(unsafe.Pointer(recordInfo))))
	return
}
Example #22
0
// GetInterfaceID is the InterfaceID of the elements in the SafeArray.
//
// AKA: SafeArrayGetIID in Windows API.
func GetInterfaceID(safearray *COMArray) (guid *com.GUID, err error) {
	err = com.HResultToError(procSafeArrayGetIID.Call(
		uintptr(unsafe.Pointer(safearray)),
		uintptr(unsafe.Pointer(&guid))))
	return
}
Example #23
0
// ResetDimensions changes the right-most (least significant) bound of the
// specified safe array.
//
// AKA: SafeArrayRedim in Windows API.
func ResetDimensions(safearray *COMArray, bounds *Bounds) error {
	err = com.HResultToError(procSafeArrayRedim.Call(
		uintptr(unsafe.Pointer(safearray)),
		uintptr(unsafe.Pointer(bounds))))
	return
}
Example #24
0
// Duplicate returns copy of SafeArray.
//
// AKA: SafeArrayCopy in Windows API.
func Duplicate(original *COMArray) (safearray *COMArray, err error) {
	err = com.HResultToError(procSafeArrayCopy.Call(
		uintptr(unsafe.Pointer(original)),
		uintptr(unsafe.Pointer(&safearray))))
	return
}
Example #25
0
// AccessData returns raw array.
//
// AKA: SafeArrayAccessData in Windows API.
func AccessData(safearray *COMArray) (element uintptr, err error) {
	err = com.HResultToError(procSafeArrayAccessData.Call(
		uintptr(unsafe.Pointer(safearray)),
		uintptr(unsafe.Pointer(&element))))
	return
}
Example #26
0
// Lock locks SafeArray for reading to modify SafeArray.
//
// This must be called during some calls to ensure that another process does not
// read or write to the SafeArray during editing.
//
// AKA: SafeArrayLock in Windows API.
func Lock(safearray *COMArray) (err error) {
	err = com.HResultToError(procSafeArrayLock.Call(uintptr(unsafe.Pointer(safearray))))
	return
}