当前位置:编程学习 > C#/ASP.NET >>

API如何获取IE缓存文件

//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); 
 }
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,