Como faço para saber se o bde já está instalado na máquina ?

Delphi

20/05/2003

PRECISO DESCOBRIR SE O BDE ESTÁ INSTALADO NA MÁQUINA...SE NAUM ESTIVER MINHA APLICAÇÃO VAI INSTALAR SE JÁ TIVER INSTALADO SÓ VOU CRIAR O ALIAS..CREIO QUE SEJA SIMPLES ALGUÉM PODE ME AJUDAR ???
AGRADEÇO ANTECIPADAMENTE !!!


Morpheus

Morpheus

Curtidas 0

Respostas

Neo_coder®

Neo_coder®

20/05/2003

Vc pode checar se esta chave se encontra no registro:

HKEY_LOCAL_MACHINE\SOFTWARE\Borland\Database Engine



Tenho este código de exemplo abaixo, mas só irá funcionar em win2000 em contas com direito de Administrador.



procedure TfmStopBDE.ReadWriteBDEStatus( Writing : Boolean;
WantBDEOn: Boolean);
{----------------------------------------------------------------------------------------------------------------------}
{ Read or write the value for the BDE path in the registry. }
{ If Writing is True, then the WantBDEValue will uncomment the registry path, otherwise it comments the registry path. }
{ If Writing is False, then it reads the BDE path in the registry and assigns it to the variable BDEDir (the registry }
{ is not changed and the WantBDEOn variable is ignored. }
{----------------------------------------------------------------------------------------------------------------------}
begin
BDEDir := ´´;
with TRegistry.Create do
try
RootKey := HKEY_LOCAL_MACHINE;
if OpenKey(cBDEKey, False) then
begin
BDEDir := ReadString(cBDEValue);
if Writing then
begin
if WantBDEOn and (Copy(BDEDir,1,1) = cComment) then
Delete(BDEDir,1,1)
else if not(WantBDEOn) and (Copy(BDEDir,1,1) <> cComment) then
BDEDir := cComment + BDEDir;
WriteString(cBDEValue, BDEDir);
end;
end
else
begin
buOn.Enabled := false;
buOff.Enabled := false;
Raise Exception.Create(´BDE is not installed´+#1310+
´Registry Key: HKEY_LOCAL_MACHINE´+cBDEKey+´´ is missing in the registry.´);
end;
finally
Free;
StatusBar1.SimpleText := BDEDir;
end;
end;


Jesus Cristo Vive e é o Senhor.


GOSTEI 0
Carnette

Carnette

20/05/2003

PRECISO DESCOBRIR SE O BDE ESTÁ INSTALADO NA MÁQUINA...SE NAUM ESTIVER MINHA APLICAÇÃO VAI INSTALAR SE JÁ TIVER INSTALADO SÓ VOU CRIAR O ALIAS..CREIO QUE SEJA SIMPLES ALGUÉM PODE ME AJUDAR ??? AGRADEÇO ANTECIPADAMENTE !!!


Função para descobrir se o BDE existe na máquina

uses
BDE;

function CheckBDEInstalled: Boolean;
begin
Result := (dbiInit(nil) = DBIERR_NONE)
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
if CheckBDEInstalled then
ShowMessage(´BDE is installed.´)
else
ShowMessage(´BDE is not installed.´)
end;


GOSTEI 0
POSTAR