`
wsql
  • 浏览: 11793847 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
文章分类
社区版块
存档分类
最新评论

wininet.dll函数库:不会过期的cookie

阅读更多

wininet.dll中包含很多win32下和网络有关的函数,包括internet,ftp等,下面演示一个IE下不过期的cookie。 比如csdn的登陆信息可以保存2个星期,你在登陆后把系统时间改为2周后,登陆信息就失效了,使用InternetSetCookie可以自己设置过期日期。 首先在IE中登陆,登陆时选择信息保存2周,然后运行如下代码,运行之后你可以把日期调整到2010年看效果:

using System;

using System.Text;

using System.Runtime.InteropServices;

namespace ConsoleApplication1

{

    class Program

    {

        /// <summary>

        /// 设置cookie

        /// </summary>

        [DllImport("wininet.dll", CharSet = CharSet.Auto, SetLastError = true)]

        public static extern bool InternetSetCookie(string lpszUrlName, string lbszCookieName, string lpszCookieData);

        /// <summary>

        /// 获取cookie

        /// </summary>

        [DllImport("wininet.dll", CharSet = CharSet.Auto, SetLastError = true)]

        public static extern bool InternetGetCookie(

          string url, string name, StringBuilder data, ref int dataSize);

        static void Main(string[] args)

        {

            //获取旧的

            StringBuilder cookie = new StringBuilder(new String(' ',2048));

            int datasize = cookie.Length;

            bool b= InternetGetCookie("http://community.csdn.net", null, cookie, ref datasize);

            //删除旧的

            foreach (string fileName in System.IO.Directory.GetFiles(System.Environment.GetFolderPath(Environment.SpecialFolder.Cookies)))

            {

                if (fileName.ToLower().IndexOf("csdn") > 0)

                {

                    System.IO.File.Delete("csdn");

                }

            }

            //生成新的

            foreach (string c in cookie.ToString().Split(';'))

            {

                string[] item = c.Split('=');

                string name = item[0];

                string value = item[1] + ";expires=Sun,22-Feb-2099 00:00:00 GMT";

                InternetSetCookie("http://community.csdn.net",name,value);

                InternetSetCookie("http://forum.csdn.net", name, value);

                InternetSetCookie("http://webim.csdn.net", name, value);

            }

        }

    }

}
分享到:
评论

相关推荐

    Wininet.dll 32+64位库下载

    Wininet.dll 32+64位库下载

    qqdownload

    C:\WINDOWS\system32\Msimg32.dll|C:\WINDOWS\system32\IMM32.DLL|C:\WINDOWS\System32\CSCDLL.dll|C:\WINDOWS\System32\cscui.dll|C:\WINDOWS\system32\CRYPT32.dll|C:\WINDOWS\system32\WININET.dll|C:\WINDOWS\...

    Hook WININET.dll

    Hook浏览器控件WebBrowser对WININET.dll的调用,来实现获取115网盘文件列表

    SCS.rar_Explorer_internet explorer3._scs_wininet.dll

    程序需要较新版 WinInet.dll。可能需要安装 Internet Explorer 3.02 或更高版本。

    wininet.dll创建线程2个demo

    发现wininet.dll库中的代码会背着程序员创建线程,里面是2个测试demo。

    RAD Studio 10.2 Toyko Update2 10.2.2 KEYGEN 亲测可用

    comctl32.dll, 6.10.16299.125, C:\WINDOWS\WinSxS\x86_microsoft.windows.common-controls_6595b64144ccf1df_6.0.16299.125_none_5d79065fa7de350f\ comdlg32.dll, 10.0.16299.125, C:\WINDOWS\System32\ ...

    WinInet.rar

    在vc6下自带的WinInet.h头文件中未定义FtpCommand和FfpGetFileSize函数,所以通过WinInet开发Ftp上传与下载程序将会遇到问题 通过Microsoft Platform SDK Febrary 2003版中的更新WinInet.h和WinInet.lib文件可以解决...

    WinInet.Component.Suite.1.9.For.Delphi.BCB56-EQUiUM.rar

    WinInet.Component.Suite.1.9.For.Delphi.BCB56-EQUiUM.rar

    易语言HTTPS访问网页模块源码

    .DLL命令 InternetOpenA, 整数型, "WinINet.dll" .参数 lpszAgent, 文本型 .参数 dwAccessType, 整数型 .参数 lpszProxyName, 文本型 .参数 lpszProxyBypass, 文本型 .参数 dwFlags, 整数型 .DLL命令 ...

    FTP(Wininet.dll).rar_ftp vb

    vb code 應用程式可以使用ftp連線

    autoit wininet

    autoit wininet.au3 api wininet.dll

    au3 wininet.au3

    au3 udf wininet, 很有用的一个UDF.下吧

    C语言头文件 WININET.rar

    C语言头文件 WININETC语言头文件 WININETC语言头文件 WININETC语言头文件 WININETC语言头文件 WININETC语言头文件 WININETC语言头文件 WININETC语言头文件 WININETC语言头文件 WININETC语言头文件 WININETC语言...

    winhttp+wininet.e

    winhttp+wininet.e

    wininet.dll

    wininet

    HTTPGET-单线程下载(源代码)

    file version: 1.94file description: The HTTPGet component intended for downloading files/documents/results of CGI scripts from the web using standard Microsoft Windows Internet library (winInet.dll) ...

    C++实现HTTP下载(两种方式:WinInet和Socket)

    1.WinInet(这种方式很简单,但不是很灵活) 2.WinSock(也就是Socket,这种方式有点繁琐,但是可以自定义发送HTTP的报文头和接收响应头,很灵活) 因作者编程水平有限,错误之处,在所难免,欢迎批评指正。

    IE浏览器插件.zip

    │ wininet.dll │ ├─ie9 │ │ IETester.ie9.exe │ │ │ └─ietester.ie9.exe.local │ dxtmsft.dll │ dxtrans.dll │ html.iec │ IEAdvpack.dll │ ieapfltr.dll │ iedkcs32.dll │ ...

Global site tag (gtag.js) - Google Analytics