zoukankan      html  css  js  c++  java
  • WebBrowser获取完整COOKIE

            [DllImport("wininet.dll", CharSet = CharSet.Auto, SetLastError = true)]
            static extern bool InternetGetCookieEx(string pchURL, string pchCookieName, StringBuilder pchCookieData, ref System.UInt32 pcchCookieData, int dwFlags, IntPtr lpReserved);
    
            [DllImport("wininet.dll", CharSet = CharSet.Auto, SetLastError = true)]
            static extern int InternetSetCookieEx(string lpszURL, string lpszCookieName, string lpszCookieData, int dwFlags, IntPtr dwReserved);
    
            private static string GetCookieString(string url)
            {
                // Determine the size of the cookie     
                uint datasize = 256;
                StringBuilder cookieData = new StringBuilder((int)datasize);
    
                if (!InternetGetCookieEx(url, null, cookieData, ref datasize, 0x2000, IntPtr.Zero))
                {
                    if (datasize < 0)
                        return null;
    
                    // Allocate stringbuilder large enough to hold the cookie     
                    cookieData = new StringBuilder((int)datasize);
                    if (!InternetGetCookieEx(url, null, cookieData, ref datasize, 0x00002000, IntPtr.Zero))
                        return null;
                }
                return cookieData.ToString();
            }
  • 相关阅读:
    变量与作用域
    安装node和grunt
    神奇的万维网
    大小写字母的转换
    跨域的方法
    选择器中含有空格的注意事项
    Tools
    jquery中innerWidth(),outerWidth(),outerWidth(true)和width()的区别
    网页中的foot底部定位问题
    CSS hack
  • 原文地址:https://www.cnblogs.com/XuPengLB/p/9261976.html
Copyright © 2011-2022 走看看