Http://www.chenjiliang.com/Article/View.aspx? ArticleID = 1621 & typeid = 84
As you know, when we visit a website. The system will cache all the images and animations on the website to the Temporary Internet folder.
You can access <drives >:\ Documents and Settings \ <user> \ Local Settings \ Temporary Internet Files. However, we may not have imagined that the files in the folder are actually different from those in other folders and files in our system.
For example, when we write a function under vs.net to return the folders and all files in the specified folder, but when we pass the address of the Temporary Internet folder into, the system will return only one file, that is, desktop. INI (each folder has), and there is a hidden folder. This proves that the files in the Temporary Folder do not exist in the normal folder and file mode.
In fact, Windows stores all temporary files in a hidden folder, which we cannot see, and then reads and displays all the content back and forth to the user through an index. dat index.
How can we use it?ProgramTo read the content? I have studied this because I have helped my students complete his graduation project over the past few days.
First, you must reference a user. dll in the system folder. Then, you can use some of its functions to traverse the entire folder and obtain information about each file.
Copy Save
[Dllimport ( "Wininet. dll" , Setlasterror = True , Charset = charset. Auto)] Public Static Extern Intptr findfirsturlcacheentry ([financialas (unmanagedtype. lptstr)] String Lpszurlsearchpattern, intptr lpfirstcacheentryinfo,Ref Int Lpdwfirstcacheentryinfobuffersize); [dllimport ( "Wininet. dll" , Setlasterror = True , Charset = charset. Auto)] Public Static Extern Bool Findnexturlcacheentry (intptr henumhandle, intptr lpnextcacheentryinfo, Ref Int Lpdwnextcacheentryinfobuffersize); [dllimport ( "Wininet. dll" )] Public Static Extern Bool Findcloseurlcache (intptr henumhandle );
Introduce the above three functions to traverse the Temporary Folder and then reference Copy Save
[Dllimport ("Kernel32.dll", Setlasterror =True, Charset = charset. Auto)]Public Static Extern IntFiletimetosystemtime (intptr lpfiletime, intptr lpsystemtime );
It is used to convert the filetime format to the string type in C # For further operations.
The main program is as follows: Copy Save
# Introduce DLL to Region [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;} [structlayout (layoutkind. Sequential, charset = charset. Auto)] Public Struct Systemtime { Public Short Wyear; Public Short Wmonth; Public Short Wdayofweek; Public Short Wday; Public Short Whour; Public Short Wminute; Public Short Wsecond; Public Short Wmilliseconds;} [dllimport ( "Kernel32.dll" , Setlasterror = True , Charset = charset. Auto)] Public Static Extern Int Filetimetosystemtime (intptr lpfiletime, intptr lpsystemtime); [dllimport ( "Wininet. dll" , Setlasterror = True , Charset = charset. Auto)] Public Static Extern Intptr findfirsturlcacheentry ([financialas (unmanagedtype. lptstr)] String Lpszurlsearchpattern, intptr lpfirstcacheentryinfo, Ref Int Lpdwfirstcacheentryinfobuffersize); [dllimport ( "Wininet. dll" , Setlasterror = True , Charset = charset. Auto)] Public Static Extern Bool Findnexturlcacheentry (intptr henumhandle, intptr lpnextcacheentryinfo, Ref Int Lpdwnextcacheentryinfobuffersize); [dllimport ( "Wininet. dll" )] Public Static Extern Bool Findcloseurlcache (intptr henumhandle ); Const Int Error _ no_more_items = 259; # Endregion # Region filetimetosystemtime Private String Filetimetodatatime (filetime time) {intptr filetime = marshal. allochglobal (marshal. sizeof ( Typeof (Filetime); intptr policime = marshal. allochglobal (marshal. sizeof ( Typeof (Systemtime); marshal. structuretoptr (time, filetime, True ); Filetimetosystemtime (filetime, effecime); systemtime ST = (systemtime) Marshal. ptrtostructure (effecime, Typeof (Systemtime )); String Time = ST. wyear. tostring () + "." + St. wmonth. tostring () + "." + St. wday. tostring () + "." + St. whour. tostring () + "." + St. wminute. tostring () + "." + St. wsecond. tostring (); Return Time ;} # Endregion # Region loading data Private Void Fileok_click (Object Sender, system. eventargs e ){ Int Nneeded = 0, nbufsize; intptr Buf; internet_cache_entry_info cacheitem; intptr henum; Bool R; findfirsturlcacheentry ( Null , Intptr. Zero, Ref Nneeded ); If (Marshal. getlastwin32error () = error_no_more_items) Return ; Nbufsize = nneeded; Buf = marshal. allochglobal (nbufsize); henum = findfirsturlcacheentry ( Null , Buf, Ref Nneeded ); While ( True ) {Cacheitem = (internet_cache_entry_info) Marshal. ptrtostructure (BUF, Typeof (Internet_cache_entry_info )); String Modifiedtime = filetimetodatatime (cacheitem. lastmodifiedtime ); String Expiretime = filetimetodatatime (cacheitem. expiretime ); String AccessTime = filetimetodatatime (cacheitem. lastaccesstime ); String Synctime = filetimetodatatime (cacheitem. lastsynctime ); # Region obtains data and stores it in the database Try { // You can retrieve cacheitem here. // Example String S = marshal. ptrtostringauto (cacheitem. lpszsourceurlname );}Catch { // Handling } # Endregion String S = marshal. ptrtostringauto (cacheitem. lpszsourceurlname); nneeded = nbufsize; r = findnexturlcacheentry (henum, Buf, Ref Nneeded ); If (! R & amp; marshal. getlastwin32error () = error_no_more_items) Break ; If (! R & nneeded> nbufsize) {nbufsize = nneeded; Buf = marshal. reallochglobal (BUF, (intptr) nbufsize); findnexturlcacheentry (henum, Buf, Ref Nneeded) ;}} MessageBox. Show ( "System data has been loaded! " ); Marshal. freehglobal (BUF );} # Endregion