//
usingsystem.runtime.interopservices;
[structlayout(layoutkind.sequential,charset
=
charset.auto)]
public
struct
internet_cache_entry_info
...
{
public
int
dwstructsize;
public
intptrlpszsourceurlname;
public
intptrlpszlocalfilename;
public
int
cacheentrytype;
public
int
dwusecount;
public
int
dwhitrate;
public
int
dwsizelow;
public
int
dwsizehigh;
public
filetimelastmodifiedtime;
public
filetimeexpiretime;
public
filetimelastaccesstime;
public
filetimelastsynctime;
public
intptrlpheaderinfo;
public
int
dwheaderinfosize;
public
intptrlpszfileextension;
public
int
dwexemptdelta;
}
[dllimport(
"
wininet.dll
"
,setlasterror
=
true
,charset
=
charset.auto)]
public
static
extern
intptrfindfirsturlcacheentry([marshalas(unmanagedtype.lptstr)]
string
urlsearchpattern,intptrlpfirstcacheentryinfo,
ref
int
lpdwfirstcacheentryinfobuffersize);
[dllimport(
"
wininet.dll
"
,setlasterror
=
true
,charset
=
charset.auto)]
public
static
extern
bool
geturlcacheentryinfo([marshalas(unmanagedtype.lptstr)]
string
lpszurlname,intptrlpcacheentryinfo,
ref
int
lpdwcacheentryinfobuffersize);
public
static
string
getcatchfilename(
string
url)
...
{
int
nneeded
=
0
,nbufsize;
intptrbuf;
findfirsturlcacheentry(
null
,intptr.zero,
ref
nneeded);
nbufsize
=
nneeded;buf
=
marshal.allochglobal(nbufsize);
geturlcacheentryinfo(url,buf,
ref
nneeded);
internet_cache_entry_infocacheitem;
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);
}
181

被折叠的 条评论
为什么被折叠?



