procedure InitPath(
const ACheckPortable: Boolean);
var
sIniFile:
string;
ExeName:
String;
FilePath:
String;
begin
ExeName := ExtractFileName(ChangeFileExt(ParamStr(0), '
'));
FilePath := ExtractFilePath(ParamStr(0));
sIniFile := FilePath + ExeName + '
.ini';
if ACheckPortable
then
Prop.Portable := FileExists(sIniFile);
if Prop.Portable
then
OTTBIni := TIniFile.Create(sIniFile)
else
begin
DeleteFile(sIniFile);
// falls auf nicht portable geschaltet wurde
UserAppDataDir := GetSpecialFolder(CSIDL_APPDATA);
// Direktory erstellen wenn nicht vorhanden
if not ForceDirectories(UserAppDataDir + '
\BrewIdeas\OTTB')
then
raise Exception.Create('
Cannot create' + UserAppDataDir + '
\BrewIdeas\OTTB');
OTTBIni := TIniFile.Create(UserAppDataDir + '
\BrewIdeas\OTTB' + '
\OTTB.ini')
end;
end;
procedure LoadINI;
begin
InitPath(True);
Prop.SoundActive := OTTBIni.ReadBool('
OTTB Option', '
SoundActive', true);
Prop.ShortCutVisible := OTTBIni.ReadBool('
OTTB Option', '
ShortCutVisible', false);
CreateIcon.ShowDesktopIcons(Prop.ShortCutVisible);
OTTBIni.Free;
end;
function SaveINI: Boolean;
var
OldErrorMode: Integer;
begin
InitPath(False);
OldErrorMode := SetErrorMode(SEM_FAILCRITICALERRORS);
try
OTTBIni.WriteBool('
OTTB Option', '
SoundActive', Prop.SoundActive);
OTTBIni.WriteBool('
OTTB Option', '
ShortCutVisible', Prop.ShortCutVisible);
finally
Result := True;
SetErrorMode(OldErrorMode);
OTTBIni.Free;
end;
end;