Thanks Naveen. Here is the code for it.
typedef HRESULT (WINAPI * SHGetKnownFolderPathFn)(REFKNOWNFOLDERID rfid, DWORD dwFlags, HANDLE hToken,PWSTR *ppszPath);
PWSTR pszPath\[1\];
SHGetKnownFolderPathFn shGetKnownFolrPth = NULL ;
HINSTANCE hins = LoadLibrary("Shell32.dll");
if(hins != NULL)
{
shGetKnownFolrPth = (SHGetKnownFolderPathFn)::GetProcAddress(hins,"SHGetKnownFolderPath");
if( shGetKnownFolrPth != NULL)
{
shGetKnownFolrPth(FOLDERID\_LocalAppDataLow,0,NULL,pszPath);
CString csData=pszPath\[0\]; // converting from wchar to ANSI.
}
}