Example #1
0
        private static IInternetSession GetInternetSession()
        {
            IInternetSession internetSession = null;
            var hr = CoInternetGetSession(0, ref internetSession, 0);

            if (hr != 0)
            {
                Marshal.ThrowExceptionForHR(hr);
            }
            return(internetSession);
        }
Example #2
0
        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);
            }
        }
Example #3
0
        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;
            }
        }
Example #5
0
 internal static extern int CoInternetGetSession(int dwSessionMode, out IInternetSession session, int dwReserved);
Example #6
0
 static extern void CoInternetGetSession(UInt32 dwSessionMode /* = 0 */, ref IInternetSession ppIInternetSession, UInt32 dwReserved /* = 0 */);
Example #7
0
 internal static extern int CoInternetGetSession(
     int dwSessionMode,
     out IInternetSession ppIInternetSession,
     int dwReserved);
 static extern void CoInternetGetSession(UInt32 dwSessionMode /* = 0 */, ref IInternetSession ppIInternetSession, UInt32 dwReserved /* = 0 */);
 public static extern int CoInternetGetSession(UInt32 dwSessionMode, ref IInternetSession ppIInternetSession, UInt32 dwReserved);
Example #10
0
 internal static extern void CoInternetGetSession(
     IntPtr dwSessionMode,
     out IInternetSession ppIInternetSession,
     IntPtr dwReserved );
Example #11
0
 private static extern void CoInternetGetSession(uint dwSession, ref IInternetSession ifSession, uint dwReserved);
Example #12
0
 public static extern void CoInternetGetSession(uint dwSessionMode, out IInternetSession ppIInternetSession, uint dwReserved);
Example #13
0
 public static extern void CoInternetGetSession(uint dwSessionMode, out IInternetSession ppIInternetSession, uint dwReserved);