Const CSIDL_ADMINTOOLS As Long = &H30 '(用户)\开始菜单\程序\系统管理工具
Const CSIDL_ALTSTARTUP As Long = &H1D '未本地化的启动
Const CSIDL_APPDATA As Long = &H1A '(用户)\应用程序的数据
Const CSIDL_BITBUCKET As Long = &HA '(桌面)\回收站
Const CSIDL_CONTROLS As Long = &H3 '我的电脑\控制面板
Const CSIDL_COOKIES As Long = &H21
Const CSIDL_DESKTOP As Long = &H0 '桌面
Const CSIDL_DESKTOPDIRECTORY As Long = &H10 '(用户)\桌面
Const CSIDL_FAVORITES As Long = &H6 '(用户)\个性化设置
Const CSIDL_FONTS As Long = &H14 'windows\字体
Const CSIDL_HISTORY As Long = &H22
Const CSIDL_INTERNET As Long = &H1 'IE(桌面上的图标
Const CSIDL_INTERNET_CACHE As Long = &H20 '因特网缓存文件夹
Const CSIDL_LOCAL_APPDATA As Long = &H1C '(用户)\本地设置\应用程序数据
Const CSIDL_DRIVES As Long = &H11 '我的电脑
Const CSIDL_MYPICTURES As Long = &H27 'C:\Program Files\My Pictures
Const CSIDL_NETHOOD As Long = &H13 '(用户)\网上邻居中的元素
Const CSIDL_NETWORK As Long = &H12 '网上邻居
Const CSIDL_PRINTERS As Long = &H4 '我的电脑\打印机
Const CSIDL_PRINTHOOD As Long = &H1B '(用户)\打印机连接
Const CSIDL_PERSONAL As Long = &H5 '我的文档
Const CSIDL_PROGRAM_FILES As Long = &H26 'C:\Program Files
Const CSIDL_PROGRAM_FILESX86 As Long = &H2A 'x86 apps (Alpha)的程序文件目录
Const CSIDL_PROGRAMS As Long = &H2 '开始菜单\程序
Const CSIDL_PROGRAM_FILES_COMMON As Long = &H2B 'Program Files\Common
Const CSIDL_PROGRAM_FILES_COMMONX86 As Long = &H2C 'RISC上的x86 \Program Files\Common
Const CSIDL_RECENT As Long = &H8 '(用户)\最近记录目录
Const CSIDL_SENDTO As Long = &H9 '(用户)\发送到目录
Const CSIDL_STARTMENU As Long = &HB '(用户)\开始菜单
Const CSIDL_STARTUP As Long = &H7 '开始菜单\程序\启动
Const CSIDL_SYSTEM As Long = &H25 'system文件夹
Const CSIDL_SYSTEMX86 As Long = &H29 'x86 apps (Alpha)的system文件夹
Const CSIDL_TEMPLATES As Long = &H15
Const CSIDL_PROFILE As Long = &H28 '用户概貌文件夹
Const CSIDL_WINDOWS As Long = &H24 'Windows目录或SYSROOT()
Const CSIDL_COMMON_ADMINTOOLS As Long = &H2F '(所有用户)\开始菜单\程序\系统管理工具
Const CSIDL_COMMON_ALTSTARTUP As Long = &H1E '未本地化的通用启动
Const CSIDL_COMMON_APPDATA As Long = &H23 '(所有用户)\应用程序数据
Const CSIDL_COMMON_DESKTOPDIRECTORY As Long = &H19 '(所有用户)\桌面
Const CSIDL_COMMON_DOCUMENTS As Long = &H2E '(所有用户)\文档
Const CSIDL_COMMON_FAVORITES As Long = &H1F '(所有用户)\设置
Const CSIDL_COMMON_PROGRAMS As Long = &H17 '(所有用户)\程序
Const CSIDL_COMMON_STARTMENU As Long = &H16 '(所有用户)\开始菜单
Const CSIDL_COMMON_STARTUP As Long = &H18 '(所有用户)\启动
Const CSIDL_COMMON_TEMPLATES As Long = &H2D '(所有用户)\临时
'其他常量
Const CSIDL_FLAG_Create = &H8000&
Const CSIDL_FLAG_DONT_VERIFY = &H4000
Const CSIDL_FLAG_MASK = &HFF00
Const SHGFP_TYPE_CURRENT = &H0
Const SHGFP_TYPE_DEFAULT = &H1
'部分常量在XP下无效!!!
【C程序示例】
#include <shlobj.h> #include <shlwapi.h> #include <windows.h> #include <stdio.h> void main(void) { char DataDir[MAX_PATH]; int len; memset(DataDir, 0, sizeof(DataDir)); if (SUCCEEDED(SHGetFolderPath(NULL, CSIDL_COMMON_APPDATA, NULL, 0, DataDir))) PathAppendA(DataDir, "XXXX\\XXXX.txt"); else return -1; len = strlen(DataDir); argv[5] = (char*) malloc(strlen(DataDir)); // argv[5] 为自己定义的的变量指针 memset(argv[5], 0, strlen(DataDir)); strcpy(argv[5], DataDir); }