📄 xodbc.pas
字号:
unit xODBC;
interface
uses
windows;
const
ODBC_ADD_DSN=1;
ODBC_CONFIG_DSN=2;
ODBC_REMOVE_DSN=3;
ODBC_ADD_SYS_DSN=4;
ODBC_CONFIG_SYS_DSN=5;
ODBC_REMOVE_SYS_DSN=6;
ODBC_REMOVE_DEFAULT_DSN=7;
function SetODBC(opCode:WORD;const sDriver,sAttributes:string):Boolean;
function SQLConfigDataSource(hwndParent:HWND;fRequest:WORD; const lpszDriver:PCHAR;const lpszAttributes:PUCHAR):BOOL;stdcall;
implementation
function SQLConfigDataSource; external 'odbccp32.dll' name 'SQLConfigDataSource';
function SetODBC(opCode:WORD;const sDriver,sAttributes:string):Boolean;
var
p,pAttributes:PUCHAR;
pDriver:PCHAR;
i,n:integer;
begin
pDriver:=PCHAR(sDriver);
GetMem(p,65535);
pAttributes:=p;
n:=Length(sAttributes);
for i:=1 to n do
begin
if sAttributes[i]=';' then p^:=0
else p^:=byte(sAttributes[i]);
inc(p);
end;
p^:=0;
inc(p);
p^:=0;
Result:=SQLConfigDataSource(0,opCode,pDriver,pAttributes);
p:=pAttributes;
FreeMem(p);
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -