zoukankan      html  css  js  c++  java
  • webBrowser获取取Cookie不全的解决方法

    //取当前webBrowser登录后的Cookie值   
            [DllImport("wininet.dll", CharSet = CharSet.Auto, SetLastError = true)]
            static extern bool InternetGetCookieEx(string pchURL, string pchCookieName, StringBuilder pchCookieData, ref int pcchCookieData, int dwFlags, object lpReserved);
            //取出Cookie,当登录后才能取    
            private static string GetCookieString(string url)
            {
                // Determine the size of the cookie      
                int datasize = 256;
                StringBuilder cookieData = new StringBuilder(datasize);
                if (!InternetGetCookieEx(url, null, cookieData, ref datasize, 0x00002000, null))
                {
                    if (datasize < 0)
                        return null;
                    // Allocate stringbuilder large enough to hold the cookie    
                    cookieData = new StringBuilder(datasize);
                    if (!InternetGetCookieEx(url, null, cookieData, ref datasize, 0x00002000, null))
                        return null;
                }
                return cookieData.ToString();
            }



    获取的方法很简单
     
    string ccokie= GetCookieString("http://www.baidu.com");
  • 相关阅读:
    Maximum Flow Exhaustion of Paths Algorithm
    ubuntu下安装java环境
    visualbox使用(二)
    vxworks一个超级奇怪的错误(parse error before `char')
    February 4th, 2018 Week 6th Sunday
    February 3rd, 2018 Week 5th Saturday
    February 2nd, 2018 Week 5th Friday
    February 1st, 2018 Week 5th Thursday
    January 31st, 2018 Week 05th Wednesday
    January 30th, 2018 Week 05th Tuesday
  • 原文地址:https://www.cnblogs.com/wangchuang/p/5619442.html
Copyright © 2011-2022 走看看