Inspired by a question in the Advantage Database Forum I’ve extracted some functions from the Advantage Delphi Client Kit to get the version numbers.
The version of the client kit itself is defined as a string const in adsver.pas:
gpcIdAxsVer = 'EsIAx!@# 11.0.0.0';
The method TAdsDataSet.GetVersionInfo in adsdata.pas shows how to extract the version string:
strTDSBuffer := adsver.gpcIdAxsVer; {* "EsIAx!@#" is at the beginning of the version information, so * skip past that string *} system.delete( strTDSBuffer, 1, ESIAX_LENGTH );
The same method also uses the API call AdsGetVersion to read out the DLL version of the Advantage Client Engine (ACE32.DLL, ACE64.DLL):
ACECheck( self, AdsGetVersion( @ulMajor, @ulMinor, @cLetter, nil, @usLen ) );
So let’s split these into two functions:
function GetTDSVersion: string; var strTDSBuffer : string; begin strTDSBuffer := adsver.gpcIdAxsVer; {* "EsIAx!@#" is at the beginning of the version information, so * skip past that string *} system.delete( strTDSBuffer, 1, ESIAX_LENGTH ); Result := strTDSBuffer; end; function GetACEVersion: string; var ulMajor : UNSIGNED32; ulMinor : UNSIGNED32; cLetter : char; usLen : UNSIGNED16; begin {* Get the version of the ACE dll we currently have loaded *} usLen := 0; ACECheck( nil, AdsGetVersion( @ulMajor, @ulMinor, @cLetter, nil, @usLen ) ); Result:=Format('%d.%.2d',[ulMajor,ulMinor])+trim(cLetter); end;
To read out the Server Version you need to be connected to it. Pass a connection handle (e.g. AdsConnection.Connectionhandle) to AdsMgGetInstallInfo and get the version from the returning struct.
function GetServerVersion(hConn:ADSHANDLE):string; var Size: UNSIGNED16; InstallInfo: ADS_MGMT_INSTALL_INFO; begin Size:=SizeOf(InstallInfo); ACECheck(nil,ACE.AdsMgGetInstallInfo(hConn, @InstallInfo, @Size)); Result := InstallInfo.aucVersionStr; end;
In order to get all function names resolved, you should add some units to the uses list.
uses adsdata, ace, adsver;