The solution has been found. crefird posted a link to the Paradox ODBC driver connection string in the first comment to this question, and using the names found there I was able to create the ODBC system DSN (data source name).
I was close on my initial try, but you won't believe what was missing. I didn't have the driver name exactly correct. In my above code I entered the driver name as this
'Microsoft Paradox Driver (*.db)'
The correct driver name is this
'Microsoft Paradox Driver (*.db )'
Yes, that extra space before the close paren is actually the correct driver name. Wow!
Here are two routines that I ended up writing to dynamically create a DSN:
implementation
uses Registry, Winapi.Windows, System.SysUtils;
const
ODBC_ADD_SYS_DSN = 4; // add a system DSN
function SQLConfigDataSource( hwndParent: LongWord ; fRequest: Word ;
lpszDriver: PChar ; lpszAttributes: pchar ): boolean;
stdcall; external 'ODBCCP32.DLL' name 'SQLConfigDataSourceW';
procedure CreateParadoxDSN(DataSourceName: string; DataDirectory: string);
var
Attributes: string;
RetVal: Boolean;
DriverName: PChar;
DirName: string;
begin
DriverName := 'Microsoft Paradox Driver (*.db )';
Attributes := 'DSN=' + DataSourceName + #0;
Attributes := Attributes + 'DefaultDir=' + DataDirectory + #0;
Attributes := Attributes + 'Dbq=' + DataDirectory + #0;
Attributes := Attributes + 'UID='#0;
Attributes := Attributes + 'Fil=Paradox 5.0'#0#0;
Attributes := Attributes + 'DESCRIPTION=' + DataSourceName + #0#0;
RetVal := SqlConfigDataSource(0, ODBC_ADD_SYS_DSN, DriverName,
PChar(Attributes));
if not RetVal then
begin
Exception.Create('Failed to create data source name. Cannot continue');
end;
end;
function ParadoxDSNExists(DataSourceName: string): Boolean;
var
Registry: TRegistry;
begin
Registry := TRegistry.Create;
try
Registry.RootKey := HKEY_LOCAL_MACHINE;
Result := Registry.KeyExists('Software\Wow6432Node\ODBC\ODBC.INI\' +
DataSourceName);
finally
Registry.Free;
end;
end;