| 发表于:2007-03-08 16:10:461楼 得分:10 |
using system.runtime.interopservices; [structlayout(layoutkind.sequential)] public class internet_cache_entry_infow { public uint dwstructsize; public string lpszsourceurlname; public string lpszlocalfilename; public uint cacheentrytype; public uint dwusecount; public uint dwhitrate; public uint dwsizelow; public uint dwsizehigh; public filetime lastmodifiedtime; public filetime expiretime; public filetime lastaccesstime; public filetime lastsynctime; public intptr lpheaderinfo; public uint dwheaderinfosize; public string lpszfileextension; public uint dwreserved; //union uint dwexemptdelta; } [dllimport( "wininet.dll ")] public static extern intptr findfirsturlcacheentryex( string lpszurlsearchpattern, uint dwflags, uint dwfilter, int64 groupid, intptr lpfirstcacheentryinfo, ref uint lpdwfirstcacheentryinfobuffersize, pointer lpgroupattributes, pointer pcbgroupattributes, pointer lpreserved ); [dllimport( "wininet.dll ")] public static extern bool findcloseurlcache(intptr henumhandle); [dllimport( "wininet.dll ")] public static extern bool findnexturlcacheentryex( intptr henumhandle, intptr lpfirstcacheentryinfo, ref uint lpdwfirstcacheentryinfobuffersize, pointer lpgroupattributes, pointer pcbgroupattributes, pointer lpreserved); public uint normal_cache_entry = 0x00000001; private void button4_click(object sender, eventargs e) { intptr vhandle; internet_cache_entry_infow vinternetcacheentryinfo = new internet_cache_entry_infow(); uint vfirstcacheentryinfobuffersize = 0; findfirsturlcacheentryex(null, 0, normal_cache_entry, 0, (intptr)null, ref vfirstcacheentryinfobuffersize, null, null, null); intptr vbuffer = marshal.allochglobal((int)vfirstcacheentryinfobuffersize); vhandle = findfirsturlcacheentryex(null, 0, normal_cache_entry, 0, vbuffer, ref vfirstcacheentryinfobuffersize, null, null, null); while (vhandle != null) { marshal.ptrtostructure(vbuffer, vinternetcacheentryinfo); richtextbox1.appendtext(vinternetcacheentryinfo.lpszsourceurlname + "\r\n "); marshal.freecotaskmem(vbuffer); findnexturlcacheentryex(vhandle, (intptr)null, ref vfirstcacheentryinfobuffersize, null, null, null); vbuffer = marshal.allochglobal((int)vfirstcacheentryinfobuffersize); if (!findnexturlcacheentryex(vhandle, vbuffer, ref vfirstcacheentryinfobuffersize, null, null, null)) break; } marshal.freecotaskmem(vbuffer); } | | |
|