Skip to content

CSharp获取WebBrower的cookie信息

Published: at 10:47编辑该页面
[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);

private static string GetCookieString(string url)
{
    int datasize = 256;
    StringBuilder cookieData = new StringBuilder(datasize);
    if (!InternetGetCookieEx(url, null, cookieData, ref datasize, 0x00002000, null))
    {
        if (datasize < 0)
            return null;
        cookieData = new StringBuilder(datasize);
        if (!InternetGetCookieEx(url, null, cookieData, ref datasize, 0x00002000, null))
            return null;
    }
    return cookieData.ToString();
}

上一篇
Tomcat下多域名及SSL证书配置
下一篇
CentOS6 / Debian6 / Ubuntu14 ShadowsocksR一键部署管理脚本