type TForm1 = class(TForm) Button1: TButton; Edit1: TEdit; Button2: TButton; procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); private { Private declarations } public { Public declarations } end;
var Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject); //Skriver til inifil var MinIniFil: TIniFile; begin try MinIniFil:= TIniFile.Create(ExtractFilePath(Application.ExeName) + '\MinIniFil.ini'); with MinIniFil do begin WriteInteger('URLS', 'MitNr', StrToInt(Edit1.Text)); //Dine andre værdier kommer her end; finally MinIniFil.Free; end; end;
procedure TForm1.Button2Click(Sender: TObject); //Læser inifil var MinIniFil: TIniFile; begin try MinIniFil:= TIniFile.Create(ExtractFilePath(Application.ExeName) + '\MinIniFil.ini'); with MinIniFil do begin Edit1.Text := IntToStr(ReadInteger('URLS', 'MitNr', 7)); //Hvis inifil ikke findes bliver defaultværdien 7 //Dine andre værdier kommer her end; finally MinIniFil.Free; end; end;
ReadString('Section', 'name', 'Value if not found')
Synes godt om
Ny brugerNybegynder
Din løsning...
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.