我在BDE Administrator中配置了一个连接本地Paradox7数据库的数据源
因为程序要动态的每天在Paradox目录中建数据库
为了灵活起见,我想在程序中读取BDE Adminstrator中配置的路径
请问哪位知道如何读取?
谢谢!

解决方案 »

  1.   


    註冊表路徑
    \HKEY_LOCAL_MACHINE\SOFTWARE\BORLAND\DATABASE ENGINE\分析下面代碼, 能夠幫你找到答案.procedure TForm1.BitBtn4Click(Sender: TObject);
    const DTS_ALIAS_NAME = 'NisDTS7';
    var
      ap: TStringList; {字串行表變數}
      answer: Integer;
    begin
      ap := TStringlist.Create;
      Session.GetAliasNames(ap); {取得別名列表}  if (ap.IndexOf(DTS_ALIAS_NAME) = -1) then {判斷別名是否存在}
      begin
        answer := Application.MessageBox('別名Cntssamp不存在,現在創建嗎?',
          'BDE資訊口', mb_OKCancel);
        {增加一個名?Cngzsamp的資料庫別名}
        if answer = IDCANCEL then
        begin
          ap.Free;
          Exit;
        end;
        Session.AddStandardAlias(DTS_ALIAS_NAME, 'e:\', 'Microsoft dBase Driver (*.dbf)');
        Session.SaveConfigFile; {BDE配置文件存檔}
      end;  ap.Clear; {取得別名Cngzsamp中的所有表格名稱列表}
      Session.GetTableNames(DTS_ALIAS_NAME, '', False, False, ap);
      if (ap.IndexOf('TSK') = -1) then {判斷表格是否存在}
      begin
        answer := Application.MessageBox('別名Cntssamp中不存在表格TSK,現在創建嗎?',
          '表格資訊視窗', mb_OKCancel);
        if answer = IDCANCEL then
        begin
          ap.Free;
          Exit;
        end;
        with table1 do
        begin
          Active := false;
          DatabaseName := DTS_ALIAS_NAME; {資料庫別名}
          TableName := 'TSK'; {表格名}
          TableType := ttDBase; {資料庫類型}
          with FieldDefs do {增加欄位}
          begin
            Clear;
            Add('SH', ftString, 30, False); {書號 String(30)}
            Add('SM', ftString, 30, False); {書名 String(30)}
            Add('CBS', ftString, 20, False); {出版社 String(20)}
            Add('CBRQ', ftDate, 0, False); {出版日期 Date}
            Add('YS', ftInteger, 0, False); {頁數 Integer}
          end;
          with IndexDefs do {增加索引}
          begin
            Clear; {按書號欄位建立主索引}
            Add('SHSY', 'SH', [ixPrimary, ixUnique]);
          end;
          CreateTable; {創建表格}
        end;
      end;
      ap.free; {釋放變數ap}end;===========================
    調用Session.GetAliasParams();
    這個方法獲取別名的參數, 參數內有Path=xxxx(:\aslkdfjasfd)
    讀取Path的值搞定!!!不過分太少.這種系統性的問題建義加分!!!