TRegIniFile: failure on consecutive reads when Section parameter is empty
Original Reporter info from Mantis: Bart @flyingsheep
-
Reporter name: Bart Broersma
Original Reporter info from Mantis: Bart @flyingsheep
- Reporter name: Bart Broersma
Description:
When you do consecutive reads (like ReadString) on the same key/section/ident, and the Section paramter is an empty string, then the second (and following) reads will fail.
Steps to reproduce:
Build and run the following program:
program rtest;
{$apptype console}
{$ifdef fpc}{$mode objfpc}{$endif}
uses
registry, sysutils, classes {$ifndef fpc}, windows{$endif};
var
RegIni: TRegIniFile;
WFileName: String;
i: Integer;
begin
RegIni := TRegIniFile.Create('SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders', KEY_READ);
try
for i := 1 to 2 do
begin
WFileName := RegIni.ReadString ('', 'Desktop', 'Failure!');
writeln(format('Try %d: WFileName = "%s"',[i,WFileName]));
end;
finally
RegIni.Free;
end;
end.
Build and run with fpc
C:\Users\Bart\LazarusProjecten\bugs\Console\regini>fpc rtest.lpr
Free Pascal Compiler version 3.1.1 [2018/06/03] for i386
...
C:\Users\Bart\LazarusProjecten\bugs\Console\regini>rtest
Try 1: WFileName = "C:\Users\Bart\Desktop"
Try 2: WFileName = "Failure!"
Now build and run with Delphi (D7)
C:\Users\Bart\LazarusProjecten\bugs\Console\regini>dcc32 rtest.lpr
Borland Delphi Version 15.0
Copyright (c) 1983,2002 Borland Software Corporation
rtest.lpr(25)
...
C:\Users\Bart\LazarusProjecten\bugs\Console\regini>rtest
Try 1: WFileName = "C:\Users\Bart\Desktop"
Try 2: WFileName = "C:\Users\Bart\Desktop"
Additional information:
Originally reported in forum: http://forum.lazarus.freepascal.org/index.php/topic,41847.0.html by user BjPascal.
Mantis conversion info:
- Mantis ID: 33980
- OS: Windows
- OS Build: 10
- Build: 39352
- Platform: i386
- Version: 3.1.1
- Fixed in version: 3.3.1
- Fixed in revision: 44478 (#a24a4b97)
- Target version: 3.2.0