Var AliasFound: Boolean; TmpCursor: hDBICur; Rslt: DBIResult; Database: DBDesc;
Begin Check(DbiInit(nil)); try Check(DbiOpenDatabaseList(TmpCursor)); AliasFound := False; repeat {Get a DBDesc record for the next alias} rslt:= DbiGetNextRecord(TmpCursor, dbiNOLOCK, @Database, nil); if (rslt <> DBIERR_EOF) then if StrPas(Database.szName) = 'MyAlias' then begin {The alias MyAlias already exists} AliasFound := True; Break end; until rslt <> DBIERR_NONE; Check(DbiCloseCursor(TmpCursor)); if not AliasFound then {If the alias was not found, add it to IDAPI.CFG} Check(DbiAddAlias(nil,PChar('MyAlias'),nil, PChar('PATH:'+ExtractFilePath(Application.ExeName)),True)) finally DbiExit; end; end;