Just to suppliment interjay's answer
I had to include shlobj.h
to use SHGetFolderPath
.
Often you may need to read a file from appdata,
to do this you need to use the pathAppend
function (shlwapi.h
is needed for this).
#include <shlwapi.h>
#pragma comment(lib,"shlwapi.lib")
#include "shlobj.h"
TCHAR szPath[MAX_PATH];
// Get path for each computer, non-user specific and non-roaming data.
if ( SUCCEEDED( SHGetFolderPath( NULL, CSIDL_COMMON_APPDATA, NULL, 0, szPath ) ) )
{
// Append product-specific path
PathAppend( szPath, _T("\\My Company\\My Product\\1.0\\") );
}
See here for more details.