调用"数据链接属性"对话框?
可以使用UDL文件,UDL文件到打开方式是:
Rundll32.exe C:\PROGRA~1\COMMON~1\System\OLEDB~1\oledb32.dll,OpenDSLFile %1
uses ADODB;
然后使用函数:PromptDataSource即可,该函数原型如下:
uses
OleDb , ComObj , ActiveX ;
function PromptDataSource ( ParentHandle : THandle ; InitialString : WideString ): WideString ;
var
DataInit : IDataInitialize ;
DBPrompt : IDBPromptInitialize ;
DataSource : IUnknown ;
InitStr : PWideChar ;
begin
Result := InitialString ;
DataInit := CreateComObject ( CLSID_DataLinks ) as IDataInitialize ;
if InitialString <> '' then
DataInit . GetDataSource ( nil , CLSCTX_INPROC_SERVER ,
PWideChar ( InitialString ), IUnknown , DataSource );
DBPrompt := CreateComObject ( CLSID_DataLinks ) as IDBPromptInitialize ;
if Succeeded ( DBPrompt . PromptDataSource ( nil , ParentHandle ,
DBPROMPTOPTIONS_PROPERTYSHEET , 0 , nil , nil , IUnknown , DataSource )) then
begin
InitStr := nil ;
DataInit . GetInitializationString ( DataSource , True , InitStr );
Result := InitStr ;
end ;
end ;