示例#1
0
文件: oleutil.go 项目: eswdd/bosun
// 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
文件: oleutil.go 项目: eswdd/bosun
// 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
}