05-09-2018, 03:06 PM
(05-09-2018, 02:10 PM)RaelB Wrote: Can it not be in the same directory as the main exe with other files?
As long as you make sure that this is a guarantied permanent directory, e.g. you must enter is as an absolute path.
I always generate a subdirectory in AppData for my applications, and there keep all my internal application stuff.
Code:
procedure GetDataDirectory;
var
Buffer: array [0..255] of Char;
begin
FillChar(Buffer, 256, #0);
try
if SHGetFolderPath(Application.Handle, CSIDL_APPDATA, 0, 0, Buffer) = S_OK then
begin
DataPath := IncludeTrailingPathDelimiter(StrPas(Buffer));
DataDir := IncludeTrailingPathDelimiter(DataPath + MyProgramName);
if not DirectoryExists(DataDir) then ForceDirectories(DataDir);
SSLDir := IncludeTrailingPathDelimiter(DataDir + 'SSL');
if not DirectoryExists(SSLDir) then ForceDirectories(SSLDir);
except
//
end;
end;
Nice and clean.
Above also still works under Windows XP.