[Lazarus] GetAppConfigDir Question

Graeme Geldenhuys graemeg.lists at gmail.com
Fri Oct 23 09:45:31 CEST 2009


2009/10/22 Graeme Geldenhuys <graemeg.lists at gmail.com>:
>
> You can still use GetAppConfigDir, just override the
> OnGetApplicationName event and return the common application name you
> want to use.

In the event that other developers do not know how to use this
feature, here is a code example. It seems not many developers know
about this feature.

Lets say the default ApplicationName returns "project1", but no matter
what my actual application name is, I would like to return a specific
(custom) name instead.

This means that GetAppConfigDir(False) would normally have return the
following path under Linux:
  /home/<user>/.config/project1

With the code below, it will always return:
  /home/<user>/.config/tutoradmin


-----------------------------
implemenation

// This function overrides the default application name
function MyCustomApplicationName: string;
begin
  Result := 'tutoradmin';
end;

constructor TMainForm.Create(AOwner: TComponent );
begin
  inherited Create(AOwner);
  OnGetApplicationName := @MyCustomApplicationName;
  lCfg := GetAppConfigDir(False) + PathDelim + 'settings.ini';
end;
-----------------------------





>
>
> --
> Regards,
>  - Graeme -
>
>
> _______________________________________________
> fpGUI - a cross-platform Free Pascal GUI toolkit
> http://opensoft.homeip.net/fpgui/
>



-- 
Regards,
  - Graeme -


_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/




More information about the Lazarus mailing list