SHGetSpecialFolderPathRequirements Runs on Versions Defined in Include Link to Windows CE OS 2.12 and later Shellapi.h This function retrieves the path of a special folder, identified by its CSIDL. BOOL SHGetSpecialFolderPath( HWND hwndOwner, LPTSTR lpszPath, int nFolder, BOOL fCreate );具体参数请查看msdn
LPTSTR lpszPath,
int nFolder,
BOOL fCreate
);nFolder用CSIDL_DESKTOPDIRECTORY
/* 得到当前工作路径 */
/******************************************************/
void GetWorkPath( char szPath[], int nSize )
{
GetModuleFileName( NULL, szPath, nSize );
char* p = strrchr( szPath, '\\' ); *p = 0;
}
以下是代码示例: LPITEMIDLIST ppidl; //定义IDLIST指针
charlinkpath[255]; //定义字符串,保存目录名
获得桌面路径: SHGetSpecialFolderLocation(NULL,0 ,&ppidl);
SHGetPathFromIDList(ppidl,linkpath);
获得程序组路径 SHGetSpecialFolderLocation(NULL,CSIDL_PROGRAMS ,&ppidl);
SHGetPathFromIDList(ppidl,linkpath);
获得启动程序项路径 SHGetSpecialFolderLocation(NULL,CSIDL_STARTUP ,&ppidl);
SHGetPathFromIDList(ppidl,linkpath);
获得IE快速启动栏路径 SHGetSpecialFolderLocation(NULL,CSIDL_APPDATA ,&ppidl);
SHGetPathFromIDList(ppidl,linkpath);
strcat(linkpath,"\Microsoft\Internet Explorer\Quick Launch");
如果我们改变SHGetSpecialFolderLocation函数中的nFolder参数,就可以获得不同的特殊目录,更多的信息请查看MSDN帮助。
Runs on Versions Defined in Include Link to
Windows CE OS 2.12 and later Shellapi.h This function retrieves the path of a special folder, identified by its CSIDL. BOOL SHGetSpecialFolderPath(
HWND hwndOwner,
LPTSTR lpszPath,
int nFolder,
BOOL fCreate
);具体参数请查看msdn
HWND hwndOwner,
LPTSTR lpszPath,
int nFolder,
BOOL fCreate
);