Como trocar via código o Net Dir do BDE...

Delphi

25/02/2008

Tem como trocar os dados no campo Net Dir do BDE via código?


Janete

Janete

Curtidas 0

Respostas

Ffabiop

Ffabiop

25/02/2008

De uma pesquisada no componente Session, nele você pode atribuir o Netdir de acordo com a aplicação.


GOSTEI 0
Maiconseccatto

Maiconseccatto

25/02/2008

uses bde

procedure ChangeNetDir(Drive: Char);
var
  hCur: hDBICur;
  Config: CFGDesc;
  Cont: Boolean;
begin
  if DbiInit(nil) = DBIERR_NONE then
  begin
  hCur := nil;
  if DbiOpenCfgInfoList(nil, dbiREADWRITE, cfgPersistent,
  ´\DRIVERS\PARADOX\INIT´, hCur) = DBIERR_NONE then
  begin
  if DbiSetToBegin(hCur) = DBIERR_NONE then
  begin
  Cont := True;
  while Cont do
  begin
  if (DbiGetNextRecord(hCur, dbiWRITELOCK, @Config, nil)
  <> DBIERR_NONE) then
  Cont := False
  else if StrIComp(Config.szNodeName, ´NET DIR´) = 0 then
  begin
  StrPCopy(Config.szValue, Drive);
  DbiModifyRecord(hCur, @Config, True);
  Cont := False
  end;
  end;
  end;
  end;
  DbiExit();
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
ChangeNetDir(´c:\seudiretorio´);
end;





GOSTEI 0
POSTAR