有关INI(30分)

P

panjf

Unregistered / Unconfirmed
GUEST, unregistred user!
在程序中我这样写的,可在编译时却出现如下信息,为什么?
代码:
var
  Ini: TiniFile;
begin
   Ini := TIniFile.Create(IniFileName);
    try
      Ini.ReadSection(KeyName, combobx1.Items);
  //编译时有提示
    finally
      Ini.Free;
    end;
[Warning] Variable'Ini' might not have been initialized
 
不可能吧,帮你up
 
use 是否添加了IniFiles?
其他地方是否定义了ini变量?
在我的机器上运行正常
 
试试这样
var
ini:Tinifile
begin
ini:=Tinifile.Create('FilePath');
try
Ini.ReadSection(KeyName, combobx1.Items);
finally
Ini.Free;
end;

end;
 
这么些就应该可以了。
begin
with TIniFile.Create(IniFileName) do
begin
try
ReadSection(KeyName, combobx1.Items);

finally
Free;
end;

end;
 
不要用这些软件或系统可能占用的保留字作为变量名,你完全可以改个名嘛
 
应该没问题哪,Warning,不管他,当然最好没有
 
把 Create 语句放到 try 里面
 
[:D]我写错了,不好意思
 
顶部