, , Application Data ++ Builder.
++ Builder, , AnsiStrings Unicode ( "UnicodeString" "AnsiString" s "SHGetSpecialFolderPathW" "SHGetSpecialFolderPath" ).
GetAppDataFolder.h:
#ifndef GetAppDataFolderH
#define GetAppDataFolderH
UnicodeString GetAppDataFolder(bool roaming = true);
#endif
GetAppDataFolder.cpp:
#include <vcl.h>
#pragma hdrstop
UnicodeString GetAppDataFolder(bool roaming )
{
UnicodeString retVal;
int csidl = roaming ? CSIDL_APPDATA : CSIDL_LOCAL_APPDATA;
wchar_t thePath[MAX_PATH];
if (SHGetSpecialFolderPathW(NULL, thePath, csidl, 0) == TRUE) {
retVal = thePath;
}
return retVal;
}