KenAs 0 Newbie Poster

Any ideas on detecting the current version of the MySQL ODBC driver?

Currently I am reading the registry to obtain the version:

Function  MySQLVersion:String;
Var TR : TRegistry;
    SL : TStringList;
    I  : Integer;
  Begin
    Result := 'ODBC 3.51';          // Default version
    SL := TStringList.Create;
    TR := TRegistry.Create;
    TR.RootKey := HKEY_LOCAL_MACHINE;
    If Not(TR.KeyExists('SOFTWARE\\MySQL AB\\'))
      Then Exit;
    If TR.OpenKey('SOFTWARE\MySQL AB\',False)
      Then Begin
             TR.GetKeyNames(SL);
             I := StartsLineIndex(SL,'MySQL Connector');   // Find the index of the line starting with 'MySQL Connector'
             If (I>=0)
               Then Result := RightPart(SL[I],'/');    // Get the right side of the string after '/'
           End;
    SL.Free;
    TR.Free;
  End;

This presents a couple of problems:

1: If one version has been uninstalled and a new version installed then both items are left in the registry.

2: Some computers give me (permission?) problems reading the registry.

Any help would be appreciated.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.