Solved

VerFindFile and related

Posted on 2000-03-08
2
288 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
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
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…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

771 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

10 Experts available now in Live!

Get 1:1 Help Now