. NET reads the Thumbs.db file in the XP folder

Source: Internet
Author: User
Tags file system filetime

Generally in the XP folder, especially in the picture and Video folder has a file-thumbs.db file. This file is used by XP to cache images and audio and video files, and with this file, XP opens a folder that saves a large number of picture files faster than a folder without thumbs.db files-because the latter needs to generate thumbnails in real time.

Recently in doing a picture management program, you need to quickly generate thumbnails, think of reusing this file, so that my program can seamlessly inherit the Windows System's resource manager function. Because the file structure and access APIs for the Thumbs.db file were not made public, Google looked up some data and found that thumbs.db files were structured storage files (structured Storage file) structure, This file is very popular in the COM era, and I don't know why. NET, Microsoft has thrown the file structure away.

Structured Storage Overview

Structured storage file structure plainly is a file system stored in a file, that is, in a structured storage file, save the "folder" information, but also save the "file" information and its contents. For example, we are familiar with the WinRAR process of packaging multiple files, you can use the structured storage file structure to save (of course, I do not have winrar source code, not to say that WinRAR is so packaged AH).

One advantage of using structured storage files is that it makes it easy to update the contents of a file. For example, as we use word for the day, when we edit a file, if Word uses the sequential storage structure-the contents of the file are stored on the disk in the logical structural order of the content, that is, on the hard drive, the first page is saved in front of the second page. The problem with sequential storage is that it makes it very cumbersome to modify Word documents. Suppose your document has thousands of pages, and when you delete the contents of the first page, the sequential storage requires you to move the next thousands of pages--you can imagine how slow the process is. If we look at a Word document as a small filesystem, we can look at it as a "folder" for every page in the document, and then all the text passages can be viewed as files in the folder. If you insert a picture in your document, you can create a small folder in the folder-the Pictures folder-and add a shortcut to the content of each page in the location where you use the picture. The following illustration shows the concept of a previous description (note-I don't see the source code for Office, which is just one of my little guesses):

COM interface for structured storage files

Just finished the concept, in COM, the IStorage interface is equivalent to the "folder" in the structured storage file, and the IStream interface is "file". Here is the IStorage interface:

MIDL_INTERFACE("0000000b-0000-0000-C000-000000000046")
IStorage : public IUnknown
{

Public

Virtual HRESULT stdmethodcalltype createstream (


/* [string][in] * * __rpc__in const OLECHAR *pwcsname,


/* [in]/DWORD Grfmode,


/* [in]/DWORD reserved1,


/* [in]/DWORD reserved2,


/* [out] */__rpc__deref_out_opt IStream **ppstm) = 0;





Virtual * * [local]/HRESULT stdmethodcalltype openstream (


/* [string][in]/const OLECHAR *pwcsname,


/* [unique][in]/void *reserved1,


/* [in]/DWORD Grfmode,


/* [in]/DWORD reserved2,


/* [out] */IStream **ppstm) = 0;





Virtual HRESULT stdmethodcalltype createstorage (


/* [string][in] * * __rpc__in const OLECHAR *pwcsname,


/* [in]/DWORD Grfmode,


/* [in]/DWORD reserved1,


/* [in]/DWORD reserved2,


/* [out] */__rpc__deref_out_opt istorage **ppstg) = 0;





Virtual HRESULT stdmethodcalltype openstorage (


/* [string][unique][in] * * __rpc__in_opt const OLECHAR *pwcsname,


/* [unique][in] * * __rpc__in_opt istorage *pstgpriority,


/* [in]/DWORD Grfmode,


/* [unique][in] * * __rpc__deref_opt_in_opt SNB snbexclude,


/* [in]/DWORD reserved,


/* [out] */__rpc__deref_out_opt istorage **ppstg) = 0;





Virtual * * [local]/HRESULT stdmethodcalltype CopyTo (


/* [in]/DWORD ciidexclude,


/* [size_is][unique][in]/const IID *rgiidexclude,


/* [unique][in] * * SNB snbexclude,


/* [unique][in] */istorage *pstgdest) = 0;





Virtual HRESULT stdmethodcalltype moveelementto (


/* [string][in] * * __rpc__in const OLECHAR *pwcsname,


/* [unique][in] * * __rpc__in_opt istorage *pstgdest,


/* [string][in] * * __rpc__in const OLECHAR *pwcsnewname,


/* [in]/DWORD grfflags = 0;





Virtual HRESULT stdmethodcalltype Commit (


/* [in]/DWORD grfcommitflags = 0;





Virtual HRESULT stdmethodcalltype Revert (void) = 0;





Virtual/* [local]/HRESULT stdmethodcalltype enumelements (


/* [in]/DWORD reserved1,


/* [size_is][unique][in]/void *reserved2,


/* [in]/DWORD reserved3,


/* [out] */IENUMSTATSTG **ppenum) = 0;





Virtual HRESULT stdmethodcalltype destroyelement (


/* [string][in] * * __rpc__in const OLECHAR *pwcsname) = 0;





Virtual HRESULT stdmethodcalltype renameelement (


/* [string][in] * * __rpc__in const OLECHAR *pwcsoldname,


/* [string][in] * * __rpc__in const OLECHAR *pwcsnewname) = 0;





Virtual HRESULT stdmethodcalltype setelementtimes (


/* [string][unique][in] * * __rpc__in_opt const OLECHAR *pwcsname,


/* [unique][in] * * __rpc__in_opt const FILETIME *pctime,


/* [Unique][in] * * __rpc__in_opt const FILETIME *patime,


/* [unique][in] * * __rpc__in_opt const FILETIME *pmtime) = 0;





Virtual HRESULT stdmethodcalltype setclass (


/* [in] */__rpc__in refclsid clsid) = 0;





Virtual HRESULT stdmethodcalltype setstatebits (


/* [in]/DWORD grfstatebits,


/* [in]/DWORD grfmask = 0;





Virtual HRESULT stdmethodcalltype Stat (


/* [out] */__rpc__out STATSTG *PSTATSTG,


/* [in]/DWORD grfstatflag = 0;


};

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.