//using system.runtime.interopservices;
[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;
intptr buf;
findfirsturlcacheentry( null, intptr.zero, ref nneeded );
nbufsize = nneeded; buf = marshal.allochglobal( nbufsize );
geturlcacheentryinfo(url,buf,ref nneeded);
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);
}