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.
}
}
int GetCurrentUserLocalLowAppPath(LPTSTR szProfileDir,int dirlen )
{
memset(szProfileDir,0,dirlen);
if(IsWinXP() == TRUE)
{
GetCurrentUserAppPath( szProfileDir, dirlen );
}
else if(IsVista() == TRUE)
{
PWSTR pszPath[1];
SHGetKnownFolderPath(NULL,FOLDERID_LocalAppDataLow,0,NULL,pszPath);
//copying the pszPath to szProfileDir array
}
return 1;
}
No comments:
Post a Comment