Wininetdll函数库:根据url获取缓存文件
2008-07-14 15:14
309 查看
using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; namespace ConsoleApplication34 { class Program { [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; } [DllImport("wininet.dll", SetLastError = true, CharSet = CharSet.Auto)] public static extern IntPtr FindFirstUrlCacheEntry([MarshalAs(UnmanagedType.LPTStr)] string urlsearchpattern, IntPtr lpfirstcacheentryinfo, ref int lpdwfirstcacheentryinfobuffersize); [DllImport("wininet.dll", SetLastError = true, CharSet = CharSet.Auto)] public static extern bool GetUrlCacheEntryInfo([MarshalAs(UnmanagedType.LPTStr)] string lpszurlname, IntPtr lpcacheentryinfo, ref int lpdwcacheentryinfobuffersize); public static string getcatchfilename(string url) { int nneeded = 0, nbufsize = 0; IntPtr buf = IntPtr.Zero; FindFirstUrlCacheEntry(null, IntPtr.Zero, ref nneeded); nbufsize = nneeded; buf = Marshal.AllocHGlobal(nbufsize); internet_cache_entry_info cacheitem; GetUrlCacheEntryInfo(url, buf, ref nneeded); cacheitem = (internet_cache_entry_info)Marshal.PtrToStructure(buf, typeof(internet_cache_entry_info)); string res = Marshal.PtrToStringAuto(cacheitem.lpszlocalfilename); return (res); } static void Main(string[] args) { string str = getcatchfilename("http://profile.csdn.net/jinjazz/picture/2.jpg"); Console.WriteLine(str); Console.Read(); } } }
相关文章推荐
- Wininetdll函数库:根据url获取缓存文件
- Wininetdll函数库:根据url获取缓存文件
- delphi根据URL获取缓存文件的方法
- Python 获取根据文件URL 获取文件的基本信息
- 根据URL获取文件,以采集网络图片为例
- IOS工具类 (钱转化(分到元),快速创建控件,生成图片名称,验证信息,缓存文件,友盟统计类,转换为json,获取URl中的参数)
- Android里根据下载文件的url获取文件名
- 根据Url获取手机文件真实路径
- 根据url获取文件名,获取文件大小
- Qt 之 模仿迅雷 根据Url获取文件信息——上
- Qt 之 模仿迅雷 根据Url获取文件信息——下
- android:根据下载文件的url获取文件名
- 【原创】ABAP根据文件路径获取文件所在目录
- 根据文件路径获取剩余磁盘空间
- 根据网页的URL获取网页信息
- js文件封装javascript在html中获取url参数
- java调用百度地图API通过URL根据地理位置中文处理返回值获取经纬度
- ios获取缓存文件的大小,实现缓的清理功能
- win7中如何获取IE8的缓存视频文件
- 根据jks文件获取SHA1签名