private static IInternetSession GetInternetSession() { IInternetSession internetSession = null; var hr = CoInternetGetSession(0, ref internetSession, 0); if (hr != 0) { Marshal.ThrowExceptionForHR(hr); } return(internetSession); }
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; } }
internal static extern int CoInternetGetSession(int dwSessionMode, out IInternetSession session, int dwReserved);
static extern void CoInternetGetSession(UInt32 dwSessionMode /* = 0 */, ref IInternetSession ppIInternetSession, UInt32 dwReserved /* = 0 */);
internal static extern int CoInternetGetSession( int dwSessionMode, out IInternetSession ppIInternetSession, int dwReserved);
public static extern int CoInternetGetSession(UInt32 dwSessionMode, ref IInternetSession ppIInternetSession, UInt32 dwReserved);
internal static extern void CoInternetGetSession( IntPtr dwSessionMode, out IInternetSession ppIInternetSession, IntPtr dwReserved );
private static extern void CoInternetGetSession(uint dwSession, ref IInternetSession ifSession, uint dwReserved);
public static extern void CoInternetGetSession(uint dwSessionMode, out IInternetSession ppIInternetSession, uint dwReserved);