Hi everybody!
I need to find the path to the application data folder. So I use the function SHGetFolderPath with the CSID: CSIDL_APPDATA
Here is my code
Code:
#include <iostream>
#include <sstream>
#include <Windows.h> // for MAX_PATH
#include <shlobj.h> // for getFolderPath function
using namespace std;
// Convert TCHAR to string
std::string TcharsToString(TCHAR const * scz)
{
#ifdef UNICODE
std::ostringstream ossA;
ossA << scz;
return ossA.str();
#else
return scz;
#endif
}
int _tmain(int argc, _TCHAR* argv[])
{
cout << "Get Application Data"<< endl;
string path="";
TCHAR szPath[MAX_PATH];
if(SUCCEEDED(SHGetFolderPath(NULL,
CSIDL_APPDATA,
NULL,
0,
szPath)))
{
path = TcharsToString(szPath);
}
cout << path << endl;
system("PAUSE");
return 0;
}
The problemm is that the string "path" contains series of characters with numbers like "0012FD24"
But normally, I would rather have a string like "C:\documents and settings\user\... , no?
Is there a problem with the conversion TCHAR -> String?
So, How could I have the path in return?
Thanks in advance for your answers