
program ODBC_REG;
const
MAX_PATH = 1000;
type
PACMAX = PACKED ARRAY [0..MAX_PATH] OF CHAR;
BOOL = LongBool;
DWORD = Integer;
function MessageBox
( HWnd: Integer;
Text, Caption: PChar;
Flags: Integer )
: Integer;
stdcall;
external 'user32.dll' name 'MessageBoxA';
function SQLInstallDriverManager
( lpszPath : PChar;
cpPathMax : WORD;
VAR pcbPathOut : WORD )
: BOOL;
stdcall;
external 'ODBCCP32.DLL';
function SQLInstallDriverEx
( lpszDriver : PChar;
lpszPathIn : PChar;
lpszPathOut : PChar;
cpPathOutMax : WORD;
VAR pcbPathOut : WORD;
fRequest : WORD;
VAR lpdwUsageCount : DWORD )
: BOOL;
stdcall;
external 'ODBCCP32.DLL';
function SQLInstallerError
( iError : WORD;
var pfErrorCode : DWORD;
lpszErrorMsg : PChar;
cbErrorMsgMax : WORD;
var pcbErrorMsg : WORD )
: integer;
stdcall;
external 'ODBCCP32.DLL';
function SQLGetPrivateProfileString
( lpszSection : PChar;
lpszEntry : PChar;
lpszDefault : PChar;
lpszRetBuffer : PChar;
cbRetBuffer : integer;
lpszFilename : PChar )
: integer;
stdcall;
external 'odbccp32.dll'
function ConfigDSN
( hwnd : integer;
fRequest : WORD;
lpszDriver : PChar;
lpszAttributes : PChar )
: BOOL;
stdcall;
external '3kodbc.dll'
const
ODBC_INSTALL_INQUIRY = 1;
ODBC_INSTALL_COMPLETE = 2;
ODBC_ADD_DSN = 1;
ODBC_CONFIG_DSN = 2;
ODBC_REMOVE_DSN = 3;
var
nReturn : BOOL;
nIgnore : WORD;
SQLPath : PACMAX;
SQLReturn : PACMAX;
SQLError : PACMAX;
lpszRetBuffer : PACMAX;
I1 : integer;
nLong : DWORD;
begin
{ nResult = 1;
nLong = 0;
nResult = SQLInstallDriverEx ( pDriver1, pDriver2, pDriver3, nIn, nOut, ODBC_INSTALL_INQUIRY, nLong );
nResult = SQLInstallDriverEx ( pDriver1, pDriver2, pDriver3, nIn, nOut, ODBC_INSTALL_COMPLETE, nLong );
}
nReturn := SQLInstallDriverManager ( SQLPath, MAX_PATH, nIgnore );
if ( nReturn ) then begin
nReturn := SQLInstallDriverEx ( 'HP3000 Data Access Driver'#0'Driver=3kodbc.dll'#0#0, SQLPath, SQLReturn, MAX_PATH, nIgnore, ODBC_INSTALL_INQUIRY, nLong );
if ( nReturn ) then begin
nReturn := SQLInstallDriverEx ( 'HP3000 Data Access Driver'#0'Driver=3kodbc.dll'#0#0, SQLPath, SQLReturn, MAX_PATH, nIgnore, ODBC_INSTALL_COMPLETE, nLong );
if ( nReturn ) then begin
if ( SQLGetPrivateProfileString ( 'MSCARD', 'Driver', '', lpszRetBuffer, MAX_PATH, 'ODBC.INI' ) = 0 ) then begin
if ( ConfigDSN ( 0, ODBC_ADD_DSN, 'HP3000 Data Access Driver'
, 'DSN=MSCARD'#0'User=MGR'#0'Account=MINISOFT'#0'Group=MM'#0'Language=-1'#0'2HostTable='#0'2DriverTable='#0'DecimalPoint=.'#0'Server Port=30006'#0'Database0=MSCARD.MM.MINISOFT,DO-ALL,0,4'#0#0 ) )
then begin
MessageBox ( 0, 'Registration and Add Complete.'#13#10'Please update the server name (or address) before using the MSCARD datasource.', 'Minisoft ODBC/32', 0 );
end else begin
SQLInstallerError ( 1, I1, SQLError, MAX_PATH, nIgnore );
MessageBox ( 0, SQLError, 'Minisoft ODBC/32', 0 );
end;
end else begin
MessageBox ( 0, 'Registration Complete.', 'Minisoft ODBC/32', 0 );
end;
end else begin
SQLInstallerError ( 1, I1, SQLError, MAX_PATH, nIgnore );
MessageBox ( 0, SQLError, 'Minisoft ODBC/32', 0 );
end;
end else begin
SQLInstallerError ( 1, I1, SQLError, MAX_PATH, nIgnore );
MessageBox ( 0, SQLError, 'Minisoft ODBC/32', 0 );
end;
end else begin
SQLInstallerError ( 1, I1, SQLError, MAX_PATH, nIgnore );
MessageBox ( 0, SQLError, 'Minisoft ODBC/32', 0 );
end;
end.