Get a Windows Special Folder Function

xiaoxiao2021-03-04  58

I can't find a more complete online, I'm doing it yourself.

Unit utils;

Interface

Uses Windows, Sysutils, Shlobj;

type TSpecialFolder = (sfDesktop, // sfInternet, // Internet Explorer (icon on desktop) sfPrograms, // Start Menu / Programs sfControls, // My Computer / Control Panel sfPrinters, // My Computer / Printers sfPersonal, / / My documents sffavorites, // / favorites sfstartup, // start menu / programs / startup sfrecent, // / recent sfsendto, // / sendto sfbitbugt, // / Recycle Bin sfStartMenu, // / Start Menu sfMyDocuments, // logical "My Documents" desktop icon sfMyMusic, // "My Music" folder sfMyVideo, // "My Videos" folder sfDesktopDirectory, // / Desktop sfdrives, // my computer sfnetwork, // network neighborhood (My Network PL aces) sfNethood, // / nethood sfFonts, // windows / fonts sfTemplates, // / Templates sfCommonStartMenu, // All Users / Start Menu sfCommonPrograms, // All Users / Start Menu / Programs sfCommonStartup , // all users / startup sfcommondesktopdirectory, // all users / desktop sfappdata, // / application data sfprinthood, // / printhood sflocalappdata, //

/ Local Settings / Applicaiton Data (non roaming) sfALTStartup, // non localized startup sfCommonALTStartup, // non localized common startup sfCommonFavorites, // All Users / Favorites sfInternetCache, // / Local Settings / Temporary Internet Files sfCookies, // / Cookies sfHistory, // / Local Settings / History sfCommonAppData, // All Users / Application Data sfWindows, // GetWindowsDirectory () sfSystem, // GetSystemDirectory () sfProgramFiles, // C: / Program Files sfMyPictures, // C: / Program Files / My Pictures sfProfile, // USERPROFILE sfSystemX86, // x86 system directory on RISC sfProgramFilesX86, // x86 C: / Program Files on RISC sfProgramFilesCommon, // C: / Program Files / Common sfprogramfilescommonx86, // x86 Program Files / Common On Risc SfcommonTemplates , // all users / templates sfcommondocuments, // all users / documents sfcommonadmintools, // all users / start menu / programs / administrative tools sfadmintools, //

/ Start Menu / Programs / Administrative Tools sfConnections, // Network and Dial-up Connections sfCommonMusic, // All Users / My Music sfCommonPictures, // All Users / My Pictures sfCommonVideo, // All Users / My Video sfResources, // Resource Direcotry sfResourcesLocalized, // Localized Resource Direcotry sfCommonOEMLinks, // Links to All Users OEM specific apps sfCDBurnArea, // USERPROFILE / Local Settings / Application Data / Microsoft / CD Burning sfComputersNearMe // Computers Near Me (computered from Workgroup membership)); function GetSpecialFolder (SpecialFolder: TspecialFolder): String;

IMPLEMentation

Function GetSpecialFolder (SpecialFolder: TspecialFolder): String;

const SpecialFolderValues: array [TSpecialFolder] of Integer = ($ 0000, $ 0001, $ 0002, $ 0003, $ 0004, $ 0005, $ 0006, $ 0007, $ 0008, $ 0009, $ 000a, $ 000b, $ 000c, $ 000d, $ 000e, $ 0010, $ 0011, $ 0012, $ 0013, $ 0014, $ 0015, $ 0016, $ 0017, $ 0018, $ 0019, $ 001a, $ 001b, $ 001c, $ 001d, $ 001e, $ 001f, $ 0020, $ 0021, $ 0022, $ 0023, $ 0024, $ 0025, $ 0026, $ 0027, $ 0028, $ 0037, $ 0033, $ 0033, $ 0033, $ 0033D)

var ItemIDList: PItemIDList; Buffer: array [0..MAX_PATH] of Char; begin SHGetSpecialFolderLocation (0, SpecialFolderValues ​​[SpecialFolder], ItemIDList); SHGetPathFromIDList (ItemIDList, Buffer); Result: = StrPas (Buffer); end;

End.

转载请注明原文地址:https://www.9cbs.com/read-31747.html

New Post(0)