delphi3000.com - the free delphi knowledge platform
delphi3000.com - the free delphi knowledge platform
Have a look at your member-status

connecting people's knowledge


  - Recent ArticlesRSS feed for Recent Articles on delphi3000.com
  - List of All Articles
  - Top Viewed Articles
  - Articles (+Attachem.)
  - Articles Of Interest
  - Categories
  - Top Uploader
  - Search
  - Index

  - My Home
  - Submit an Article
  - My Articles
  - My Personal Data
  - My Bookmarks
  - Activities
  - Login/Logout

  - Sign Up
  - Why Sign Up
  - Newsletter

  - Press
  - Advertise

  - Contact
  - Feedback



Community
Borland
ClubeDelphi
Dr. Bob
UK-BUG
Delphi Meetings
Planeta Delphi








Share this article with friendsShare this article with friends
Rate this articleRate this article - to keep the quality of delphi3000.com !
Comment this article or read through previous comments (3)


How to extract exe/dll/ocx ... file informationGo to Rafael Ribas Aguiló's websiteComponent available for this articleFormat this article printer-friendly!Bookmark function is only available for registered users!
Product:
Delphi all versions
Category:
Files Operation
Skill Level:
Scoring:
Last Update:
11/23/2001
Search Keys:
delphi delphi3000 article borland vcl code-snippet file version dll exe
Times Scored:
4
Visits:
3713
Uploader: Rafael Ribas Aguiló
Company: SEF-RJ
Reference: www.facilities.com.br
Component Download: ../www.facilities.com.br
 
Question/Problem/Abstract:
If you want to check a file version or product name of an existing system dll, or you are creating an install program that only installs newer versions of dll or exe.
* Works with all Delphi versions
Answer:



It´s a simple function that retuns the iformation requested. You can use a VersionInfo array element to pass as the parameter:

  Label1.Caption := GetFileInfo('c:\windows\explorer.exe', VersionInfo[3]);
or
  Label1.Caption := GetFileInfo('c:\windows\explorer.exe', 'FileVersion');


===============================================
unit lFilever;
interface
uses
  WinTypes, WinProcs, SysUtils {$IFNDEF WIN32} ,Ver {$ENDIF};
const
  VersionInfo: array [1..8] of string = (
    'CompanyName', 'FileDescription', 'FileVersion', 'InternalName',
    'LegalCopyRight', 'OriginalFileName', 'ProductName', 'ProductVersion');

function GetFileInfo(FName, InfoType: string): string;

implementation

function GetFileInfo(FName, InfoType: string): string;
var
  Info     : Pointer;
  InfoData : Pointer;
  InfoSize : LongInt;
  InfoLen  : {$IFDEF WIN32} DWORD;{$ELSE} LongInt; {$ENDIF}
  DataLen  : {$IFDEF WIN32} UInt; {$ELSE} word; {$ENDIF}
  LangPtr  : Pointer;
begin
  result:=''; DataLen:=255;
  if Length(FName)<=0 then exit;
  FName:=FName+#0;
  InfoSize:=GetFileVersionInfoSize(@Fname[1], InfoLen);
  if (InfoSize > 0) then
    begin
      GetMem(Info, InfoSize);
      try
        if GetFileVersionInfo(@FName[1], InfoLen, InfoSize, Info) then
          begin
            if VerQueryValue(Info,'\VarFileInfo\Translation',LangPtr, DataLen) then
              InfoType:=Format('\StringFileInfo\%0.4x%0.4x\%s'#0,[LoWord(LongInt(LangPtr^)),
                                                                  HiWord(LongInt(LangPtr^)), InfoType]);
            if VerQueryValue(Info,@InfoType[1],InfoData,Datalen) then
              Result := strPas(InfoData);
          end;
      finally
        FreeMem(Info, InfoSize);
      end;
    end;
end;

end.





Please rate this article!
Skill level:
BeginnerExpert

Useful:
No!Very!

Overall rating:
PoorExcellent



Comments to this article
Write a new comment
more ??
    Hagen Reddmann (May 31 2001 3:32AM)

and how can we get non-standard topics ?
usefull would be a list of all VerInfo Entries.


Respond

RE: more ??
Rafael Ribas Aguiló (May 31 2001 8:02AM)

Ok. You can get the list in the Win32.hlp help file that ships with Delphi. Search for "VERSIONINFO Resource" at the "Find" tab.
Respond

RE: RE: more ??
Hagen Reddmann (Jun 7 2001 11:59AM)

Yes I known, but I want to list ALL topics of a VerInfo Resource, included ALL non-standard topics.

Please try in Delphi to add some custom VerInfo Topics to Your Project, that's possible. But I can these only read if I known the names.

Respond














 
Sign up to consume product discounts for Bronze memberships !

read more


   


  Community Ad of
A. B. Talal
 
   














 







     
  Copyright © 2000 - 2007 delphi3000.com - All rights reserved. Terms of use. || Privacy
delphi3000.com is a service by bluestep.com IT-Services GmbH (Vienna)