vcpp获取系统特定目录的路径以及CSIDL值的定义

⌚Time: 2022-10-16 14:50:14

👨‍💻Author: Jack Ge


BOOL SHGetSpecialFolderPathA(

        HWND  hwnd,

  [out] LPSTR pszPath,

  [in]  int   csidl,

  [in]  BOOL  fCreate

);

Parameters

hwnd



Type: HWND



Reserved.



[out] pszPath



Type: LPTSTR



A pointer to a null-terminated string that receives the drive and path of the specified folder. This buffer must be at least MAX_PATH characters in size.



[in] csidl



Type: int



A CSIDL that identifies the folder of interest. If a virtual folder is specified, this function will fail.



[in] fCreate



Type: BOOL



Indicates whether the folder should be created if it does not already exist. If this value is nonzero, the folder is created. If this value is zero, the folder is not created.



Return value

Type: BOOL



TRUE if successful; otherwise, FALSE.



Remarks

The Microsoft Internet Explorer 4.0 Desktop Update must be installed for this function to be available.

头文件shlobj.h

CSIDL_BITBUCKET 回收站

CSIDL_CONTROLS 控制面板

CSIDL_DESKTOP Windows 桌面Desktop

CSIDL_DESKTOPDIRECTORY Desktop的目录

CSIDL_DRIVES 我的电脑

CSIDL_FONTS 字体目录

CSIDL_NETHOOD 网上邻居

CSIDL_NETWORK 网上邻居虚拟目录

CSIDL_PERSONAL 我的文档

CSIDL_PRINTERS 打印机

CSIDL_PROGRAMS 程序组

CSIDL_RECENT 最近打开的文档

CSIDL_SENDTO “发送到”菜单项

CSIDL_STARTMENU 任务条启动菜单项

CSIDL_STARTUP 启动目录

CSIDL_TEMPLATES 文档模板


TCHAR MyDir[_MAX_PATH];  

SHGetSpecialFolderPath(this->GetSafeHwnd(),MyDir,CSIDL_FONTS,0);

MessageBox(MyDir);