当前位置: 首页>>代码示例>>C#>>正文


C# IMoniker.BindToStorage方法代码示例

本文整理汇总了C#中IMoniker.BindToStorage方法的典型用法代码示例。如果您正苦于以下问题:C# IMoniker.BindToStorage方法的具体用法?C# IMoniker.BindToStorage怎么用?C# IMoniker.BindToStorage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IMoniker的用法示例。


在下文中一共展示了IMoniker.BindToStorage方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: getName

		/// <summary> Retrieve the human-readable name of the filter </summary>
		protected string getName(IMoniker moniker)
		{
			object bagObj = null;
			IPropertyBag bag = null;
			try 
			{
				Guid bagId = typeof( IPropertyBag ).GUID;
				moniker.BindToStorage( null, null, ref bagId, out bagObj );
				bag = (IPropertyBag) bagObj;
				object val = "";
				int hr = bag.Read( "FriendlyName", ref val, IntPtr.Zero );
				//if( hr != 0 )
				//	Marshal.ThrowExceptionForHR( hr );
				string ret = val as string;
				if( (ret == null) || (ret.Length < 1) )
					throw new NotImplementedException( "Device FriendlyName" );
				return( ret );
			}
			catch( Exception )
			{
				return( "" );
			}
			finally
			{
				bag = null;
				if( bagObj != null )
					Marshal.ReleaseComObject( bagObj ); bagObj = null;
			}
		}
开发者ID:iManbot,项目名称:monoslam,代码行数:30,代码来源:Filter.cs

示例2: GetName

        // Get filter name represented by the moniker
        private string GetName(IMoniker moniker)
        {
            Object			bagObj = null;
            IPropertyBag	bag = null;

            try
            {
                Guid bagId = typeof(IPropertyBag).GUID;
                // get property bag of the moniker
                moniker.BindToStorage(null, null, ref bagId, out bagObj);
                bag = (IPropertyBag) bagObj;

                // read FriendlyName
                object val = "";
                int hr = bag.Read("FriendlyName", ref val, IntPtr.Zero);
                if (hr != 0)
                    Marshal.ThrowExceptionForHR(hr);

                // get it as string
                string ret = val as string;
                if ((ret == null) || (ret.Length < 1))
                    throw new ApplicationException();

                return ret;
            }
            catch (Exception)
            {
                return "";
            }
            finally
            {
                // release all COM objects
                bag = null;
                if (bagObj != null)
                {
                    Marshal.ReleaseComObject(bagObj);
                    bagObj = null;
                }
            }
        }
开发者ID:zhuangyy,项目名称:Motion,代码行数:41,代码来源:Filter.cs

示例3: GetName

        /// <summary>
        /// Gets the name of a specific moniker
        /// </summary>
        /// <param name="moniker">Moniker object to get the name of</param>
        /// <returns>Name of a specific moniker</returns>
        private static string GetName(IMoniker moniker)
        {
            // Declare variables
            Object bagObj = null;
            IPropertyBag bag = null;

            try
            {
                // Bind the moniker to storage
                Guid bagId = typeof(IPropertyBag).GUID;
                moniker.BindToStorage(null, null, ref bagId, out bagObj);
                bag = (IPropertyBag)bagObj;

                // Try to retrieve the friendly name
                object val = "";
                int hr = bag.Read("FriendlyName", ref val, IntPtr.Zero);
                if (hr != 0)
                {
                    Marshal.ThrowExceptionForHR(hr);
                }

                // Convert to string & validate
                string result = (string)val;
                if (string.IsNullOrEmpty(result))
                {
                    throw new ApplicationException();
                }

                // Return result
                return result;
            }
            catch (Exception)
            {
                // Return empty string
                return string.Empty;
            }
            finally
            {
                // Clean up
                bag = null;
                if (bagObj != null)
                {
                    Marshal.ReleaseComObject(bagObj);
                    bagObj = null;
                }
            }
        }
开发者ID:ravidasghodse,项目名称:genericva,代码行数:52,代码来源:FilterInfo.cs

示例4: getName

    /// <summary> Retrieve the human-readable name of the filter </summary>
    protected string getName(IMoniker moniker)
    {
      object bagObj = null;
      IPropertyBag bag = null;
      try
      {
        Guid bagId = typeof (IPropertyBag).GUID;
        moniker.BindToStorage(null, null, ref bagId, out bagObj);
        bag = (IPropertyBag)bagObj;
        object val = "";
        int hr = bag.Read("FriendlyName", out val, null);
        if (hr != 0)
        {
          Marshal.ThrowExceptionForHR(hr);
        }
        string ret = val as string;
        if ((ret == null) || (ret.Length < 1))
        {
          throw new NotImplementedException("Device FriendlyName");
        }

        hr = bag.Read("CLSID", out val, null);
        if (hr == 0)
        {
          CLSID = new Guid(val.ToString());
        }

        return (ret);
      }
      catch (Exception)
      {
        return ("");
      }
      finally
      {
        bag = null;
        if (bagObj != null)
        {
          DirectShowUtil.ReleaseComObject(bagObj);
        }
        bagObj = null;

        _nameResolved = true;
      }
    }
开发者ID:arangas,项目名称:MediaPortal-1,代码行数:46,代码来源:Filter.cs

示例5: GetFriendlyName

 public static string GetFriendlyName(IMoniker mon)
 {
   if (mon == null)
   {
     return string.Empty;
   }
   object bagObj = null;
   IPropertyBag bag = null;
   try
   {
     IErrorLog errorLog = null;
     Guid bagId = typeof (IPropertyBag).GUID;
     mon.BindToStorage(null, null, ref bagId, out bagObj);
     bag = (IPropertyBag)bagObj;
     object val = "";
     int hr = bag.Read("FriendlyName", out val, errorLog);
     if (hr != 0)
     {
       Marshal.ThrowExceptionForHR(hr);
     }
     string ret = val as string;
     if ((ret == null) || (ret.Length < 1))
     {
       throw new NotImplementedException("Device FriendlyName");
     }
     return ret;
   }
   catch (Exception)
   {
     return null;
   }
   finally
   {
     bag = null;
     if (bagObj != null)
     {
       ReleaseComObject(bagObj);
     }
     bagObj = null;
   }
 }
开发者ID:npcomplete111,项目名称:MediaPortal-1,代码行数:41,代码来源:DirectShowUtil.cs

示例6: DisplayDebugInformation

        private void DisplayDebugInformation(IMoniker moniker, Guid filterClsid)
        {
            IPropertyBag propertyBag = null;

              try
              {
            string registryPath = string.Format(@"HKEY_CLASSES_ROOT\CLSID\{0}\InprocServer32", filterClsid.ToString("B"));
            string filterLocation = (string)Registry.GetValue(registryPath, string.Empty, string.Empty);

            object o;
            Guid IID_IPropertyBag = typeof(IPropertyBag).GUID;

            moniker.BindToStorage(null, null, ref IID_IPropertyBag, out o);
            propertyBag = (IPropertyBag)o;

            int hr = propertyBag.Read("FriendlyName", out o, null);
            Marshal.ThrowExceptionForHR(hr);

            string friendlyName = o.ToString();

            Debug.WriteLine(string.Format("Localtion: {0}\r\nFriendly Name: {1}", filterLocation, friendlyName));
              }
              catch { }
              finally
              {
            if (propertyBag != null)
              Marshal.ReleaseComObject(propertyBag);
              }
        }
开发者ID:adambyram,项目名称:pimaker,代码行数:29,代码来源:BlackListManager.cs

示例7: GetName

        private string GetName(IMoniker moniker)
        {
            object bagObj = null;
            IPropertyBag bag = null;

            try
            {
                Guid bagId = typeof(IPropertyBag).GUID;
                moniker.BindToStorage(null, null, ref bagId, out bagObj);
                bag = (IPropertyBag)bagObj;

                object val = null;
                int hr = bag.Read("FriendlyName", ref val, IntPtr.Zero);
                if (hr != 0)
                    Marshal.ThrowExceptionForHR(hr);
                return (string)val;
            }
            finally
            {
                bag = null;
                if (bagObj != null)
                {
                    Marshal.ReleaseComObject(bagObj);
                    bagObj = null;
                }
            }
        }
开发者ID:JacindaChen,项目名称:TronCell,代码行数:27,代码来源:CaptureInterfaces.cs


注:本文中的IMoniker.BindToStorage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。