| 
注册时间2005-7-5
阅读权限20
最后登录1970-1-1UID2261 以武会友  
 
 TA的每日心情|  | 开心 2019-9-19 16:05
 | 
|---|
 签到天数: 4 天 [LV.2]偶尔看看I | 
 
| 在网上找不到比较全的,干脆自己做,现贡献出来。 
 unit Utils;
 
 interface
 
 uses
 Windows, SysUtils, ShlObj;
 
 type
 TSpecialFolder = (
 sfDesktop,                // <desktop>
 sfInternet,               // Internet Explorer (icon on desktop)
 sfPrograms,               // Start Menu\Programs
 sfControls,               // My Computer\Control Panel
 sfPrinters,               // My Computer\Printers
 sfPersonal,               // My Documents
 sfFavorites,              // <user name>\Favorites
 sfStartup,                // Start Menu\Programs\Startup
 sfRecent,                 // <user name>\Recent
 sfSendTo,                 // <user name>\SendTo
 sfBitBucket,              // <desktop>\Recycle Bin
 sfStartMenu,              // <user name>\Start Menu
 sfMyDocuments,            // logical "My Documents" desktop icon
 sfMyMusic,                // "My Music" folder
 sfMyVideo,                // "My Videos" folder
 sfDesktopDirectory,       // <user name>\Desktop
 sfDrives,                 // My Computer
 sfNetwork,                // Network Neighborhood (My Network Places)
 sfNethood,                // <user name>\nethood
 sfFonts,                  // windows\fonts
 sfTemplates,              // <user name>\Templates
 sfCommonStartMenu,        // All Users\Start Menu
 sfCommonPrograms,         // All Users\Start Menu\Programs
 sfCommonStartup,          // All Users\Startup
 sfCommonDesktopDirectory, // All Users\Desktop
 sfAppData,                // <user name>\Application Data
 sfPrinthood,              // <user name>\PrintHood
 sfLocalAppData,           // <user name>\Local Settings\Applicaiton Data (non roaming)
 sfALTStartup,             // non localized startup
 sfCommonALTStartup,       // non localized common startup
 sfCommonFavorites,        // All Users\Favorites
 sfInternetCache,          // <user name>\Local Settings\Temporary Internet Files
 sfCookies,                // <user name>\Cookies
 sfHistory,                // <user name>\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,             // <user name>\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, $0029, $002a, $002b, $002c, $002d, $002e, $002f,
 $0030, $0031, $0035, $0036, $0037, $0038, $0039, $003a, $003b, $003d);
 
 var
 ItemIDList: PItemIDList;
 Buffer: array [0..MAX_PATH] of Char;
 begin
 SHGetSpecialFolderLocation(0, SpecialFolderValues[SpecialFolder], ItemIDList);
 SHGetPathFromIDList(ItemIDList, Buffer);
 Result := StrPas(Buffer);
 end;
 
 end.
 
 [ 本帖最后由 Moodsky 于 2007-2-8 10:10 编辑 ]
 | 
 |