#include <windows.h>
#include <shlobj.h>
#pragma comment( lib, "shell32.lib")
void GetDesktopFilePath(char* returnpath,char *path)
{// TCHAR MyDir[_MAX_PATH];
// SHGetSpecialFolderPath(this->GetSafeHwnd(),MyDir,CSIDL_APPDATA,0);
// char str[30]={0};
// unsigned long size=30;
// GetUserName(str,&size);
// sprintf(returnpath,"C:\\Documents and Settings\\%s\\桌面\\%s",str,path);
char m_lpszDefaultDir[MAX_PATH];
char szDocument[MAX_PATH]={0};
memset(m_lpszDefaultDir,0,_MAX_PATH);
LPITEMIDLIST pidl=NULL;
SHGetSpecialFolderLocation(NULL, CSIDL_DESKTOP, &pidl);
if (pidl && SHGetPathFromIDList(pidl, szDocument))
{
GetShortPathName(szDocument,m_lpszDefaultDir,_MAX_PATH);
}
sprintf(returnpath,"%s\\%s",szDocument,path);
}