Jump to content

INI File


Mohammad Hamdan

Recommended Posts

In Web Mode, can i read from INI file?

 

i use the following code.

 

 

var
  INI            : TIniFile;
  strINIFilePath : String;
  strReadedVal   : string;
begin
  Result := False;
  Try
  strINIFilePath := GetCurrentDir + 'Config.ini';
  strReadedVal   := EmptyStr;
  If FileExists(strINIFilePath) Then
  Begin
    Ini := TIniFile.Create(strINIFilePath);
    Try
      strReadedVal := Ini.ReadString(strSec,strTag, '0');
      strVal := strReadedVal;
      Result := True;
    Finally
      FreeAndNil(Ini);
    End;
  End;
  except
    Result := False;
  End;
 
this work in normal VCL Application, but not work in ISAPI DLL , I want to use the INI file to Store the SQL Server Connection String
and other Values

 

Link to comment
Share on other sites

It easy to work to udl files, you just only has to create a txt file and change the extension txt by udl.

Example : myDbConnect.txt by myDbConecct.udl,

Then you just only has to click and you will see the option to connect to any database

 

 

Ronny Encarnacion

  • Upvote 1
Link to comment
Share on other sites

In case you want to stick to the ini files :

 

 

function ReadSetup:boolean;

  var
                          fname:string;
                                ini:TIniFile;
  begin
  fname:=UniServerModule.StartPath+'etc\your_conf_file.ini';
  if FileExists(fname) then
     begin
       Conn.Connected  := False;
       ini:=TIniFile.Create(fname);
       try
          ..... Read the stuff you want here
          result:=True;
       finally
          ini.Free;
       end;
     end
     else begin
       UniServerModule.Logger.AddLog('No conf file ->'+fname);
       result:=False;
     end;
end;
 

 

  • Upvote 1
Link to comment
Share on other sites

  • 1 month later...

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...