InternetGetCookie API 求助.目的是获得本地保存的指定Url的Cookie
在网上搜索了一下.说是可以用InternetGetCookie这个api来获得cookie
用以下代码
[System.Runtime.InteropServices.DllImport("wininet.dll", CharSet = System.Runtime.InteropServices.CharSet.Auto, SetLastError = true)]
public static extern bool InternetGetCookie(string lpszUrlName, string lpszCookieName, StringBuilder lpszCookieData, ref int lpdwSize);
[System.Runtime.InteropServices.DllImport("kernel32.dll")]
internal static extern Int32 GetLastError();
public static string GetCookie(string url) //Win32 API
{
int size = 1000;
StringBuilder sb = new StringBuilder(size);
if (!InternetGetCookie(url, "", sb, ref size))
{
Console.WriteLine("Error code:{0}", GetLastError());
}
return sb.ToString();
}
static void Main(string[] args)
{
System.Console.WriteLine(GetCookie("http://www.google.com/"));
}
返回错误结果Error code:259
网上写着说什么不支持xp sp2.不知道有没有什么解决方法?
问题点数:20、回复次数:3Top
1 楼hdt(倦怠)回复于 2006-03-19 06:02:18 得分 20
259
没有可用的数据了。Top
2 楼boyyao(迷失在网络 (问题不解答扣分也不结贴!))回复于 2006-03-19 09:59:37 得分 0
可是我确定我的cookie目录的确有google.com的cookie保存着啊..
不如用户名@google[1].txt这样类似的.
我试了好些站点都这样.Top
3 楼boyyao(迷失在网络 (问题不解答扣分也不结贴!))回复于 2006-03-23 09:20:27 得分 0
自己解决了.送分..
Top




