Hi Sven,
{$mode objfpc}{$H+}
TConfiguration = packed record
DataFolder: string;
end;
does not work, but:
TConfiguration = packed record
DataFolder: array [0..MaxPathLen] of Char;
end;
worked. My save procedure is:
function SaveParams(var Buffer; Count: Integer; FileName: string): Boolean;
var
fs: TFileStream;
begin
Result := False;
if not ForceDirectories(ExtractFilePath(FileName)) then Exit;
try
fs := TFileStream.Create(FileName, fmCreate);
try
fs.Write(Buffer, Count);
Result := True;
finally
fs.Free;
end;
except
end;
end;
It is called on the finalization section of config.pas:
SaveParams(cfg, SizeOf(cfg), cfn);
//cfg is TConfgiruation, cfn is the filename.
The symptoms of error are:
1. The DataFolder value is not saved to configuration file, although file saving seems succeeded.
2. There are weird access violations, e.g. on exiting or on occasions that I try to manipulate the configuration at runtime (RunError(203) was reported).
Anything that I did wrong? or, AnsiString is not supported this way anyway?
2013/3/3 Sven Barth
Show quoted text 35 lines
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20130303/5a709c84/attachment.html>