本文整理汇总了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;
}
}
示例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;
}
}
}
示例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;
}
}
}
示例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;
}
}
示例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;
}
}
示例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);
}
}
示例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;
}
}
}