Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

VerFindFile and related

Posted on 2000-03-08
2
Medium Priority
?
318 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 400 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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

783 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