1、生成当前程序的路径: MainDir:=ExtractFileDir(Application.Exename);
2、不写注册表;
3、如下生成自己的配置文件:
procedure GlobalStartIni;
var
IniFile: TIniFile;
begin
MainDir:=ExtractFileDir(Application.Exename);
IniFile:=TIniFile.Create(MainDir+'/Config.ini');
try
if not FileExists(MainDir+'/Config.ini') then
begin
MainForm.Top:=1;
MainForm.Left:=1;
MainForm.Height:=450;
MainForm.Width:=636;
iProjectOrder:=0;
iAutoSaveTime:=5;
boolAutoOpenItemCostForm:= true;
boolPrintProjectChief:= true;
boolPrintEditChief:= true;
boolPrintEditAssessor:= true;
boolPrintEditor:= true;
IniFile.WriteInteger('MainForm','WindowStateMax',0);
IniFile.WriteInteger('MainForm','Top',1);
IniFile.WriteInteger('MainForm','left',1);
IniFile.WriteInteger('MainForm','Height',450);
IniFile.WriteInteger('MainForm','Width',636);
IniFile.WriteInteger('Commond','ProjectOrder',0);
IniFile.WriteInteger('Commond','AutoSaveTime',5);
IniFile.WriteBool('Commond','AutoOpenItemCostForm',true);
IniFile.WriteBool('Print','PrintProjectChief',true);
IniFile.WriteBool('Print','PrintEditChief',true);
IniFile.WriteBool('Print','PrintEditAssessor',true);
IniFile.WriteBool('Print','PrintEditor',true);
end
else begin
if IniFile.ReadInteger('MainForm','WindowStateMax',1)=0 then
begin
MainForm.Top:=IniFile.ReadInteger('MainForm','Top',1);
MainForm.Left:=IniFile.ReadInteger('MainForm','left',1);
MainForm.Height:=IniFile.ReadInteger('MainForm','Height',450);
MainForm.Width:=IniFile.ReadInteger('MainForm','Width',636);
end
else begin
MainForm.WindowState:= wsMaximized;
end;
iProjectOrder:=IniFile.ReadInteger('Commond','ProjectOrder',0);
iFont:=IniFile.ReadInteger('Commond','Font',1);
iAutoSaveTime:=IniFile.ReadInteger('Commond','AutoSaveTime',5);
boolAutoOpenItemCostForm:=IniFile.ReadBool('Commond','AutoOpenItemCostForm',True);
boolPrintProjectChief:= IniFile.ReadBool('Print', 'PrintProjectChief', true);
boolPrintEditChief:= IniFile.ReadBool('Print', 'PrintEditChief', true);
boolPrintEditAssessor:= IniFile.ReadBool('Print', 'PrintEditAssessor', true);
boolPrintEditor:= IniFile.ReadBool('Print', 'PrintEditor', true);
end;
finally
IniFile.Free;
end;
end;