{ initeng.pas } program InitEng; {$IfDef VER80} uses SnipTool, SnipData, SysUtils, WinTypes, WinProcs, DbiProcs, DbiTypes, DbiErrs; {$Else} uses WinTypes, WinCrt, Strings, DbiProcs, DbiTypes, DbiErrs, SnipTool, SnipData; {$EndIf} {======================================================================== Code: InitEngSample(); Description: This code snipet will initialize IDAPI with a nil environment structure, connect to a Standard database (used by Paradox and dBASE tables), then clean up before returning. Initializing IDAPI with a nil environment structure will force IDAPI to scan for the needed CFG file. The search will follow this search heirchy: 1. Use the CFG specified in the DBIEnv structure (not supplied by this example. 2. Check for a defined CFG file in the WIN.INI file located in your Windows directory. The entry checked for is '[IDAPI]' with an sub-entry of 'CONFIGFILE01.' 3. Check for the CFG file in the startup directory. 4. When all else fails, IDAPI will initialise with a predefined set of configuration settings. The default settings include no locking of Paradox or dBASE tables, no network access to tables, and no SQL databases. ======================================================================== } var hDb: hDBIDb; { Handle to the database } begin Screen('*** Init IDAPI and Connect Example ***'); Screen(' Initializing IDAPI...'); InitOutput; if (ChkRslt(DbiInit(nil), DBIERR_NONE, ' Error - Init.') = DBIERR_NONE) then begin { IDAPI initialized. Now open a Standard database (used to access Paradox and dBASE tables), by using a nil database type. } Screen(' Opening a Standard database...'); if (ChkRslt(DbiOpenDatabase(nil, nil, dbiREADWRITE, dbiOPENSHARED, nil, 0, nil, nil, hDb), DBIERR_NONE, ' Error - OpenDatabase.') = DBIERR_NONE) then begin { Database was opened. Go ahead and close it! } Screen(' Closing the database...'); ChkRslt(DbiCloseDatabase(hDb), DBIERR_NONE, ' Error - DbClose'); end; Screen(' Exiting IDAPI...'); ChkRslt(DbiExit, DBIERR_NONE, ' Error - Exit'); end else begin Screen(' Error - Could not initialize IDAPI'); end; Screen(''); CloseOutput; Screen('*** End of Example ***'); end.