home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 October / Chip_2001-10_cd1.bin / zkuste / delphi / kompon / d56 / MSYSINFO.ZIP / Source / MSI_Engines.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  2001-07-24  |  3.4 KB  |  131 lines

  1.  
  2. {*******************************************************}
  3. {                                                       }
  4. {       MiTeC System Information Component              }
  5. {               Engine Detection Part                   }
  6. {           version 6.0 for Delphi 5,6                  }
  7. {                                                       }
  8. {       Copyright ⌐ 1997,2001 Michal Mutl               }
  9. {                                                       }
  10. {*******************************************************}
  11.  
  12. {$INCLUDE MITEC_DEF.INC}
  13.  
  14. unit MSI_Engines;
  15.  
  16. interface
  17.  
  18. uses
  19.   {$IFDEF D6PLUS} Variants, {$ENDIF}
  20.   SysUtils, Windows, Classes;
  21.  
  22. type
  23.   TEngines = class(TPersistent)
  24.   private
  25.     FBDE: string;
  26.     FODBC: string;
  27.     FDAO: string;
  28.     FADO: string;
  29.   public
  30.     procedure GetInfo;
  31.     procedure Report(var sl :TStringList);
  32.   published
  33.     property ODBC :string read FODBC {$IFNDEF D6PLUS} write FODBC {$ENDIF} stored false;
  34.     property BDE :string read FBDE {$IFNDEF D6PLUS} write FBDE {$ENDIF} stored false;
  35.     property DAO :string read FDAO {$IFNDEF D6PLUS} write FDAO {$ENDIF} stored False;
  36.     property ADO :string read FADO {$IFNDEF D6PLUS} write FADO {$ENDIF} stored False;
  37.   end;
  38.  
  39. implementation
  40.  
  41. uses Registry, MiTeC_Routines, COMObj;
  42.  
  43. { TEngines }
  44.  
  45. procedure TEngines.GetInfo;
  46. var
  47.   s,s1 :string;
  48.   OLEObj: OLEVariant;
  49. const
  50.   rkBDESettings = {HKEY_LOCAL_MACHINE\}'SOFTWARE\Borland\Database Engine';
  51.     rvBDEDLLPath = 'DLLPATH';
  52.     fnBDEDLL = 'IDAPI32.DLL';
  53.   rkODBCSettings = {HKEY_LOCAL_MACHINE\}'SOFTWARE\ODBC\ODBCINST.INI\ODBC Core\FileList';
  54.     rvODBCCoreDLL = 'ODBC32.DLL';
  55.  
  56.   { OLE object table class string }
  57.   daoEngine36 = 'DAO.DBEngine.36';
  58.   daoEngine35 = 'DAO.DBEngine.35';
  59.   daoEngine30 = 'DAO.DBEngine';
  60.  
  61.   adoEngine = 'adodb.connection';
  62.  
  63.   function GetOLEObject(CLSID: string): OLEVariant;
  64.   begin
  65.     try
  66.       result:=GetActiveOLEObject(CLSID);
  67.     except
  68.       try
  69.         result:=CreateOLEObject(CLSID);
  70.       except
  71.         result:=null;
  72.       end;
  73.     end;
  74.   end;
  75.  
  76. begin
  77.   with TRegistry.Create do begin
  78.     rootkey:=HKEY_LOCAL_MACHINE;
  79.     if OpenKey(rkBDESettings,false) then begin
  80.       if ValueExists(rvBDEDLLPath) then begin
  81.         s:=ReadString(rvBDEDLLPath);
  82.         FBDE:=readverinfo(s+'\'+fnBDEDLL,s1);
  83.       end;
  84.       closekey;
  85.     end;
  86.     if OpenKey(rkODBCSettings,false) then begin
  87.       if ValueExists(rvODBCCoreDLL) then begin
  88.         s:=ReadString(rvODBCCoreDLL);
  89.         FODBC:=readverinfo(s,s1);
  90.       end;
  91.       closekey;
  92.     end;
  93.     free;
  94.   end;
  95.  
  96.   OLEObj:=GetOLEObject(daoEngine36);
  97.   if TVarData(OLEObj).VType<>varDispatch then
  98.     OLEObj:=GetOLEObject(daoEngine35);
  99.   if TVarData(OLEObj).VType<>varDispatch then
  100.     OLEObj:=GetOLEObject(daoEngine30);
  101.   if TVarData(OLEObj).VType=varDispatch then
  102.     FDAO:=OLEObj.Version;
  103.   OLEObj:=null;
  104.  
  105.   OLEObj:=GetOLEObject(adoEngine);
  106.   if TVarData(OLEObj).VType=varDispatch then
  107.     FADO:=OLEObj.Version;
  108.   OLEObj:=null;
  109. end;
  110.  
  111. procedure TEngines.Report(var sl: TStringList);
  112. begin
  113.   with sl do begin
  114.     Add('[ODBC]');
  115.     if ODBC<>'' then
  116.       Add(Format('Version=%s',[ODBC]));
  117.     Add('[BDE]');
  118.     if BDE<>'' then
  119.       Add(Format('Version=%s',[BDE]));
  120.     Add('[DAO]');
  121.     if DAO<>'' then
  122.       Add(Format('Version=%s',[DAO]));
  123.     Add('[ADO]');
  124.     if ADO<>'' then
  125.       Add(Format('Version=%s',[ADO]));
  126.   end;
  127. end;
  128.  
  129.  
  130. end.
  131.