开博科技|手机开单|手机商店|送货单打印软件|销售管理系统|进销存|ERP供应链管理系统

 找回密码
 加入我们
查看: 6638|回复: 0
打印 上一主题 下一主题

获取Windows系统特殊性目录路径

[复制链接]

740

主题

867

帖子

10万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
101951
QQ
跳转到指定楼层
楼主
发表于 2017-6-1 13:14:14 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
引用单元
  uses ShlObj

获取方法:
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;


参数可以为下面这些:

1    CSIDL_DESKTOP                 , { = $0000 }
2    CSIDL_INTERNET                , { = $0001 }
3    CSIDL_PROGRAMS                , { = $0002 }
4    CSIDL_CONTROLS                , { = $0003 }
5    CSIDL_PRINTERS                , { = $0004 }
6    CSIDL_PERSONAL                , { = $0005 }
7    CSIDL_FAVORITES               , { = $0006 }
8    CSIDL_STARTUP                 , { = $0007 }
9    CSIDL_RECENT                  , { = $0008 }
10   CSIDL_SENDTO                  , { = $0009 }
11   CSIDL_BITBUCKET               , { = $000a }
12   CSIDL_STARTMENU               , { = $000b }
13   CSIDL_MYDOCUMENTS             , { = $000c }
14    CSIDL_MYMUSIC                 , { = $000d }
15    CSIDL_MYVIDEO                 , { = $000e }
16    CSIDL_DESKTOPDIRECTORY        , { = $0010 }
17    CSIDL_DRIVES                  , { = $0011 }
18    CSIDL_NETWORK                 , { = $0012 }
19    CSIDL_NETHOOD                 , { = $0013 }
20    CSIDL_FONTS                   , { = $0014 }
21    CSIDL_TEMPLATES               , { = $0015 }
22    CSIDL_COMMON_STARTMENU        , { = $0016 }
23    CSIDL_COMMON_PROGRAMS         , { = $0017 }
24    CSIDL_COMMON_STARTUP          , { = $0018 }
25    CSIDL_COMMON_DESKTOPDIRECTORY , { = $0019 }
26    CSIDL_APPDATA                 , { = $001a }
27    CSIDL_PRINTHOOD               , { = $001b }
28    CSIDL_LOCAL_APPDATA           , { = $001c }
29    CSIDL_ALTSTARTUP              , { = $001d }
30    CSIDL_COMMON_ALTSTARTUP       , { = $001e }
31    CSIDL_COMMON_FAVORITES        , { = $001f }
32    CSIDL_INTERNET_CACHE          , { = $0020 }
33    CSIDL_COOKIES                 , { = $0021 }
34    CSIDL_HISTORY                 , { = $0022 }
35    CSIDL_COMMON_APPDATA          , { = $0023 }
36    CSIDL_WINDOWS                 , { = $0024 }
37    CSIDL_SYSTEM                  , { = $0025 }
38    CSIDL_PROGRAM_FILES           , { = $0026 }
39    CSIDL_MYPICTURES              , { = $0027 }
40    CSIDL_PROFILE                 , { = $0028 }
41    CSIDL_SYSTEMX86               , { = $0029 }
42    CSIDL_PROGRAM_FILESX86        , { = $002a }
43    CSIDL_PROGRAM_FILES_COMMON    , { = $002b }
44    CSIDL_PROGRAM_FILES_COMMONX86 , { = $002c }
45    CSIDL_COMMON_TEMPLATES        , { = $002d }
46    CSIDL_COMMON_DOCUMENTS        , { = $002e }
47    CSIDL_COMMON_ADMINTOOLS       , { = $002f }
48    CSIDL_ADMINTOOLS              , { = $0030 }
49    CSIDL_CONNECTIONS             , { = $0031 }
50    CSIDL_COMMON_MUSIC            , { = $0035 }
51    CSIDL_COMMON_PICTURES         , { = $0036 }
52    CSIDL_COMMON_VIDEO            , { = $0037 }
53    CSIDL_RESOURCES               , { = $0038 }
54    CSIDL_RESOURCES_LOCALIZED     , { = $0039 }
55    CSIDL_COMMON_OEM_LINKS        , { = $003a }
56    CSIDL_CDBURN_AREA             , { = $003b }
57    CSIDL_COMPUTERSNEARME         , { = $003d }
58    CSIDL_PROFILES                  { = $003e }


对应结果(WIN7操作系统):
0: C:\Users\zhubk\Desktop
2: C:\Users\zhubk\AppData\Roaming\Microsoft\Windows\Start Menu\Programs
5: C:\Users\zhubk\Documents
6: C:\Users\zhubk\Favorites
7: C:\Users\zhubk\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
8: C:\Users\zhubk\AppData\Roaming\Microsoft\Windows\Recent
9: C:\Users\zhubk\AppData\Roaming\Microsoft\Windows\SendTo
11: C:\Users\zhubk\AppData\Roaming\Microsoft\Windows\Start Menu
13: C:\Users\zhubk\Music
14: C:\Users\zhubk\Videos
16: C:\Users\zhubk\Desktop
19: C:\Users\zhubk\AppData\Roaming\Microsoft\Windows\Network Shortcuts
20: C:\Windows\Fonts
21: C:\Users\zhubk\AppData\Roaming\Microsoft\Windows\Templates
22: C:\ProgramData\Microsoft\Windows\Start Menu
23: C:\ProgramData\Microsoft\Windows\Start Menu\Programs
24: C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup
25: C:\Users\Public\Desktop
26: C:\Users\zhubk\AppData\Roaming
27: C:\Users\zhubk\AppData\Roaming\Microsoft\Windows\Printer Shortcuts
28: C:\Users\zhubk\AppData\Local
29: C:\Users\zhubk\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
30: C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup
31: C:\Users\zhubk\Favorites
32: C:\Users\zhubk\AppData\Local\Microsoft\Windows\Temporary Internet Files
33: C:\Users\zhubk\AppData\Roaming\Microsoft\Windows\Cookies
34: C:\Users\zhubk\AppData\Local\Microsoft\Windows\History
35: C:\ProgramData
36: C:\Windows
37: C:\Windows\System32
38: C:\Program Files
39: C:\Users\zhubk\Pictures
40: C:\Users\zhubk
41: C:\Windows\System32
42: C:\Program Files
43: C:\Program Files\Common Files
44: C:\Program Files\Common Files
45: C:\ProgramData\Microsoft\Windows\Templates
46: C:\Users\Public\Documents
47: C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Administrative Tools
48: C:\Users\zhubk\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Administrative Tools
53: C:\Users\Public\Music
54: C:\Users\Public\Pictures
55: C:\Users\Public\Videos
56: C:\Windows\Resources
59: C:\Users\zhubk\AppData\Local\Microsoft\Windows\Burn\Burn


import fsys;
import console;

console.log( fsys.getSpecial(0x5 /*_CSIDL_MYDOCUMENTS*/,"/../../" )  )
//  XP: C:\Document and Settings  
//WIN7: C:\Users
//表示“我的文档”桌面项的虚拟文件夹。

console.log( fsys.getSpecial(0x2e /*_CSIDL_COMMON_DOCUMENTS*/,"/../" )  )
//  XP: C:\Document and Settings\All Users
//WIN7: C:\ProgramData
//包含所有用户所共用文档的文件系统目录。

console.log( fsys.getSpecial(0x23 /*_CSIDL_COMMON_APPDATA*/) )
//  XP: C:\Document and Settings\All Users\Application Data
//WIN7: C:\ProgramData
//包含所有用户的应用程序数据的文件系统目录。

console.log( fsys.getSpecial(0x19 /*_CSIDL_COMMON_DESKTOPDIRECTORY*/) )
//  XP: C:\Document and Settings\All Users\desktop
//WIN7: C:\Users\Public\Desktop
//包含显示在所有用户的桌面上的文件和文件夹的文件系统目录。

console.log( fsys.getSpecial(0x2e /*_CSIDL_COMMON_DOCUMENTS*/) )
//  XP: C:\Document and Settings\All Users\Documents
//WIN7: C:\Users\Public\Documents
//包含所有用户所共用文档的文件系统目录。

console.log( fsys.getSpecial(0x1f/*_CSIDL_COMMON_FAVORITES*/) )
//  XP: C:\Document and Settings\All Users\Favorites
//WIN7: C:\Users\Public\Favorites
//作为所有用户所共用收藏夹项的公共储存库的文件系统目录。

console.log( fsys.getSpecial(0x2d /*_CSIDL_COMMON_TEMPLATES*/) )
//  XP: C:\Document and Settings\All Users\Templates
//WIN7: C:\ProgramData\Microsoft\Windows\Templates
//包含可用于所有用户的模板的文件系统目录。

console.log( fsys.getSpecial(0x16 /*_CSIDL_COMMON_STARTMENU*/) )
//  XP: C:\Document and Settings\All Users\「开始」菜单
//WIN7: C:\ProgramData\Microsoft\Windows\Start Menu
//包含在所有用户的“开始”菜单上出现的程序和文件夹的文件系统目录。

console.log( fsys.getSpecial(0x6 /*_CSIDL_FAVORITES*/) )
//  XP: C:\Document and Settings\All Users\收藏夹
//WIN7: C:\Users\Public\Favorites
//作为用户的收藏夹项的公共储存库的文件系统目录。

console.log( fsys.getSpecialDefault(0x1a /*_CSIDL_APPDATA*/) )
//  XP: C:\Document and Settings\Default Users\Application Data
//WIN7: C:\Users\Default\AppData\Roaming
//作为应用程序特定数据的公共储存库的文件系统目录。

console.log( fsys.getSpecialDefault(0x21/*_CSIDL_COOKIES*/) )
//  XP: C:\Document and Settings\Default Users\Cookies
//WIN7: C:\Users\Default\AppData\Roaming\Microsoft\Windows\Cookies
//作为 Internet Cookie 的公共储存库的文件系统目录。

console.log( fsys.getSpecialDefault(0x1c /*_CSIDL_LOCAL_APPDATA*/,"/../") )
//  XP: C:\Document and Settings\Default Users\Local Settings
//WIN7: C:\Users\Default\AppData\Local
//作为本地(非漫游)应用程序的数据储存库的文件系统目录。

console.log( fsys.getSpecialDefault(0x5 /*_CSIDL_MYDOCUMENTS*/) )
//  XP: C:\Document and Settings\Default Users\My Documents
//WIN7: C:\Users\Default\Documents
//表示“我的文档”桌面项的虚拟文件夹。

console.log( fsys.getSpecialDefault(0x13 /*_CSIDL_NETHOOD*/) )
//  XP: C:\Document and Settings\Default Users\NetHood
//WIN7: C:\Users\Default\AppData\Roaming\Microsoft\Windows\Network Shortcuts
//包含可能存在于“网络邻居”虚拟文件夹中的链接对象的文件系统目录。该目录不同于 CSIDL_NETWORK,后者表示的是网络命名空间根目录。

console.log( fsys.getSpecialDefault(0x1b /*_CSIDL_PRINTHOOD*/) )
//  XP: C:\Document and Settings\Default Users\PrintHood
//WIN7: C:\User\Default\AppData\Roaming\Microsoft\Windows\Printer Shortcuts
//含可能存在于“打印机”虚拟文件夹中的链接对象的文件系统目录。

console.log( fsys.getSpecialDefault(0x8 /*_CSIDL_RECENT*/) )
//  XP: C:\Document and Settings\Default Users\Recent
//WIN7: C:\User\Default\AppData\Roaming\Microsoft\Windows\Recent
//包含指向用户最近使用文档的快捷方式的文件系统目录。

console.log( fsys.getSpecialDefault(0x9 /*_CSIDL_SENDTO*/) )
//  XP: C:\Document and Settings\Default Users\SendTo
//WIN7: C:\User\Default\AppData\Roaming\Microsoft\Windows\SendTo
//包含“发送到”菜单项的文件系统目录。

console.log( fsys.getSpecialDefault(0xb /*_CSIDL_STARTMENU*/) )
//  XP: C:\Document and Settings\Default Users\Start Menu
//WIN7: C:\User\Default\AppData\Roaming\Microsoft\Windows\Start Menu
//包含“开始”菜单项的文件系统目录。

console.log( fsys.getSpecialDefault(0x15/*_CSIDL_TEMPLATES*/) )
//  XP: C:\Document and Settings\Default Users\Templates
//WIN7: C:\User\Default\AppData\Roaming\Microsoft\Windows\Templates
//作为文档模板的公共储存库的文件系统目录。

console.log( fsys.getSpecialDefault(0xd /*_CSIDL_MYMUSIC*/) )
//  XP: C:\Document and Settings\Default Users\My Documents\My Music
//WIN7: C:\Users\Public\Music
//作为音乐文件的公共储存库的文件系统目录。

console.log( fsys.getSpecialDefault(0x27 /*_CSIDL_MYPICTURES*/) )
//  XP: C:\Document and Settings\Default Users\My Documents\My Pictures
//WIN7: C:\Users\Public\Pictures
//作为图像文件的公共储存库的文件系统目录。

console.log( fsys.getSpecialDefault(0xe /*_CSIDL_MYVIDEO*/) )
//  XP: C:\Document and Settings\Default Users\My Documents\My Videos
//WIN7: C:\Users\Public\Videos
//作为视频文件的公共储存库的文件系统目录。

console.log( fsys.getSpecial(0x1a /*_CSIDL_APPDATA*/) )
//  XP: C:\Document and Settings\用户名\Application Data
//WIN7: C:\Users\用户名\AppData\Roaming
//作为应用程序特定数据的公共储存库的文件系统目录。

console.log( fsys.getSpecial( 0x21/*_CSIDL_COOKIES*/) )
//  XP: C:\Document and Settings\用户名\Cookies
//WIN7: C:\Users\用户名\AppData\Roaming\Microsoft\Windows\Cookies
//作为 Internet Cookie 的公共储存库的文件系统目录。

console.log( fsys.getSpecial(0x1c /*_CSIDL_LOCAL_APPDATA*/,"/../") )
//  XP: C:\Document and Settings\用户名\Local Settings
//WIN7: C:\Users\用户名\AppData\Local
//作为本地(非漫游)应用程序的数据储存库的文件系统目录。

console.log( fsys.getSpecial(0x5 /*_CSIDL_MYDOCUMENTS*/) )
//  XP: C:\Document and Settings\用户名\My Documents
//WIN7: C:\Users\用户名\Documents
//表示“我的文档”桌面项的虚拟文件夹。

console.log( fsys.getSpecial(0x13 /*_CSIDL_NETHOOD*/) )
//  XP: C:\Document and Settings\用户名\NetHood
//WIN7: C:\Users\用户名\AppData\Roaming\Microsoft\Windows\Network Shortcuts
//包含可能存在于“网络邻居”虚拟文件夹中的链接对象的文件系统目录。该目录不同于 CSIDL_NETWORK,后者表示的是网络命名空间根目录。

console.log( fsys.getSpecial(0x1b /*_CSIDL_PRINTHOOD*/) )
//  XP: C:\Document and Settings\用户名\PrintHood
//WIN7: C:\User\用户名\AppData\Roaming\Microsoft\Windows\Printer Shortcuts
//含可能存在于“打印机”虚拟文件夹中的链接对象的文件系统目录。

console.log( fsys.getSpecial(0x8 /*_CSIDL_RECENT*/) )
//  XP: C:\Document and Settings\用户名\Recent
//WIN7: C:\User\用户名\AppData\Roaming\Microsoft\Windows\Recent
//包含指向用户最近使用文档的快捷方式的文件系统目录。

console.log( fsys.getSpecial(0x9 /*_CSIDL_SENDTO*/) )
//  XP: C:\Document and Settings\用户名\SendTo
//WIN7: C:\User\用户名\AppData\Roaming\Microsoft\Windows\SendTo
//包含“发送到”菜单项的文件系统目录。

console.log( fsys.getSpecial(0x15/*_CSIDL_TEMPLATES*/) )
//  XP: C:\Document and Settings\用户名\Templates
//WIN7: C:\User\用户名\AppData\Roaming\Microsoft\Windows\Templates
//作为文档模板的公共储存库的文件系统目录

console.log( fsys.getSpecial(0xb /*_CSIDL_STARTMENU*/) )
//  XP: C:\Document and Settings\用户名\「开始」菜单
//WIN7: C:\User\用户名\AppData\Roaming\Microsoft\Windows\Start Menu
//包含“开始”菜单项的文件系统目录。

console.log( fsys.getSpecial(0x22/*_CSIDL_HISTORY*/) )
//  XP: C:\Document and Settings\用户名\Local Settings\History
//WIN7: C:\Users\用户名\AppData\Local\Microsoft\Windows\History
//作为 Internet 历史记录项的公共储存库的文件系统目录

console.log( fsys.getSpecial(0x20/*_CSIDL_INTERNET_CACHE*/) )
//  XP: C:\Document and Settings\用户名\Local Settings\Temporary Internet Files
//WIN7: C:\Users\用户名\AppData\Local\Microsoft\Windows\Temporary Internet Files
//作为临时 Internet 文件的公共储存库的文件系统目录


更详细的开发和使用信息,请使用以下联系方式联系我司:
电话:0757-83994417、13929988706、18923101227
QQ:800183189、3190115、29286113

邮箱:admin@757abc.com
您需要登录后才可以回帖 登录 | 加入我们

本版积分规则

QQ|Archiver|手机版|小黑屋|开博维尔科技有限公司 ( 粤ICP备13070897号 )

GMT+8, 2024-4-20 02:46 , Processed in 0.091549 second(s), 24 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表