Use the shgetspecialfolderlocation and shgetpathfromidlist functions to obtain common paths.

Source: Internet
Author: User
In this example:


Code file:
Unit unit1; interfaceuses windows, messages, extensions, variants, classes, graphics, controls, forms, dialogs, stdctrls; Type tform1 = Class (tform) memo1: tmemo; Procedure formcreate (Sender: tobject); end; var form1: tform1; implementation {$ R *. DFM} uses shlobj; {shgetspecialfolderlocation, shgetpathfromidlist function from this unit} {function for obtaining common paths} function getpath (FID: integer): string; var pidl: pitemidlist; Path: array [0 .. max_path] of char; begin shgetspecialfolderlocation (0, FID, pidl); shgetpathfromidlist (pidl, PATH); Result: = path; end; {during testing, I defined the parameters required by the shgetspecialfolderlocation function as a constant array} const arr: array [0 .. 57] of integer = (csidl_desktop, {=$ 0000} csidl_internet, {=$ 0001} csidl_programs, {=$ 0002} csidl_controls, {=$ 0003} csidl_printers, {=$ 0004} csidl_personal, {=$ 0005} csidl_favorites, {=$ 0006} csidl_startup, {=$ 0007} csidl_recent, {=$ 0008} csidl_sendto, {= $0009} csidl_bitbucket, {=$ 000a} csidl_startmenu, {=$ 000b} csidl_mydocuments, {=$ 000c} csidl_mymusic, {=$ 000d} csidl_myvideo, {= $ 000e} csidl_shorttopdirectory, {=$ 0010} csidl_drives, {=$ 0011} csidl_network, {=$ 0012} csidl_nethood, {=$ 0013} csidl_fonts, {=$ 0014} csidl_templates, {=$ 0015} csidl_common_startmenu, {=$ 0016} groups, {=$ 0017} csidl_common_startup, {=$ 0018} csidl_common_comment topdirectory, {=$ 0019} csidl_appdata, {=$ 001a} csidl_printhood, {=$ 001b} csidl_local_appdata, {=$ 001c} csidl_altstartup, {=$ 001d} timeout, {=$ 001e} caching, {=$ 001f} csidl_internet_cache, {=$ 0020} csidl_cookies, {=$ 0021} csidl_history, {=$ 0022} csidl_common_appdata, {= $0023} csidl_windows, {=$ 0024} csidl_system, {=$ 0025} csidl_program_files, {=$ 0026} csidl_mypictures, {=$ 0027} csidl_profile, {=$ 0028} csidl_systemx86, {=$ 0029} csidl_program_filesx86, {=$ 002a} csidl_program_files_common, {=$ 002b} partition, {=$ 002c} csidl_common_templates, {=$ 002d} libraries, {=$ 002e} csidl_common_admintools, {=$ 002f} csidl_admintools, {=$ 0030} csidl_connections, {=$ 0031} csidl_common_music, {=$ 0035} csidl_common_pictures, {=$ 0036} csidl_common_video, {=$ 0037} csidl_resources, {=$ 0038} csidl_resources_localized, {=$ 0039} bytes, {=$ 003a} csidl_cdburn_area, {=$ 003b} blocks, {=$ 003d} csidl_profiles {=$ 003e}); {test} procedure tform1.formcreate (Sender: tobject ); vaR I: integer; s: string; begin memo1.clear; for I: = 0 to length (ARR)-1 do begin S: = getpath (ARR [I]); if s ''then memo1.lines. add (format ('% d:' # 9' % s', [arr [I], S]); end.
 

Form file:

object Form1: TForm1  Left = 0  Top = 0  Caption = 'Form1'  ClientHeight = 318  ClientWidth = 465  Color = clBtnFace  Font.Charset = DEFAULT_CHARSET  Font.Color = clWindowText  Font.Height = -11  Font.Name = 'Tahoma'  Font.Style = []  OldCreateOrder = False  OnCreate = FormCreate  PixelsPerInch = 96  TextHeight = 13  object Memo1: TMemo    Left = 0    Top = 0    Width = 465    Height = 318    Align = alClient    Lines.Strings = (      'Memo1')    ScrollBars = ssBoth    TabOrder = 0    ExplicitWidth = 409  endend
 

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.