Esempio n. 1
0
        public Filter(IBaseFilter ibf)
        {
            basefilter = ibf;
            Guid clsid;

            ibf.GetClassID(out clsid);
            FilterInfo fi;

            ibf.QueryFilterInfo(out fi);
            string strGuid    = Graph.GuidToString(clsid);
            string strCatguid = Graph.GuidToString(FilterCategory.LegacyAmFilterCategory);

            filterProps = new FilterProps(fi.achName, "", strGuid, strCatguid);
            filterProps.MakeFileName();
            filterProps.SetFilter(this);
        }
Esempio n. 2
0
        static Dictionary <string, string> dispnames = new Dictionary <string, string>(); //orgname => display name

        public Filter(FilterProps fp)
        {
            filterProps = fp;

            IBindCtx bindCtx = null;
            IMoniker moniker = null;

            basefilter = null;
            try
            {
                int hr = NativeMethods.CreateBindCtx(0, out bindCtx);
                Marshal.ThrowExceptionForHR(hr);
                int eaten;
                hr = NativeMethods.MkParseDisplayName(bindCtx, fp.DisplayName, out eaten, out moniker);
                Marshal.ThrowExceptionForHR(hr);
                Guid   guid = typeof(IBaseFilter).GUID;
                object obj;
                moniker.BindToObject(bindCtx, null, ref guid, out obj);
                basefilter = obj as IBaseFilter;
            }
            finally
            {
                if (bindCtx != null)
                {
                    Marshal.ReleaseComObject(bindCtx);
                }
                if (moniker != null)
                {
                    Marshal.ReleaseComObject(moniker);
                }
            }

            if (basefilter == null)
            {
                throw new Exception("Can't create filter");
            }

            fp.SetFilter(this);
        }