示例#1
0
// GetProperty retrieves property from IDispatch.
func GetProperty(disp *ole.IDispatch, name string, params ...interface{}) (result *ole.VARIANT, err error) {
	var dispid []int32
	dispid, err = disp.GetIDsOfName([]string{name})
	if err != nil {
		return
	}

	if len(params) < 1 {
		result, err = disp.Invoke(dispid[0], ole.DISPATCH_PROPERTYGET)
	} else {
		result, err = disp.Invoke(dispid[0], ole.DISPATCH_PROPERTYGET, params...)
	}

	return
}
示例#2
0
// CallMethod calls method on IDispatch with parameters.
func CallMethod(disp *ole.IDispatch, name string, params ...interface{}) (result *ole.VARIANT, err error) {
	var dispid []int32
	dispid, err = disp.GetIDsOfName([]string{name})
	if err != nil {
		return
	}

	if len(params) < 1 {
		result, err = disp.Invoke(dispid[0], ole.DISPATCH_METHOD)
	} else {
		result, err = disp.Invoke(dispid[0], ole.DISPATCH_METHOD, params...)
	}

	return
}