コード例 #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);
        }
コード例 #2
0
        public System.Runtime.InteropServices.ComTypes.ITypeInfo TryGetTypeInfo()
        {
            System.Runtime.InteropServices.ComTypes.ITypeInfo typeInfo = null;

            IDispatch dispatch = null;

            try
            {
                dispatch = TryGetUniqueRCW <IDispatch>();

                if (dispatch != null)
                {
                    typeInfo = dispatch.GetTypeInfo();
                }
            }
            catch
            {
            }
            finally
            {
                ComPtr.CleanupUniqueRCW(dispatch);
            }

            return(typeInfo);
        }
コード例 #3
0
        public int TryInvokeMethod(string name, object[] args, out object returnValue)
        {
            int       hr       = NativeMethods.S_OK;
            IDispatch dispatch = null;

            returnValue = null;

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

                    if (dispatch != null)
                    {
                        if (MarshalEx.Succeeded(hr = dispatch.InvokeMethod(name, args, out returnValue)))
                        {
                        }
                    }
                }
            }
            catch
            {
            }
            finally
            {
                ComPtr.CleanupUniqueRCW(dispatch);
            }

            return(hr);
        }
コード例 #4
0
        public ComTypeInfo TryGetComTypeInfo()
        {
            ComTypeInfo comTypeInfo = null;
            IDispatch   dispatch    = null;

            try
            {
                dispatch = TryGetUniqueRCW <IDispatch>();

                if (dispatch != null)
                {
                    comTypeInfo = ComTypeManager.Instance.FromIDispatch(dispatch);
                }
            }
            catch
            {
            }
            finally
            {
                ComPtr.CleanupUniqueRCW(dispatch);
            }


            return(comTypeInfo);
        }