본문 바로가기
Delphi Tip/+Tip

윈도우버전별 바탕화면 경로 알아내기

by MonoSoft 2022. 3. 28.
728x90
반응형

윈도우버전별 바탕화면 경로 알아내기

 

uses ShFolder,ShlObj;

 

function GetSystemDirectory(Dir: Integer): String;

var

Path: PChar;

begin

Result:='';

GetMem(Path, MAX_PATH);

SHGetFolderPath(0, Dir, 0, 0, Path);

Result:=Copy(Path, 0, Length(Path));

FreeMem(Path);

end;

 

사용 예제

var

path : String

begin

path := GetSystemDirectory(CSIDL_PROFILE);

end;

 

--------------------------------------------------------------------------------------------------

unit Winapi.ShlObj;

...

CSIDL_DESKTOP = $0000; // <desktop>

{$EXTERNALSYM CSIDL_DESKTOP}

CSIDL_INTERNET = $0001; // Internet Explorer (icon on desktop)

{$EXTERNALSYM CSIDL_INTERNET}

CSIDL_PROGRAMS = $0002; // Start Menu\Programs

{$EXTERNALSYM CSIDL_PROGRAMS}

CSIDL_CONTROLS = $0003; // My Computer\Control Panel

{$EXTERNALSYM CSIDL_CONTROLS}

CSIDL_PRINTERS = $0004; // My Computer\Printers

{$EXTERNALSYM CSIDL_PRINTERS}

CSIDL_PERSONAL = $0005; // My Documents

{$EXTERNALSYM CSIDL_PERSONAL}

CSIDL_FAVORITES = $0006; // <user name>\Favorites

{$EXTERNALSYM CSIDL_FAVORITES}

CSIDL_STARTUP = $0007; // Start Menu\Programs\Startup

{$EXTERNALSYM CSIDL_STARTUP}

CSIDL_RECENT = $0008; // <user name>\Recent

{$EXTERNALSYM CSIDL_RECENT}

CSIDL_SENDTO = $0009; // <user name>\SendTo

{$EXTERNALSYM CSIDL_SENDTO}

CSIDL_BITBUCKET = $000a; // <desktop>\Recycle Bin

{$EXTERNALSYM CSIDL_BITBUCKET}

CSIDL_STARTMENU = $000b; // <user name>\Start Menu

{$EXTERNALSYM CSIDL_STARTMENU}

CSIDL_MYDOCUMENTS = CSIDL_PERSONAL; // Personal was just a silly name for My Documents

{$EXTERNALSYM CSIDL_MYDOCUMENTS}

CSIDL_MYMUSIC = $000d; // "My Music" folder

{$EXTERNALSYM CSIDL_MYMUSIC}

CSIDL_MYVIDEO = $000e; // "My Videos" folder

{$EXTERNALSYM CSIDL_MYVIDEO}

CSIDL_DESKTOPDIRECTORY = $0010; // <user name>\Desktop

{$EXTERNALSYM CSIDL_DESKTOPDIRECTORY}

CSIDL_DRIVES = $0011; // My Computer

{$EXTERNALSYM CSIDL_DRIVES}

CSIDL_NETWORK = $0012; // Network Neighborhood (My Network Places)

{$EXTERNALSYM CSIDL_NETWORK}

CSIDL_NETHOOD = $0013; // <user name>\nethood

{$EXTERNALSYM CSIDL_NETHOOD}

CSIDL_FONTS = $0014; // windows\fonts

{$EXTERNALSYM CSIDL_FONTS}

CSIDL_TEMPLATES = $0015;

{$EXTERNALSYM CSIDL_TEMPLATES}

CSIDL_COMMON_STARTMENU = $0016; // All Users\Start Menu

{$EXTERNALSYM CSIDL_COMMON_STARTMENU}

CSIDL_COMMON_PROGRAMS = $0017; // All Users\Start Menu\Programs

{$EXTERNALSYM CSIDL_COMMON_PROGRAMS}

CSIDL_COMMON_STARTUP = $0018; // All Users\Startup

{$EXTERNALSYM CSIDL_COMMON_STARTUP}

CSIDL_COMMON_DESKTOPDIRECTORY = $0019; // All Users\Desktop

{$EXTERNALSYM CSIDL_COMMON_DESKTOPDIRECTORY}

CSIDL_APPDATA = $001a; // <user name>\Application Data

{$EXTERNALSYM CSIDL_APPDATA}

CSIDL_PRINTHOOD = $001b; // <user name>\PrintHood

{$EXTERNALSYM CSIDL_PRINTHOOD}

CSIDL_LOCAL_APPDATA = $001c; // <user name>\Local Settings\Applicaiton Data (non roaming)

{$EXTERNALSYM CSIDL_LOCAL_APPDATA}

CSIDL_ALTSTARTUP = $001d; // non localized startup

{$EXTERNALSYM CSIDL_ALTSTARTUP}

CSIDL_COMMON_ALTSTARTUP = $001e; // non localized common startup

{$EXTERNALSYM CSIDL_COMMON_ALTSTARTUP}

CSIDL_COMMON_FAVORITES = $001f;

{$EXTERNALSYM CSIDL_COMMON_FAVORITES}

CSIDL_INTERNET_CACHE = $0020;

{$EXTERNALSYM CSIDL_INTERNET_CACHE}

CSIDL_COOKIES = $0021;

{$EXTERNALSYM CSIDL_COOKIES}

CSIDL_HISTORY = $0022;

{$EXTERNALSYM CSIDL_HISTORY}

CSIDL_COMMON_APPDATA = $0023; // All Users\Application Data

{$EXTERNALSYM CSIDL_COMMON_APPDATA}

CSIDL_WINDOWS = $0024; // GetWindowsDirectory()

{$EXTERNALSYM CSIDL_WINDOWS}

CSIDL_SYSTEM = $0025; // GetSystemDirectory()

{$EXTERNALSYM CSIDL_SYSTEM}

CSIDL_PROGRAM_FILES = $0026; // C:\Program Files

{$EXTERNALSYM CSIDL_PROGRAM_FILES}

CSIDL_MYPICTURES = $0027; // C:\Program Files\My Pictures

{$EXTERNALSYM CSIDL_MYPICTURES}

CSIDL_PROFILE = $0028; // USERPROFILE

{$EXTERNALSYM CSIDL_PROFILE}

CSIDL_SYSTEMX86 = $0029; // x86 system directory on RISC

{$EXTERNALSYM CSIDL_SYSTEMX86}

CSIDL_PROGRAM_FILESX86 = $002a; // x86 C:\Program Files on RISC

{$EXTERNALSYM CSIDL_PROGRAM_FILESX86}

CSIDL_PROGRAM_FILES_COMMON = $002b; // C:\Program Files\Common

{$EXTERNALSYM CSIDL_PROGRAM_FILES_COMMON}

CSIDL_PROGRAM_FILES_COMMONX86 = $002c; // x86 Program Files\Common on RISC

{$EXTERNALSYM CSIDL_PROGRAM_FILES_COMMONX86}

CSIDL_COMMON_TEMPLATES = $002d; // All Users\Templates

{$EXTERNALSYM CSIDL_COMMON_TEMPLATES}

CSIDL_COMMON_DOCUMENTS = $002e; // All Users\Documents

{$EXTERNALSYM CSIDL_COMMON_DOCUMENTS}

CSIDL_COMMON_ADMINTOOLS = $002f; // All Users\Start Menu\Programs\Administrative Tools

{$EXTERNALSYM CSIDL_COMMON_ADMINTOOLS}

CSIDL_ADMINTOOLS = $0030; // <user name>\Start Menu\Programs\Administrative Tools

{$EXTERNALSYM CSIDL_ADMINTOOLS}

CSIDL_CONNECTIONS = $0031; // Network and Dial-up Connections

{$EXTERNALSYM CSIDL_CONNECTIONS}

CSIDL_COMMON_MUSIC = $0035; // All Users\My Music

{$EXTERNALSYM CSIDL_COMMON_MUSIC}

CSIDL_COMMON_PICTURES = $0036; // All Users\My Pictures

{$EXTERNALSYM CSIDL_COMMON_PICTURES}

CSIDL_COMMON_VIDEO = $0037; // All Users\My Video

{$EXTERNALSYM CSIDL_COMMON_VIDEO}

CSIDL_RESOURCES = $0038; // Resource Direcotry

{$EXTERNALSYM CSIDL_RESOURCES}

CSIDL_RESOURCES_LOCALIZED = $0039; // Localized Resource Direcotry

{$EXTERNALSYM CSIDL_RESOURCES_LOCALIZED}

CSIDL_COMMON_OEM_LINKS = $003a; // Links to All Users OEM specific apps

{$EXTERNALSYM CSIDL_COMMON_OEM_LINKS}

CSIDL_CDBURN_AREA = $003b; // USERPROFILE\Local Settings\Application Data\Microsoft\CD Burning

{$EXTERNALSYM CSIDL_CDBURN_AREA}

// unused 0x003c

CSIDL_COMPUTERSNEARME = $003d; // Computers Near Me (computered from Workgroup membership)

{$EXTERNALSYM CSIDL_COMPUTERSNEARME}

CSIDL_FLAG_CREATE = $8000; // combine with CSIDL_ value to force folder creation in SHGetFolderPath()

{$EXTERNALSYM CSIDL_FLAG_CREATE}

CSIDL_FLAG_DONT_VERIFY = $4000; // combine with CSIDL_ value to return an unverified folder path

{$EXTERNALSYM CSIDL_FLAG_DONT_VERIFY}

CSIDL_FLAG_DONT_UNEXPAND = $2000; // combine with CSIDL_ value to avoid unexpanding environment variables

{$EXTERNALSYM CSIDL_FLAG_DONT_UNEXPAND}

CSIDL_FLAG_NO_ALIAS = $1000; // combine with CSIDL_ value to insure non-alias versions of the pidl

{$EXTERNALSYM CSIDL_FLAG_NO_ALIAS}

CSIDL_FLAG_PER_USER_INIT = $0800; // combine with CSIDL_ value to indicate per-user init (eg. upgrade)

{$EXTERNALSYM CSIDL_FLAG_PER_USER_INIT}

CSIDL_FLAG_MASK = $FF00; // mask for all possible flag values

{$EXTERNALSYM CSIDL_FLAG_MASK

728x90
반응형

댓글