Alterar arquivo INI
Pessoal dei uma pesquisada e verifiquei só criação e leitura de Aquivo INI, acontece que tenho um arquivo INI e em um lugar do sistema eu Crio o INI com umas chaves e depois em outro módulo eu gravo outra chave, como faço para adicionar mais chaves em um arquivo existeste???
Ariovaldo
Curtidas 0
Respostas
Maicongabriel
09/03/2004
Crio o INI com umas chaves e depois em outro módulo eu gravo outra chave, como faço para adicionar mais chaves em um arquivo existeste???
Cria as chaves via programação? Se sim, para adicionar é da mesma forma! Procure do help do próprio Delphi, que lá tem exemplos! :?
GOSTEI 0
Ariovaldo
09/03/2004
Pessoal alguém poderia me ajudar neste problema, já criei o arquivo ini já estou lendo, más agora preciso gravar algumas configurações de outro módulo, ou seja, quando entro neste segundo módulo eu verifico se o arquivo existe se existir eu carrego ele em um stringlist e agora quero incluir nova chave e valor só que não estou conseguindo, pelo que vi no delphi só explica nem exemplo tem
GOSTEI 0
Aroldo Zanela
09/03/2004
Colega,
This example reads the Transfer section of the DELPHI32.INI file into a memo and changes one of the strings in the INI file when Button1 is clicked. When Button2 is clicked, the DELPHI32.INI file is restored to its initial state, using the values stored in the memo.
Before you run this example, you must add the IniFiles unit to the uses clause of your unit.
Warning
Do not click button2 before you have clicked button1!
procedure TForm1.Button1Click(Sender: TObject);
var
DelphiIni: TIniFile;
begin
DelphiIni := TIniFile.Create(´c:\windows\delphi32.ini´);
Memo1.Clear;
DelphiIni.ReadSectionValues(´Transfer´, Memo1.Lines);
if Memo1.Lines.Values[´Title1´] <> ´Picture Painter´ then
DelphiIni.WriteString(´Transfer´, ´Title1´, ´Picture Painter´);
DelphiIni.Free;
end;
procedure TForm1.Button2Click(Sender: TObject);
var
DelphiIni: TIniFile;
begin
DelphiIni := TIniFile.Create(´c:\windows\delphi32.ini´);
{ if the entry wasn’t there before, delete it now }
if Memo1.Lines.Values[´Title1´] = ´´ then
DelphiIni.DeleteKey(´Transfer´, ´Title1´)
{ otherwise, restore the old value }
else
DelphiIni.WriteString(´Transfer´, ´Title1´,
Memo1.Lines.Values[´Title1´]);
DelphiIni.Free;
end;GOSTEI 0
Maicongabriel
09/03/2004
É [b:ad03f2094a]Aroldo[/b:ad03f2094a] acho que a única solução as vezes é colar o HELP DO DELPHI! Já que indicar não resolve :shock:
GOSTEI 0