on a customers site I have two different networks: one open to the internet, the other not. Both have the same ADS server, but with a different IP address.
To make ADS work in this environment, I need to differentiate the ads.ini.
In VO, the following code works:
Code: Select all
local cIPAddress as string
local cAdsIniLoc as string
cIPAddress := AllTrim( GetIPAddress( "alpilx" ) )
if ! cIPAddress == ""
cAdsIniLoc := oSysIni:GetStringCheck( "Settings", "AdsIniLoc_" + cIPAddress, "g:\alpifakt\192.168.1.0" )
SetEnvironmentVariable( String2PSZ( "adsini_path" ), String2PSZ( cAdsIniLoc ) )
endif
Code: Select all
local oHostEntry as System.Net.IPHostEntry
local oIpAddress as System.Net.IPAddress
local cAdsIniLoc as string
oHostEntry := System.Net.DNS.GetHostEntry( ProgSettings.DatabaseConnectionInfo:ServerName )
if oHostEntry:AddressList:Length > 0
oIpAddress := oHostEntry:AddressList[1]
cAdsIniLoc := ProgSettings.SysIni:GetStringCheck( "Settings", "AdsIniLoc_" + oIpAddress:ToString(), "g:\alpifakt\192.168.1.0" )
Environment.SetEnvironmentVariable( "adsini_path", cAdsIniLoc, EnvironmentVariableTarget.Process )
endif
The ADS help file has the following text about this functionality:
Code: Select all
Windows
In order for the ads.ini file to be used, it must be located in the application directory, the Windows directory, the Windows System directory, or the client's search path.
In addition, if an environment variable exists with the name adsini_path, that path will be used to locate the ads.ini file. This can be helpful when you do not want to modify the application’s search path, but still need the ads.ini file to exist in a directory multiple users have rights to (for example on Windows Vista installations). An application can often set the environment variable at run-time before calling any Advantage functions, which avoids the need to set a per-workstation environment variable.
Wolfgang