Use csidl to open a special folder

Source: Internet
Author: User

Csidl description and instructions for use:
Csidl indicates the Identifier value of a special folder in Windows Shell. The special folder here refers to the folder defined by Windows Shell, for example, "My documents", "recycle bin ", "Inernet cache folder" is a special folder specified by shell. these special folders can be physical paths on a disk or virtual folders )!
Note: Virtual folder
A virtual folder is a folder defined by Windows shell, but it does not correspond to any physical path on your computer. for example, "my computer" is a virtual folder containing all the drives, and "Control Panel" is also a virtual folder. Virtual folders are rarely used in non-Shell functions.
In Windows2000/NT, many csidl-related folders are for each user. However, similar to csidl_common _ *, it can be used by all users.

In many applications, a csidl can be combined with one of the following identifiers:

Csidl_flag_create ($8000)
Windows 2000: If the folder referenced by csidl does not exist, create this folder !.
Csidl_flag_dont_verify ($4000)
Windows 2000: whether the folder referenced by csidl exists or not, use it!

Csidl_admintools ($30)
Indicates the "Administrative Tools" system folder of the current user.
Csidl_altstartup ($ h1d)
Unknown
Csidl_appdata ($ 1a)
Indicates the specific application of the current user. Program Data storage folder, for example: C: \ Documents ents and Settings \ USERNAME \ Application Data
Csidl_bitbucket ($)
Indicates the recycle bin.
Csidl_common_admintools ($ 2f)
Indicates all users' "Administrative Tools" system folders
Csidl_common_altstartup ($ 1D)
Indicates all users (only Windows NT systems are supported)
Csidl_common_appdata ($23)
The data storage folder of all users' specific applications, such as c: \ Documents ents and Settings \ All Users \ Application Data.
Csidl_common_comment topdirectory ($19)
The "desktop" folder of all users, such as c: \ Documents ents and Settings \ All Users \ Desktop.
Csidl_common_documents ($ 2e)
Represents the "My Documents" folder of all users, for example, C: \ Documents and Settings \ All Users \ Documents
Csidl_common_favorites ($ 1f)
Represents the "My favorites" folder of all users.
Csidl_common_programs ($17)
Represents the "program" folder of all users, such as c: \ Documents ents and Settings \ All Users \ Start Menu \ Programs
Csidl_common_startmenu ($16)
The "Start Menu" folder of all users, for example, C: \ Documents ents and Settings \ All Users \ Start Menu.
Csidl_common_startup ($18)
Indicates the "Start" folder of all users, for example, C: \ Documents ents and Settings \ All Users \ Start Menu \ Programs \ Startup
Csidl_common_templates ($ 2d)
Indicates the "modules" folder of all users, such as c: \ Documents ents and Settings \ All Users \ templates.
Csidl_controls ($3)
Control Panel folder
Csidl_cookies ($21)
Indicates the cookie folder of Internet Explorer for the current user, for example: C: \ Documents ents and Settings \ USERNAME \ cookies
Csidl_desktop ($0)
Indicates the "desktop" virtual folder, which contains all the content on the computer.
Csidl_topics topdirectory ($10)
Indicates the current user's "desktop" folder, for example: C: \ Documents ents and Settings \ USERNAME \ Desktop
Csidl_drives ($11)
Represents the "my computer" virtual folder, containing all the drives on the computer
Csidl_favorites ($6)
Represents the current user's "favorites" folder, for example: C: \ Documents ents and Settings \ USERNAME \ favorites
Csidl_fonts ($14)
System font folder, for example, C: \ winnt \ Fonts
Csidl_history ($22)
Indicates the "history" folder of Inernet Explorer
Csidl_internet ($1)
Indicates the virtual folder on the Internet.
Csidl_internet_cache ($20)
Indicates the "cache" folder of the current user's Internet Explorer, for example, C: \ Documents ents and Settings \ USERNAME \ Temporary Internet Files
Csidl_local_appdata ($ 1c)
Indicates the application data folder of the current user, for example, C: \ Documents ents and Settings \ USERNAME \ Local Settings \ Application Data
Csidl_mymusic
The folder where the current user stores music files, for example, C: \ Administrative ents and Settings \ User \ My administrative ents \ my music.
Csidl_mypictures ($27)
Indicates the folder where the current user Stores image files, for example, C: \ Documents ents and Settings \ USERNAME \ My Documents ents \ my pictures
Csidl_nethood ($13)
Indicates the network connection folder of the current user, for example, C: \ Documents ents and Settings \ USERNAME \ nethood.
Csidl_network ($12)
Indicates the virtual folder "Network Neighbor"
Csidl_personal ($5)
Indicates the "My Documents" folder of the current user, for example, C: \ Documents and Settings \ USERNAME \ My Documents ents
Csidl_printers ($4)
Point to the virtual folder "Printer"
Csidl_printhood ($ 1b)
Indicates the virtual folder of the current user's network printer, for example: C: \ Documents ents and Settings \ USERNAME \ printhood
Csidl_profile ($28)
The folder of the current user configuration file
Csidl_program_files ($26)
The folder of the program file, for example, c: \ Program Files.
Csidl_program_files_common ($ 2B)
Indicates that system programs Share Component folders, for example, c: \ Program Files \ common
Csidl_programs ($2)
Indicates the current user's "program" menu folder, for example: C: \ Documents ents and Settings \ USERNAME \ Start Menu \ Programs
Csidl_recent ($8)
Indicates the "document" menu folder of the current user, for example, C: \ Documents ents and Settings \ USERNAME \ Start Menu \ Programs.
Csidl_sendto ($9)
Indicates the "sent" folder of the current user, for example, C: \ Documents ents and Settings \ USERNAME \ sendto
Csidl_startmenu ($ B)
Indicates the "Start" menu folder of the current user, for example, C: \ Documents ents and Settings \ USERNAME \ Start Menu.
Csidl_startup ($7)
Indicates the "Start" menu folder of the current user, for example: C: \ Documents ents and Settings \ USERNAME \ Start Menu \ Programs \ Startup
Csidl_system ($25)
Windows system folder, for example, C: \ winnt \ System32
Csidl_templates ($15)
Indicates the folder where the document module is stored in the system.
Csidl_windows ($24)
Indicates the files in the Windows directory in the system, for example, C: \ WINNT.

Csidl can be used in the following API functions. For the function description, refer to the API description in msdn:
Shgetfolderlocation, shgetfolderpath, shgetspecialfolderlocation, shgetspecialfolderpath

Let's look at the following example:
// Open some special folders and add ActiveX, shellapi, and shlobj units.
Uses ActiveX, shellapi, shlobj;
Function openspecialfolder (FLAG: integer; handle: hwnd = 0): Boolean;
// Here the flag is the csidl value of the folder we need to open
Procedure freepidl (pidl: pitemidlist); // release the pitemidlist instance.
VaR
Allocator: imalloc;
Begin
If succeeded (shlobj. shgetmalloc (Allocator) then
Begin
Allocator. Free (pidl );
{$ Ifdef ver90}
Allocator. release;
{$ Endif}
End;
End;
VaR
Exinfo: tshellexecuteinfo;
Begin
Fillchar (exinfo, sizeof (exinfo), 0); // set the initial value for exinfo
With exinfo do
Begin
Cbsize: = sizeof (exinfo );
Fmask: = see_mask_flag_ddewait or see_mask_idlist;
WND: = handle;
Nshow: = sw_shownormal;
Lpverb: = 'open ';
Shgetspecialfolderlocation (handle, flag, pitemidlist (lpidlist); // locate the folder specified by the csidl Value
End;
Shellexecuteex (@ exinfo); // open the folder
Freepidl (exinfo. lpidlist );
End;

// Call the function written above:
Procedure tform1.button5click (Sender: tobject );
Begin
Openspecialfolder ($0); // or openspecialfolder (csidl_desktop), open the "desktop" Window
End;
For how to configure csidl and other functions, refer to msdn!

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.