uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,
DB, DBTables, Grids, DBGrids,IniFiles,FileCtrl;
type
TForm1 =
class(TForm)
DBGrid1: TDBGrid;
Query1: TQuery;
DataSource1: TDataSource;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
const
SELDIRHELP = 1000;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var i : Integer;
inifile : TIniFile;
dir :
String;
begin
try
inifile := TInifile.Create(ChangeFileExt(ParamStr(0), '
.ini'));
if not inifile.SectionExists('
Dir')
then
begin
if SelectDirectory(dir, [sdAllowCreate, sdPerformCreate, sdPrompt],SELDIRHELP)
then
inifile.WriteString('
Dir', '
Pfad' ,dir) ;
end else
dir :=inifile.ReadString('
Dir', '
Pfad', '
ERROR');
for i:=0
to Form1.ComponentCount-1
do
begin
if Form1.Components[i]
is TQuery
then
begin
TQuery(Components[i]).DatabaseName := dir;;
TQuery(Components[i]).Open
end;
end;
finally
inifile.Free;
end;
end;