private IMoniker ParseMoniker(IBindCtx bind_context, string moniker_string) { if (moniker_string == "new") { Guid IID_IUnknown = COMInterfaceEntry.IID_IUnknown; IntPtr unk; int hr = COMUtilities.CoCreateInstance(ref CLSID_NewMoniker, IntPtr.Zero, CLSCTX.INPROC_SERVER, ref IID_IUnknown, out unk); if (hr != 0) { Marshal.ThrowExceptionForHR(hr); } try { return((IMoniker)Marshal.GetObjectForIUnknown(unk)); } finally { Marshal.Release(unk); } } else { if (moniker_string.StartsWith("file:", StringComparison.OrdinalIgnoreCase) || moniker_string.StartsWith("http:", StringComparison.OrdinalIgnoreCase) || moniker_string.StartsWith("https:", StringComparison.OrdinalIgnoreCase)) { IMoniker moniker; int hr = COMUtilities.CreateURLMonikerEx(null, moniker_string, out moniker, CreateUrlMonikerFlags.Uniform); if (hr != 0) { Marshal.ThrowExceptionForHR(hr); } return(moniker); } int eaten = 0; return(COMUtilities.MkParseDisplayName(bind_context, moniker_string, out eaten)); } }