private void button1_Click(object sender, EventArgs e)
{
int nNeeded = , nBufSize;
IntPtr buf;
INTERNET_CACHE_ENTRY_INFO CacheItem;
IntPtr hEnum;
bool r; FindFirstUrlCacheEntry(null, IntPtr.Zero, ref nNeeded); if (Marshal.GetLastWin32Error() == ERROR_NO_MORE_ITEMS)
return; nBufSize = nNeeded;
buf = Marshal.AllocHGlobal(nBufSize);
hEnum = FindFirstUrlCacheEntry(null, buf, ref nNeeded);
var sb = new StringBuilder();
while (true)
{
CacheItem = (INTERNET_CACHE_ENTRY_INFO) Marshal.PtrToStructure(buf,typeof (INTERNET_CACHE_ENTRY_INFO));
string url = Marshal.PtrToStringAuto(CacheItem.lpszSourceUrlName);
if (url.Contains("mp.weixin.qq.com/misc/getheadimg"))
{
string modifiedTime = FILETIMEtoDataTime(CacheItem.LastModifiedTime);
string expireTime = FILETIMEtoDataTime(CacheItem.ExpireTime);
string accessTime = FILETIMEtoDataTime(CacheItem.LastAccessTime);
string syncTime = FILETIMEtoDataTime(CacheItem.LastSyncTime); var LocalFileName = Marshal.PtrToStringAuto(CacheItem.lpszLocalFileName);
sb.AppendFormat("\r\nUrl {0}", url);
sb.AppendFormat("\r\n本地路径{0}",LocalFileName);
if (!File.Exists(LocalFileName))
{
sb.AppendFormat("\r\n本地路径不存在!!!");
}
else
{
sb.AppendFormat("\r\nmodifiedTime {0}", modifiedTime);
sb.AppendFormat("\r\n expireTime {0}", expireTime);
sb.AppendFormat("\r\n accessTime {0}",accessTime );
sb.AppendFormat("\r\n syncTime {0}", syncTime); var id = Util.GetMatchValue(url, @"fakeid\=(\d+)");
var path = @"c:\1\" + id + ".jpg";
if (!File.Exists(path))
{ File.Copy(LocalFileName, path);
}
}
// pictureBox1.Image = GetThumbnail(LocalFileName);
//if (s.Contains(textBox1.Text))
//{
//}
}
nNeeded = nBufSize;
r = FindNextUrlCacheEntry(hEnum, buf, ref nNeeded); if (!r && Marshal.GetLastWin32Error() == ERROR_NO_MORE_ITEMS)
break; if (!r && nNeeded > nBufSize)
{
nBufSize = nNeeded;
buf = Marshal.ReAllocHGlobal(buf, (IntPtr) nBufSize);
FindNextUrlCacheEntry(hEnum, buf, ref nNeeded);
}
}
Util.Log(sb);
MessageBox.Show("系统数据加载完毕!");
Marshal.FreeHGlobal(buf);
} #region MyRegion #region 引入dll [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct INTERNET_CACHE_ENTRY_INFO
{
public int dwStructSize;
public IntPtr lpszSourceUrlName;
public IntPtr lpszLocalFileName;
public int CacheEntryType;
public int dwUseCount;
public int dwHitRate;
public int dwSizeLow;
public int dwSizeHigh;
public FILETIME LastModifiedTime;
public FILETIME ExpireTime;
public FILETIME LastAccessTime;
public FILETIME LastSyncTime;
public IntPtr lpHeaderInfo;
public int dwHeaderInfoSize;
public IntPtr lpszFileExtension;
public int dwExemptDelta;
} [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct SYSTEMTIME
{
public short wYear;
public short wMonth;
public short wDayOfWeek;
public short wDay;
public short wHour;
public short wMinute;
public short wSecond;
public short wMilliseconds;
} [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Auto)]
public static extern int FileTimeToSystemTime(IntPtr lpFileTime,IntPtr lpSystemTime); [DllImport("wininet.dll", SetLastError = true, CharSet = CharSet.Auto)]
public static extern IntPtr FindFirstUrlCacheEntry([MarshalAs(UnmanagedType.LPTStr)] string lpszUrlSearchPattern,IntPtr lpFirstCacheEntryInfo,ref int lpdwFirstCacheEntryInfoBufferSize); [DllImport("wininet.dll", SetLastError = true, CharSet = CharSet.Auto)]
public static extern bool FindNextUrlCacheEntry(IntPtr hEnumHandle,IntPtr lpNextCacheEntryInfo,ref int lpdwNextCacheEntryInfoBufferSize); [DllImport("wininet.dll")]
public static extern bool FindCloseUrlCache(
IntPtr hEnumHandle); const int ERROR_NO_MORE_ITEMS = ; #endregion #region FileTimeToSystemTime private string FILETIMEtoDataTime(FILETIME time)
{
IntPtr filetime = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(FILETIME)));
IntPtr systime = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(SYSTEMTIME)));
Marshal.StructureToPtr(time, filetime, true);
FileTimeToSystemTime(filetime, systime);
SYSTEMTIME st = (SYSTEMTIME)Marshal.PtrToStructure(systime, typeof(SYSTEMTIME));
string Time = st.wYear+"-" + st.wMonth+"-" + st.wDay+" " + st.wHour+":" + st.wMinute+":" + st.wSecond;
return Time;
} #endregion
#endregion

C# 读取IE缓存文件(2)的更多相关文章

  1. php实现数据库数据读取生成缓存文件

    有些时候我们希望减少对数据库的 查询来提高程序的性能,因为这些数据不是经常变更的,而是会在很长一段时间内都不会变化,因此,我们每连接一次数据库,都会把相应的结果用文件的形式保存 起来.比如对于一个商城 ...

  2. 读取IE缓存文件

    使用WebCacheTool项目中的WinInetAPI.cs和Win32API.cs两个类 /// <summary> /// 获取IE缓存文件 /// </summary> ...

  3. C# 读取IE缓存文件(1)

    using System; using System.Runtime.InteropServices; namespace Common { public class IECache { [DllIm ...

  4. Python3实现从文件中读取指定行的方法

    from:http://www.jb51.net/article/66580.htm 这篇文章主要介绍了Python3实现从文件中读取指定行的方法,涉及Python中linecache模块操作文件的使 ...

  5. CVE-2017-7529-Nginx越界读取缓存漏洞

    漏洞参考 https://blog.csdn.net/qq_29647709/article/details/85076309 漏洞原因 Nginx在反向代理站点的时候,通常会将一些文件进行缓存,特别 ...

  6. 深入探究ASP.NET Core读取Request.Body的正确方式

    前言 相信大家在使用ASP.NET Core进行开发的时候,肯定会涉及到读取Request.Body的场景,毕竟我们大部分的POST请求都是将数据存放到Http的Body当中.因为笔者日常开发所使用的 ...

  7. Nginx越界读取缓存漏洞 CVE-2017-7529

    1.漏洞描述 Nginx在反向代理站点的时候,通常会将一些文件进行缓存,特别是静态文件.缓存的部分存储在文件中,每个缓存文件包括"文件头"+"HTTP返回包头" ...

  8. VS调试经常打断点打上之后没反应的问题

    在调试的时候经常会发现打了断点但是始终不进到程序中来,这是因为访问的这个页面在服务器中有缓存,也就是在iis中产生了缓存.访问的时候直接进到读取的缓存文件, 根本没有读取项目文件,所以打了断点肯定进不 ...

  9. ThinkPHP2.2框架执行流程图,ThinkPHP控制器的执行流程

    ThinkPHP2.2框架执行原理.流程图在线手册 ThinkPHP控制器的执行流程 对用户的第一次URL访问 http://<serverIp>/My/index.php/Index/s ...

随机推荐

  1. Hulu面试题解答——N位数去除K个数字(解法错误sorry)

    给定一个N位数,比如12345,从里面去掉k个数字.得到一个N-k位的数.比如去掉2,4,得到135,去掉1,5.得到234.设计算法.求出全部得到的N-k位数里面最小的那一个. 写的代码例如以下,思 ...

  2. SE 2014年5月22日

    一.   用自己的理解描述 tunnel接口状态 up和down的情况都有哪些 Tunnel接口的状态UP:隧道的目标有可达路由. Tunnel接口的状态Down:隧道的目标路由不可达. 如图配置实验 ...

  3. 读书笔记:《为什么大猩猩比专家高明, How We Decide》

    读书笔记:<为什么大猩猩比专家高明, How We Decide> 英文的书名叫<How We Decide>,可能是出版社的原因,非要弄一个古怪的中文书名<为什么大猩猩 ...

  4. linux--shell script

    下面是最近学习shell script的一些知识点总结 ***博客园-邦邦酱好***   1.介绍shell是一个文字接口,让我们与系统沟通.shell script就是针对shell所写的脚本.它就 ...

  5. Eclipse中的SVN的冲突解决方案详解

    版本冲突原因: 假设A.B两个用户都在版本号为100的时候,更新了kingtuns.txt这个文件,A用户在修改完成之后提交kingtuns.txt到服务器,这个时候提交成功,这个时候kingtuns ...

  6. poj1655 Balancing Act 找树的重心

    http://poj.org/problem? id=1655 Balancing Act Time Limit: 1000MS   Memory Limit: 65536K Total Submis ...

  7. Mybatis数据操作

    Maven 工程下 Spring MVC 站点配置 (二) Mybatis数据操作   详细的Spring MVC框架搭配在这个连接中: Maven 工程下 Spring MVC 站点配置 (一) M ...

  8. Unity入门

    Unity入门 用unity做一个最简单的交互.(相当于Hello World)仅仅要最后能执行就算入门了. 第一步,要先用三维制作软件制作出我们须要的场景. 这儿使用的是Max2012(软件大小3. ...

  9. 关与 Visual.Assist.X.V10.7.1912的Crack破解补丁(vs 番茄插件的key破解方法)

    在win7系统下, 我用的是vs2012版本号. Visual Assist沿用了快10年的界面,最终有了更新,变得更加适合Win8 以及 VS2012的主题风格了 ,这也是以后软件的发展趋势,仅仅是 ...

  10. Mongodb入门——安装与配置

    作者:zhanhailiang 日期:2014-11-07 1. 安装mongodb: [root@~/wade/nodejs/nodeclub]# yum search mongodb [root@ ...