Вопрос Редактирование ini файла

Статус
В этой теме нельзя размещать новые ответы.

Ion

Мимокрокодил
Gde u menea asibka ne redktiruet fail pamaghite pajalusta vot kod
Код:
[Setup]
AppName=My Application
AppVersion=1.5
DefaultDirName={pf}\My Application

[files]
Source: "setup.ini"; DestDir: "{app}"; Flags: ignoreversion ; Components: triobar;

[Components]
Name: "triobar"; Description: "Triobar"; Flags: disablenouninstallwarning

[code]
function SetupEdit(SetupName, OldSetupValue, NewSetupValue: String): Boolean;
var
  Setup: TStringList;
  SetupSetStr: TArrayOfString;
  SetupDir, FileName, Tmp: String;
begin
  SetupDir:=ExpandConstant('{app}');
  FileName:=SetupDir + SetupName;
  If FileExists(FileName) then
  begin
  Setup:=TStringList.Create;
  try
    Setup.LoadFromFile(SetupDir + SetupName);
    Tmp:=Setup.Text;
    StringChange(Tmp, OldSetupValue, NewSetupValue);
    Setup.Text:=Tmp;
    Setup.SaveToFile(SetupDir + SetupName);
  finally
  Setup.Free;
  end;
  end;
end;

procedure triobar();
begin
  If IsComponentSelected('triobar') then
  begin
    SetupEdit('{app}\Setup.ini', 'DbName=localhost: D:\Incoming\TrioBarWork\_FreshBase,', 'DbName=localhost: {app}\FRONT.FDB,');
  end;
end;

procedure CurStepChanged(CurStep: TSetupStep);
begin
  If CurStep = ssPostInstall then
  begin
    triobar();
  end;
end;
 

Вложения

  • 794 байт Просмотры: 13

Kotyarko_O

Новичок
Ion, для редактирования *.ini файлов используйте соответствующую секцию. Или специальные функции (поиск по справке в помощь).
 

sergey3695

Ветеран
Модератор
Код:
[Setup]
AppName=My Application
AppVersion=1.5
DefaultDirName={pf}\My Application

[files]
Source: "setup.ini"; DestDir: "{app}"; Flags: ignoreversion ; Components: triobar;

[Components]
Name: "triobar"; Description: "Triobar"; Flags: disablenouninstallwarning

[code]
procedure RePlaceTextinFile(FilePath:string; find:string; replace1, replace2:string);
var
  S: TStringList;
  i : Integer;
begin
if FileExists(FilePath) then begin
  S:=tstringlist.create;
  S.LoadFromFile(FilePath);
for i := 0 to S.Count-1 do
begin
  if S.Names[i]=find then
  begin
    S.Delete(i);
    S.Insert(i,replace1+'='+replace2);
  end;
end;
  S.SaveToFile(FilePath);
end;
end;

procedure triobar();
begin
  If IsComponentSelected('triobar') then
  begin
    RePlaceTextinFile(ExpandConstant('{app}\Setup.ini'),'DbName', 'DbName', 'localhost:'+AddBackslash(ExpandConstant('{app}'))+'FRONT.FDB,');
  end;
end;

procedure CurStepChanged(CurStep: TSetupStep);
begin
  If CurStep = ssPostInstall then
  begin
    triobar();
  end;
end;
 

asterix93

Новичок
Код:
[Setup]
AppName=My Application
AppVersion=1.5
DefaultDirName={pf}\My Application

[files]
Source: "setup.ini"; DestDir: "{app}"; Flags: ignoreversion ; Components: triobar;

[Components]
Name: "triobar"; Description: "Triobar"; Flags: disablenouninstallwarning

[code]
procedure RePlaceTextinFile(FilePath:string; find:string; replace1, replace2:string);
var
  S: TStringList;
  i : Integer;
begin
if FileExists(FilePath) then begin
  S:=tstringlist.create;
  S.LoadFromFile(FilePath);
for i := 0 to S.Count-1 do
begin
  if S.Names[i]=find then
  begin
    S.Delete(i);
    S.Insert(i,replace1+'='+replace2);
  end;
end;
  S.SaveToFile(FilePath);
end;
end;

procedure triobar();
begin
  If IsComponentSelected('triobar') then
  begin
    RePlaceTextinFile(ExpandConstant('{app}\Setup.ini'),'DbName', 'DbName', 'localhost:'+AddBackslash(ExpandConstant('{app}'))+'FRONT.FDB,');
  end;
end;

procedure CurStepChanged(CurStep: TSetupStep);
begin
  If CurStep = ssPostInstall then
  begin
    triobar();
  end;
end;
agromnaea spasiba
 
Статус
В этой теме нельзя размещать новые ответы.
Сверху