Handle SHGetKnownFolderPath failing - return empty string

* The calling code will handle this as an unknown path and fail upwards.
This commit is contained in:
baldurk
2018-05-01 14:46:33 +01:00
parent 6a482c02e2
commit f339314468
+6 -3
View File
@@ -354,9 +354,12 @@ string GetHomeFolderFilename()
string GetAppFolderFilename(const string &filename)
{
PWSTR appDataPath;
SHGetKnownFolderPath(FOLDERID_RoamingAppData, KF_FLAG_SIMPLE_IDLIST | KF_FLAG_DONT_UNEXPAND, NULL,
&appDataPath);
PWSTR appDataPath = NULL;
HRESULT hr = SHGetKnownFolderPath(
FOLDERID_RoamingAppData, KF_FLAG_SIMPLE_IDLIST | KF_FLAG_DONT_UNEXPAND, NULL, &appDataPath);
if(appDataPath == NULL || FAILED(hr))
return "";
wstring appdata = appDataPath;
CoTaskMemFree(appDataPath);