我想在C#应用程序里面读取浏览器的Cookie,怎么做?在线等待!!! http://www.aspcool.com/lanmu/browse.asp?bbsuser=aspnet 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 我开发的不是b/s结构的程序,是普通应用程序,没有请求、响应机制,我要做的就是把本机上保存的Cookie信息读取出来 HttpCookie类,不知道能不能在winform里面用,如果不能,有一个折衷的方法:在你的winform里面镶入一个webbrowser 1.读取注册表,获取cookie保存位置2.象读取文本文件一样读出cookie文件;3.作相应处理。 ==》可否? 我也知道,Cookie是一系列文本文件,存放在指定的目录下,不过有些信息是加密的,我得知道他的规则才能直接通过读取这些文件得到! using System;using System.Text;using System.Runtime.InteropServices;class TestCookie{ [DllImport("wininet.dll", CharSet=CharSet.Auto, SetLastError=true)] public static extern bool InternetGetCookie( string lpszUrlName, string lpszCookieName, StringBuilder lpszCookieData, ref uint lpdwSize ); [DllImport("kernel32.dll")] internal static extern Int32 GetLastError(); public static string GetCookie(string url) { StringBuilder sb = new StringBuilder(1000); uint size = 1000; bool bGood = InternetGetCookie(url,"", sb,ref size); if (!bGood) Console.WriteLine("Error code:{0}", GetLastError()); return sb.ToString(); } public static void Main() { Console.WriteLine(GetCookie("http://expert.csdn.net")); } 我现在 很想知道什么时候要调用API,请高手指点 |ZYCWPF| 用户控件是有构造函数参数的,如何在XAML中进地实例 System.Net.Mail类库的小BUG啊~ 初学WPF,一个定制控件,求助 求救,求救! ajax控件tabcontainer中怎么实现textbox.focus() winform关闭问题 问一个vs2005引用类的问题 何处能下到longhorn??? .net中怎样用c#和asp.net结合开发web应用程序?请赐教 我的首页问题 一个很简单的问题: 为什么TextBox的文本不换行? Visual 2003的.net framework1.1装不上了
2.象读取文本文件一样读出cookie文件;
3.作相应处理。 ==》可否?
using System.Text;
using System.Runtime.InteropServices;
class TestCookie
{ [DllImport("wininet.dll", CharSet=CharSet.Auto, SetLastError=true)]
public static extern bool InternetGetCookie(
string lpszUrlName,
string lpszCookieName,
StringBuilder lpszCookieData,
ref uint lpdwSize
);
[DllImport("kernel32.dll")]
internal static extern Int32 GetLastError(); public static string GetCookie(string url)
{
StringBuilder sb = new StringBuilder(1000);
uint size = 1000;
bool bGood = InternetGetCookie(url,"", sb,ref size);
if (!bGood)
Console.WriteLine("Error code:{0}", GetLastError()); return sb.ToString();
}
public static void Main()
{
Console.WriteLine(GetCookie("http://expert.csdn.net"));
}