Как узнать физическое расположение локальной БД по Alias?

Previous  Top  Next

    
 

 

 

По Table(Query).Database:

Code:

uses

DbiProcs;

 

function GetDirByDatabase(Database: TDatabase): string;

var

pszDir: PChar;

begin

pszDir := StrAlloc(255);

try

   DbiGetDirectory(Database.Handle, True, pszDir);

   Result := StrPas(pszDir);

finally

   StrDispose(pszDir);

end;

end;

 

 

По алиасу:

Code:

function GetPhNameByAlias(sAlias: string): string;

var

Database: TDatabase;

pszDir: PChar;

begin

Database := TDatabase.Create(nil); {allocate memory}

pszDir := StrAlloc(255);

try

   Database.AliasName := sAlias;

   Database.DatabaseName := 'TEMP'; {requires a name -- is ignored}

   Database.Connected := True; {connect without opening any table}

   DbiGetDirectory(Database.Handle, True, pszDir); {get the dir.}

   Database.Connected := False; {disconnect}

   Result := StrPas(pszDir); {convert to a string}

finally

   Database.Free; {free memory}

end;

end;

 

 

 

©Drkb::02538

       

Взято с http://delphiworld.narod.ru