Beispiel #1
0
        public int TryInvokePropertySet(string propertyName, object value)
        {
            int       hr       = NativeMethods.S_OK;
            IDispatch dispatch = null;

            try
            {
                if (IsDispatch)
                {
                    dispatch = TryGetUniqueRCW <IDispatch>();

                    if (dispatch != null)
                    {
                        if (MarshalEx.Succeeded(hr = dispatch.InvokePropertySet(propertyName, value)))
                        {
                        }
                    }
                }
            }
            catch
            {
            }
            finally
            {
                ComPtr.CleanupUniqueRCW(dispatch);
            }

            return(hr);
        }
Beispiel #2
0
        public static int InvokePropertySet(this IDispatch dispatch, string name, object value)
        {
            int hr     = NativeMethods.S_OK;
            int dispid = 0;

            if (MarshalEx.Succeeded(dispatch.GetIdOfName(name, out dispid)))
            {
                hr = dispatch.InvokePropertySet(dispid, value);
            }

            return(hr);
        }