---
title: "用API获取IE缓存文件"
author: "csstome"
date: "2007-12-20T02:00:00Z"
tags: []
slug: "api-ie"
draft: false
lastmod: "2007-12-20T02:00:00Z"
id: 1033162
url: "https://csstome.iteye.com/blog/1033162"
---

![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)// usingsystem.runtime.interopservices;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) \[structlayout(layoutkind.sequential,charset = charset.auto)]  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) public struct internet\_cache\_entry\_info  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif) ... {  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) public int dwstructsize;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) public intptrlpszsourceurlname;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) public intptrlpszlocalfilename;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) public int cacheentrytype;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) public int dwusecount;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) public int dwhitrate;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) public int dwsizelow;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) public int dwsizehigh;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) public filetimelastmodifiedtime;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) public filetimeexpiretime;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) public filetimelastaccesstime;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) public filetimelastsynctime;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) public intptrlpheaderinfo;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) public int dwheaderinfosize;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) public intptrlpszfileextension;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) public int dwexemptdelta;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif) }  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) \[dllimport( " wininet.dll " ,setlasterror = true ,charset = charset.auto)]  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) public static extern intptrfindfirsturlcacheentry(\[marshalas(unmanagedtype.lptstr)] string urlsearchpattern,intptrlpfirstcacheentryinfo, ref int lpdwfirstcacheentryinfobuffersize);  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) \[dllimport( " wininet.dll " ,setlasterror = true ,charset = charset.auto)]  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) public static extern bool geturlcacheentryinfo(\[marshalas(unmanagedtype.lptstr)] string lpszurlname,intptrlpcacheentryinfo, ref int lpdwcacheentryinfobuffersize);  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) public static string getcatchfilename( string url)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif) ... {  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) int nneeded = 0 ,nbufsize;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) intptrbuf;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) findfirsturlcacheentry( null ,intptr.zero, ref nneeded);  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) nbufsize = nneeded;buf = marshal.allochglobal(nbufsize);  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) geturlcacheentryinfo(url,buf, ref nneeded);  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) internet\_cache\_entry\_infocacheitem;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) geturlcacheentryinfo(url,buf, ref nneeded);  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) cacheitem = (internet\_cache\_entry\_info)marshal.ptrtostructure(buf, typeof (internet\_cache\_entry\_info));  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) string res = marshal.ptrtostringauto(cacheitem.lpszlocalfilename);  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) return (res);  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif) }  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)