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();
            }
  • 相关阅读:
    Java学习日记Ⅰ
    docker 安装redis
    maven 打包 把第三方包也打进去
    wiki 配置数据源 编码要是utf8 不能是utf8mb4
    SCFT用公钥登录
    配置tomcat重启脚本
    tomcat
    centos7 搭建rabbitmq服务 3.7.15
    安装openoffice
    tomcat 日期切分
  • 原文地址:https://www.cnblogs.com/XuPengLB/p/9261976.html
Copyright © 2011-2022 走看看