[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

bde/tutil32 version number

Posted on 1998-04-29
5
Medium Priority
?
225 Views
Last Modified: 2010-04-06
Does anyone know how I can get the tutil32.dll and bde version numbers? Thanks, Tom.
0
Comment
Question by:boardtc
  • 3
  • 2
5 Comments
 
LVL 5

Accepted Solution

by:
JimBob091197 earned 200 total points
ID: 1339394
Hi Tom

The following functions should do it for you.

(GetDllVersion is defined at the bottom.)

type
  TVersionNumber = Record
    MS1          : Word;
    MS2          : Word;
    LS1          : Word;
    LS2          : Word;
  end;

function GetTUtilVersion: string;
var
  VerRec: TVersionNumber;
begin
  // VerRec structure is filled, AND a string is returned.
  Result := GetDllVersion(VerRec, 'TUTIL32.DLL');
end;

function GetBdeVersion: string;
var
  Registry : TRegistry;
      BDEDir : String;
  VerRec: TVersionNumber;
begin
  // VerRec structure is filled, AND a string is returned.

      Registry := TRegistry.Create;
      Registry.RootKey := HKEY_LOCAL_MACHINE;
      If Registry.OpenKey('Software\Borland\Database Engine', FALSE) then
      begin
            BDEDir := Registry.ReadString('DLLPATH');
            while (Pos(';', BDEDir) > 0) do
                  BDEDir := Copy(BDEDir, Pos(';', BDEDir) + 1, MaxInt);

            if BDEDir[length(BDEDir)] <> '\' then
                  BDEDir := BDEDir + '\';
            BDEDir := BDEDir + 'Idapi32.dll';
    Result := GetDllVersion(VerRec, BDEDir);
      end
      else
    Result := '';
      Registry.Free;
end;

function GetDllVersion(var VerRec : TVersionNumber; TheDllName: string): string;
type
   PFixedFileInfo = PVSFixedFileInfo;
var
  UTVerInfo : Pointer;
  PFixedInfo : Pointer;
  VerInfoSize : DWORD;
  VerHandle : DWORD;
  RetLen : Integer;
  FileNulStr : DBITBLNAME;
begin
  VerInfoSize := GetFileVersionInfoSize(StrPCopy(FileNulStr, TheDllName), VerHandle);
  If VerInfoSize > 0 then
  begin
    GetMem(UTVerInfo, VerInfoSize);
    GetFileVersionInfo(
       FileNulStr,
       VerHandle,
       VerInfoSize,
       UTVerInfo);
    VerQueryValue(UTVerInfo, '\' , PFixedInfo, RetLen);
    VerRec.MS1 := HIWORD(PFixedFileInfo(PFixedInfo)^.dwFileVersionMS);
    VerRec.MS2 := LOWORD(PFixedFileInfo(PFixedInfo)^.dwFileVersionMS);
            VerRec.LS1 := HIWORD(PFixedFileInfo(PFixedInfo)^.dwFileVersionLS);
            VerRec.LS2 := LOWORD(PFixedFileInfo(PFixedInfo)^.dwFileVersionLS);
            Result := IntToStr(VerRec.MS1) + '.' +
                                          IntToStr(VerRec.MS2) + '.' +
                                          IntToStr(VerRec.LS1) + '.' +
                                          IntToStr(VerRec.LS2);
            FreeMem(UTVerInfo, VerInfoSize);
      end
      else
    Result := '';
end;

Cheers,
JB
0
 
LVL 5

Expert Comment

by:JimBob091197
ID: 1339395
Oh yeah, add Bde and Registry to your uses clause.
JB
0
 

Author Comment

by:boardtc
ID: 1339396
Thanks a million Jim Bob, I'll try that out. Tom.
0
 

Author Comment

by:boardtc
ID: 1339397
Jim Bob, Awesome stuff my man, worked like a charm, nice code for the reg to, used it to run bde admin from the prog also. Tom.
0
 
LVL 5

Expert Comment

by:JimBob091197
ID: 1339398
Hi Tom,
Thanks, but I can't take all the credit.  We use this code in our company, and I didn't write it originally, although I did fix 2 bugs that it had.

Cheers,
JB
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses
Course of the Month18 days, 8 hours left to enroll

825 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question