Solved

VerFindFile and related

Posted on 2000-03-08
2
292 Views
Last Modified: 2010-04-04
Hi, I'm working on an ocx that checks for the version of another ocx and installs a newer version if necessary. It will be run on an NT network embedded in IE.
Can someone provide me with some example code for the GetFileVersionInfo, VerFindFile and VerInstallFile functions ?
0
Comment
Question by:DonBartholomew
2 Comments
 

Accepted Solution

by:
Gurkan earned 100 total points
ID: 2595173
Hi,
This is the GetFileVersionInfo sample


function ReadVersionInfo(sProgram: string;
    Major, Minor, Release, Build : pWord): Boolean;
var
  Info:       PVSFixedFileInfo;
  InfoSize:   Cardinal;
  nHwnd:      DWORD;
  BufferSize: DWORD;
  Buffer:     Pointer;
begin
  Result:=False; //needed?
  BufferSize := GetFileVersionInfoSize(pchar(sProgram),nHWnd); {Get buffer size}
  if BufferSize <> 0 then begin {if zero, there is no version info}
    GetMem( Buffer, BufferSize); {allocate buffer memory}
    try
      if GetFileVersionInfo(PChar(sProgram),nHWnd,BufferSize,Buffer) then begin
        {got version info}
        if VerQueryValue(Buffer, '\', Pointer(Info), InfoSize) then begin
          {got root block version information}
          if Assigned(Major) then Major^ := HiWord(Info^.dwFileVersionMS);
          if Assigned(Minor) then Minor^ := LoWord(Info^.dwFileVersionMS);
          if Assigned(Release) then Release^ := HiWord(Info^.dwFileVersionLS);
          if Assigned(Build) then Build^ := LoWord(Info^.dwFileVersionLS);
          Result:=True;
          end;
        end;
    finally
      FreeMem(Buffer, BufferSize); {release buffer memory}
    end;
  end;
end;

USAGE:

procedure TForm2.Button1Click(Sender: TObject);
var
  major, minor, release, build:word;
begin
ReadVersionInfo(Edit1.Text,@major,@minor,@release,@build);
ShowMessage(Format('major: %d / minor: %d / release %d / build %d', [major,minor,release,build]));
end;

0
 
LVL 1

Author Comment

by:DonBartholomew
ID: 2599939
Thanks for this one. I'll give you half the points, since it's only one of the three functions in the question. It helped for another project, but for ocx's, I found out that if you make them 'signed', the webserver provides automatic installation and updates, without prompting the user.

Cheers, Bartman.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

912 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now