Solved

VerFindFile and related

Posted on 2000-03-08
2
296 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

810 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