Kod, który podałeś jest prawidłowy. Pod Delphi 7 kompiluje się ok. Za pewne masz coś pomieszane z typami. Ty nie przypisujesz IniFile stringa. Tylko w konstruktorze tego obiektu nakazujesz wczytywanie/zapis pliku ini do katalogu w którym jest Twój exek + JakasZmiennaTypuStringCoNieWiemyCoZawiera + 'users.ini'. Ponieważ domyślnie pliki ini zapisują się i odczytują z katalogu Windowsa. Tak pliki ini zostały stworzone jeszcze od wczesnych Windowsów, gdzie podkatalog w stylu %APPDATA%
nie istniał.
Ewentualnie, jeżeli takie problemy sprawia Ci banalne ogarnięcie podstaw VCL. To nie wiem, zrób to pod WinAPI. Ja od dawna już porzuciłem używanie klasy TIniFile
. Wszystko co najważniejsze mogą zrobić poniżesze metody:
procedure IniFileWriteString(FileName, Section, Ident, Value : string);
begin
WritePrivateProfileString(PChar(Section), PChar(Ident), PChar(Value), PChar(FileName));
end;
function IniFileReadString(FileName : string;
const Section, Ident, Default : string) : string;
var
Buffer : array[0..2047] of Char;
begin
SetString(Result, Buffer, GetPrivateProfileString(PChar(Section),
PChar(Ident), PChar(Default), Buffer, SizeOf(Buffer), PChar(FileName)));
end;
procedure IniFileEraseSection(FileName : string; const Section : string);
begin
WritePrivateProfileString(PChar(Section), nil, nil, PChar(FileName));
end;
procedure IniFileDeleteKey(FileName : string; const Section, Ident : string);
begin
WritePrivateProfileString(PChar(Section), PChar(Ident), nil, PChar(FileName));
end;