Board index » delphi » Delphi & .INI files

Delphi & .INI files

I am stuck on this one.  I want to know if it is possible for my
application to have an .ini file associated with it that will pass in the
[IDAPI] paramaters to windows.  Right now, I have to go to each
workstation and add the following to each win.ini file

[IDAPI]
DLLPATH=F:\PUBLIC\APPS\BDE
CONFIGFILE01=F:\PUBLIC\APPS\BDE\IDAPI.CFG

Couldn't my delphi app just have a simple .ini file to pass these in that
could be managed from a central location?

If so, how would I interface the app with that .ini file?  Could someone
please give me some guidance here.  It just seems like a waste of time
(especially when you try to centralize everything on a server) to have to
go to each machine and edit the stupid win.ini file!!!  Please help.

Thanks so much,
Ryan

 

Re:Delphi & .INI files


Quote
Ryan Zwahr <span...@interaccess.com> wrote:

>If so, how would I interface the app with that .ini file?  

From an old post:

Quote
John Breen wrote:
> Does anyone know how to use the TIniFile object.  
> The Delphi online help isn'terribly clear, and I don't ...

Let say u have an INI file like this :
[Setup]
Value1=MyValue1
Value2=MyValue2

Then u can do something like,

var MyIni     : TIniFile;
    TheValue  : string;
    SetupList : TStringList;

begin
   ...
   MyIni := TIniFile.Create('C:\MYINI.INI);
   { To get the value for Value1 }
   TheValue := MyIni.ReadString( 'Setup', 'Value1, '' );
   ...
   { To get the whole section of Setup }
   SetupList := TStringList.Create;
   MyIni.ReadSectionValues('Setup', SetupList);
   { Then u will have SetupList.Strings[0] = 'Value1=MyValue1' and so on }
   ...

   MyIni.Free;
end;

Don't forget u can also write into the INI beside then reading it easily.
Regards,  
Steven Yong

kwy...@pop.jaring.my

Re:Delphi & .INI files


Quote
Ryan Zwahr wrote:

> I am stuck on this one.  I want to know if it is possible for my
> application to have an .ini file associated with it that will pass in the
> [IDAPI] paramaters to windows.  Right now, I have to go to each
> workstation and add the following to each win.ini file

> [IDAPI]
> DLLPATH=F:\PUBLIC\APPS\BDE
> CONFIGFILE01=F:\PUBLIC\APPS\BDE\IDAPI.CFG

> Couldn't my delphi app just have a simple .ini file to pass these in that
> could be managed from a central location?

> If so, how would I interface the app with that .ini file?  Could someone
> please give me some guidance here.  It just seems like a waste of time
> (especially when you try to centralize everything on a server) to have to
> go to each machine and edit the stupid win.ini file!!!  Please help.

> Thanks so much,
> Ryan

Ryan,

Delphi supports the calls for reading/writing INI files. Search on help
under INI, TINIFile Object.

I have also found MANY INI file components for free on the web and
Compu$erve.

Cheers,

Matthew

==================================================================
Matthew McDermott
McDermott Enterprises
matt...@valleynet.com
My Web Page: http://www.valleynet.com/~matthew
------------------------------------------------------------------
Director of Information Services & Adjunct Professor - Mathematics
The American College of Prehospital Medicine: http://www.acpm.edu/
==================================================================

Re:Delphi & .INI files


Quote
Ryan Zwahr <span...@interaccess.com> wrote:
>I am stuck on this one.  I want to know if it is possible for my
>application to have an .ini file associated with it that will pass in the
>[IDAPI] paramaters to windows.  Right now, I have to go to each
>workstation and add the following to each win.ini file

>[IDAPI]
>DLLPATH=F:\PUBLIC\APPS\BDE
>CONFIGFILE01=F:\PUBLIC\APPS\BDE\IDAPI.CFG
>...

You could write a little stub loader in place of your program -- it would
load, and check that the local configuration was set up (making the ini
changes if necessary), then call your main program's EXE. If you don't use
the Delphi VCL, and just make direct calls to Windows functions, then the
resulting EXE will be tiny -- less than 10K probably.

--
Brad Aisa <ba...@hookup.net>
Senior Software Designer
Business Machine Interfaces, Inc.
Toronto, Ontario, Canada

Re:Delphi & .INI files


Quote
ba...@hookup.net (Brad Aisa) wrote:
>Ryan Zwahr <span...@interaccess.com> wrote:
>>I am stuck on this one.  I want to know if it is possible for my
>>application to have an .ini file associated with it that will pass in the
>>[IDAPI] paramaters to windows.  Right now, I have to go to each
>>workstation and add the following to each win.ini file

>>[IDAPI]
>>DLLPATH=F:\PUBLIC\APPS\BDE
>>CONFIGFILE01=F:\PUBLIC\APPS\BDE\IDAPI.CFG
>>...

Indeed, this can be crazy if there's 50 workstations to configure.
Well, I have done this b4 and it's fairly EZ. Hope 4lowing help:

function UpdateWindowsINI: Boolean;
var
  Ini: TIniFile;
begin

  Ini:= TIniFile.Create('WIN.INI');

  Ini.WriteString('IDAPI','DLLPATH',RootDirectory+'IDAPI');
  Ini.WriteString('IDAPI','CONFIGFILE01',RootDirectory+'IDAPI\IDAPI.CFG');
  Ini.WriteString('Borland Language Drivers','LDPath',
                   RootDirectory+'IDAPI\LANGDRV');

  ....

  Ini.Free;
end;

Terence

Other Threads