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获取缓存文件
转载本文章为转载内容,我们尊重原作者对文章享有的著作权。如有内容错误或侵权问题,欢迎原作者联系我们进行内容更正或删除文章。
上一篇:信号与中断
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
java 根据HttpEntity 中contenttype获取文件类型
java 根据HttpEntity 中contenttype获取文件类型
apache HTTP Apache -
java根据表名称获取所有字段
java根据表名称获取所有字段
字段 java sql -
Android 图片缓存函数库 Glide vs Picasso
方式,这两个库
android glide picasso ide 加载 -
函数库java 函数库和库函数
&n
函数库java 头文件 库函数 函数库