public MsxhelpProtocol() //constructor { // initialize async pluggable protocol handler NativeMethods.CoInternetGetSession(0, out protocolHandlerSession, 0); protocolHandlerFactory = new HelpClassFactory(); Guid guid = new Guid("078600C7-A606-4d28-99EF-9378A08FCE97"); protocolHandlerSession.RegisterNameSpace(protocolHandlerFactory, ref guid, "ms-xhelp", 0, null, 0); //Now we will get pinged for content any time we navigate to ms-xhelp://... //webBrowser.Navigate("ms-xhelp:///?method=page&id=ba237712-f8c4-4d13-854b-ab4a16afa309&vendor=Microsoft&topicVersion=&topicLocale=EN-US"); }
public static void Register(string prefix, Func <EmbeddedProtocol> createProtocol, Guid guid) { IInternetSession session = null; CoInternetGetSession(0, ref session, 0); var hresult = session.RegisterNameSpace(new EmbeddedProtocolFactory(createProtocol), ref guid, prefix, 0, null, 0); if (hresult != 0) { throw new Win32Exception(hresult); } }
public static WebBrowserProtocolFactory Register(string protocolPrefix, Func <string, WebBrowserProtocolReaderContext, byte[]> reader, Guid?protocolId = null) { IInternetSession session = null; CoInternetGetSession(0, ref session, 0); //Console.WriteLine(session); var _protocolId = protocolId ?? Guid.NewGuid(); var factory = new WebBrowserProtocolFactory(protocolPrefix, reader, _protocolId); session.RegisterNameSpace(factory, ref _protocolId, protocolPrefix, 0, null, 0); return(factory); }
public static void Register(string name, Func <IProtocol> factory) { string emptyStr = null; IInternetSession session = GetSession(); try { Guid handlerGuid = typeof(Protocol).GUID; session.RegisterNameSpace( new ProtocolFactory(factory), ref handlerGuid, name, 0, ref emptyStr, 0); } finally { Marshal.ReleaseComObject(session); session = null; } }