|
webBrowser中取Cookie的方法在Win7 64位系统下有问题,方法应该改为
private static string GetCookieString(string url)
{
uint capacity = 0x100;
StringBuilder pchCookieData = new StringBuilder((int)capacity);
if (!InternetGetCookieEx(url, null, pchCookieData, ref capacity, 0x2000, IntPtr.Zero))
{
if (capacity < 0)
{
return null;
}
pchCookieData = new StringBuilder((int)capacity);
if (!InternetGetCookieEx(url, null, pchCookieData, ref capacity, 0x2000, IntPtr.Zero))
{
return null;
}
}
return pchCookieData.ToString();
}
[System.Runtime.InteropServices.DllImport("wininet.dll", CharSet = System.Runtime.InteropServices.CharSet.Auto, SetLastError = true)]
private static extern bool InternetGetCookieEx(string pchURL, string pchCookieName, StringBuilder pchCookieData, ref System.UInt32 pcchCookieData, int dwFlags, IntPtr lpReserved);
|
|