只是为了好奇:为什么这段代码会提供AV而不是抛出异常?
procedure TForm1.Button1Click(Sender: TObject);
var fs: TFormatSettings;
begin
strtodate('2011-01-01', fs);
end;
答案 0 :(得分:12)
您的代码引发了异常,因为fs
未初始化。
uses SysUtis, Windows;
procedure TForm1.Button1Click(Sender: TObject);
var fs: TFormatSettings;
begin
GetLocaleFormatSettings(GetSystemDefaultLCID, fs); // what is your short-date format?
strtodate('2011-01-01', fs);
end;