Solved

VerFindFile and related

Posted on 2000-03-08
2
301 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

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…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

751 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