SHGetSpecialFolderPath
Retrieves the path of a special folder, identified by its CSIDL.
BOOL SHGetSpecialFolderPath(
HWND hwndOwner,
LPTSTR lpszPath,
int nFolder,
BOOL fCreate
);
获取系统桌面的文件夹的路径 |
char szPath[MAX_PATH]; SHGetSpecialFolderPath( NULL, szPath, CSIDL_DESKTOP, false ); CString s; s.Format("%s",szPath); SetWindowText( s );
效果图: |
SHGetPathFromIDList
Converts an item identifier list to a file system path.
BOOL SHGetPathFromIDList(
LPCITEMIDLIST pidl,
LPSTR pszPath
);
获取系统桌面的文件夹的路径 写法2 |
LPITEMIDLIST lpItemIdList; TCHAR szPath[MAX_PATH]; ::SHGetSpecialFolderLocation( NULL, CSIDL_DESKTOP, &lpItemIdList ); ::SHGetPathFromIDList(lpItemIdList, szPath); SetWindowText( szPath ); 效果图: |
ID | nFolder | 文件夹 | 路径 |
1 | CSIDL_DESKTOP | 桌面 | C:\Users\Administrator\Desktop |
2 | CSIDL_INTERNET | | |
3 | CSIDL_PROGRAMS | | C:\Users\Administrator\AppData\Roaming\Microsoft\Windows\Start Menu\Programs |
4 | CSIDL_CONTROLS | | |
5 | CSIDL_PRINTERS | | |
6 | CSIDL_PERSONAL | 我的文档 | D:\Administrator\Documents |
7 | CSIDL_FAVORITES | | D:\Administrator\Favorites |
8 | CSIDL_STARTUP | | C:\Users\Administrator\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup |
9 | CSIDL_RECENT | | C:\Users\Administrator\AppData\Roaming\Microsoft\Windows\Recent |
10 | CSIDL_SENDTO | | C:\Users\Administrator\AppData\Roaming\Microsoft\Windows\SendTo |
11 | CSIDL_BITBUCKET | | |
12 | CSIDL_STARTMENU | | |
13 | CSIDL_DESKTOPDIRECTORY | | |
14 | CSIDL_DRIVES | | C:\Users\Administrator\AppData\Roaming\Microsoft\Windows\Start Menu |
15 | CSIDL_NETWORK | | |
16 | CSIDL_NETHOOD | 网络邻居 | C:\Users\Administrator\AppData\Roaming\Microsoft\Windows\Network Shortcuts |
17 | CSIDL_FONTS | | C:\Windows\Fonts |
18 | CSIDL_TEMPLATES | | C:\Users\Administrator\AppData\Roaming\Microsoft\Windows\Templates |
19 | CSIDL_COMMON_STARTMENU | | C:\ProgramData\Microsoft\Windows\Start Menu |
20 | CSIDL_COMMON_PROGRAMS | 开始菜单 | C:\ProgramData\Microsoft\Windows\Start Menu\Programs |
21 | CSIDL_COMMON_STARTUP | | C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup |
22 | CSIDL_COMMON_DESKTOPDIRECTORY | | C:\Users\Public\Desktop |
23 | CSIDL_APPDATA | | C:\Users\Administrator\AppData\Roaming |
24 | CSIDL_PRINTHOOD | | C:\Users\Administrator\AppData\Roaming\Microsoft\Windows\Printer Shortcuts |
25 | CSIDL_ALTSTARTUP | 启动 | C:\Users\Administrator\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup |
26 | CSIDL_COMMON_ALTSTARTUP | | C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup |
27 | CSIDL_COMMON_FAVORITES | | D:\Administrator\Favorites |
28 | CSIDL_INTERNET_CACHE | IE临时 | C:\Users\Administrator\AppData\Local\Microsoft\Windows\Temporary Internet Files |
29 | CSIDL_COOKIES | | C:\Users\Administrator\AppData\Roaming\Microsoft\Windows\Cookies |
30 | CSIDL_HISTORY | | C:\Users\Administrator\AppData\Local\Microsoft\Windows\History |
31 | 36 | Windows目录 | C:\Windows |
32 | 37 | System32 | C:\Windows\System32 |
33 | | | |
34 | | | |
35 | | | |
36 | | | |