Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 2 of 2 total
Thread Access to Elevate Web Server ini file?
Mon, May 14 2018 3:21 PMPermanent Link

Ralf Mimoun

Hi all,

I am writing a server module that needs a configuration file. Is there any way to access the ewbsrvr.ini, get the file name of the ini file used or get the folder? It would help to put all config data in one file or at least in the same folder.

Ralf
Fri, May 18 2018 1:36 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Ralf,

<< I am writing a server module that needs a configuration file. Is there any way to access the ewbsrvr.ini, get the file name of the ini file used or get the folder? It would help to put all config data in one file or at least in the same folder. >>

I would recommend using your own sub-folder and .ini file, and you can use this code to do so:

uses Windows, ShlObj;

function OSAppDataDirectory: String;
var
  TempBuffer: array[0..MAX_PATH] of Char;
  ResultLength: Integer;
begin
  FillChar(TempBuffer,((MAX_PATH+1)*SizeOf(Char)),0);
  ShlObj.SHGetSpecialFolderPathW(0,@TempBuffer,CSIDL_LOCAL_APPDATA,False);
  ResultLength:=WStrLen(pChar(@TempBuffer));
  SetLength(Result,ResultLength);
  Move(TempBuffer[0],pChar(Result)^,(ResultLength*SizeOf(Char)));
end;

function GetAppDataDirectory: String;
begin
  {$WARN SYMBOL_PLATFORM OFF}
  Result:=IncludeTrailingBackslash(OSAppDataDirectory)+'Your Company Name\Your Product Name';
  if (not DirectoryExists(Result)) then
     ForceDirectories(Result);
  {$WARN SYMBOL_PLATFORM ON}
end;

function GetIniFileName: String;
begin
  {$WARN SYMBOL_PLATFORM OFF}
  Result:=GetAppDataDirectory+PathDelim+'yourapplication.ini');
  {$WARN SYMBOL_PLATFORM ON}
end;

Tim Young
Elevate Software
www.elevatesoft.com
Image