BDE - saber se esta instalado e se o level esta ok |
Top Previous Next |
|
// o BDE está instalado? function BDEInstalado: Boolean; const Chave = 'SOFTWARE\Borland\Database Engine\Settings\DRIVERS\DBASE\TABLE CREATE'; var Reg: TRegistry; begin Reg := TRegistry.Create; Reg.RootKey := HKEY_LOCAL_MACHINE; Reg.OpenKey(Chave, True); Result := Reg.ValueExists('LEVEL'); if not Result then msgErro('É necessário o BDE para a execução deste sistema!!'); FreeAndNil(Reg); end;
// só para DBF: saber se o level é 5 function LevelBDEOK: Boolean; const Chave = 'SOFTWARE\Borland\Database Engine\Settings\DRIVERS\DBASE\TABLE CREATE'; var Reg: TRegistry; Lvl: Integer; begin Lvl := 0; Reg := TRegistry.Create; Reg.RootKey := HKEY_LOCAL_MACHINE; Reg.OpenKey(Chave, True);
if Reg.ValueExists('LEVEL') then Lvl := StrToIntDef(Reg.ReadString('LEVEL'), 0); // nao coloque READINTEGER aqui... Dá pau FreeAndNil(Reg);
if Lvl = 0 then msgInforma('É necessário o BDE para a execução deste sistema!!') else if Lvl <> 5 then msgInforma('O Level do BDE está incorreto!'); Result := (Lvl = 5); end;
/////////// EXEMPLO: coloque no DPR:
program ConfigPrinter;
uses Forms, ARotinas2Unit, ConfigPrinterUnit in 'ConfigPrinterUnit.pas' {ConfigPrinterForm}, AjudaUnit in 'AjudaUnit.pas' {AjudaForm};
{$R *.res}
begin if not BDEInstalado then Exit; if not LevelBDEOK then Exit;
Application.Initialize; Application.CreateForm(TConfigPrinterForm, ConfigPrinterForm); Application.Run; end. . |