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

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...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...