예제 #1
0
        public int TryInvokePropertyGet(string propertyName, out object value)
        {
            int       hr       = NativeMethods.S_OK;
            IDispatch dispatch = null;

            value = null;

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

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

            return(hr);
        }
예제 #2
0
        public static int InvokePropertyGet(this IDispatch dispatch, string name, out object value)
        {
            int hr = NativeMethods.S_OK;

            value = null;
            int dispid = 0;

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

            return(hr);
        }
예제 #3
0
        public int TryGetItemCount()
        {
            IDispatch dispatch = null;
            object    count    = 0;

            try
            {
                dispatch = TryGetUniqueRCW <IDispatch>();
                if (MarshalEx.Succeeded(dispatch.InvokePropertyGet("Count", out count)))
                {
                    return(count is int?(int)count : -1);
                }
            }
            catch
            {
            }
            finally
            {
                CleanupUniqueRCW(dispatch);
            }

            return(-1);
        }