Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How can I display some fields from my application's version information Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
31-Oct-03
Category
System
Language
Delphi 3.x
Views
190
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			 Author: Igor Siticov

How can I display some fields from my application's version information?

Answer:

I provide you the object that could be used for extracting version information from 
executables and libraries. 

1   unit siverinfo;
2   
3   interface
4   uses Windows, Classes, SysUtils;
5   
6   type
7     TVersionInfo = class(TObject)
8     private
9       FData: Pointer;
10      FSize: Cardinal;
11      FCompanyName: string;
12      FFileDescription: string;
13      FFileVersion: string;
14      FInternalName: string;
15      FLegalCopyright: string;
16      FLegalTrademarks: string;
17      FOriginalFilename: string;
18      FProductName: string;
19      FProductVersion: string;
20      FComments: string;
21    public
22      constructor Create(FileName: string);
23      destructor Destroy; override;
24      property CompanyName: string read FCompanyName;
25      property FileDescription: string read FFileDescription;
26      property FileVersion: string read FFileVersion;
27      property InternalName: string read FInternalName;
28      property LegalCopyright: string read FLegalCopyright;
29      property LegalTrademarks: string read FLegalTrademarks;
30      property OriginalFilename: string read FOriginalFilename;
31      property ProductName: string read FProductName;
32      property ProductVersion: string read FProductVersion;
33      property Comments: string read FComments;
34    end;
35  
36  implementation
37  { TVersionInfo }
38  
39  constructor TVersionInfo.Create(FileName: string);
40  var
41    sz, lpHandle, tbl: Cardinal;
42    lpBuffer: Pointer;
43    str: PChar;
44    strtbl: string;
45    int: PInteger;
46    hiW, loW: Word;
47  begin
48    inherited Create;
49    FSize := GetFileVersionInfoSize(PChar(FileName), lpHandle);
50    FData := AllocMem(FSize);
51    GetFileVersionInfo(PChar(FileName), lpHandle, FSize, FData);
52  
53    VerQueryValue(FData, '\\VarFileInfo\Translation', lpBuffer, sz);
54    int := lpBuffer;
55    hiW := HiWord(int^);
56    loW := LoWord(int^);
57    tbl := (loW shl 16) or hiW;
58    strtbl := Format('%x', [tbl]);
59    if Length(strtbl) < 8 then
60      strtbl := '0' + strtbl;
61  
62    VerQueryValue(FData, PChar('\\StringFileInfo\' + strtbl + '\CompanyName'), 
63  lpBuffer,
64      sz);
65    str := lpBuffer;
66    FCompanyName := str;
67  
68    VerQueryValue(FData, PChar('\\StringFileInfo\' + strtbl + '\FileDescription'),
69      lpBuffer, sz);
70    str := lpBuffer;
71    FFileDescription := str;
72  
73    VerQueryValue(FData, PChar('\\StringFileInfo\' + strtbl + '\FileVersion'), 
74  lpBuffer,
75      sz);
76    str := lpBuffer;
77    FFileVersion := str;
78  
79    VerQueryValue(FData, PChar('\\StringFileInfo\' + strtbl + '\InternalName'),
80      lpBuffer, sz);
81    str := lpBuffer;
82    FInternalName := str;
83  
84    VerQueryValue(FData, PChar('\\StringFileInfo\' + strtbl + '\LegalCopyright'),
85      lpBuffer, sz);
86    str := lpBuffer;
87    FLegalCopyright := str;
88  
89    VerQueryValue(FData, PChar('\\StringFileInfo\' + strtbl + '\LegalTrademarks'),
90      lpBuffer, sz);
91    str := lpBuffer;
92    FLegalTrademarks := str;
93  
94    VerQueryValue(FData, PChar('\\StringFileInfo\' + strtbl + '\OriginalFilename'),
95      lpBuffer, sz);
96    str := lpBuffer;
97    FOriginalFilename := str;
98  
99    VerQueryValue(FData, PChar('\\StringFileInfo\' + strtbl + '\ProductName'), 
100 lpBuffer,
101     sz);
102   str := lpBuffer;
103   FProductName := str;
104 
105   VerQueryValue(FData, PChar('\\StringFileInfo\' + strtbl + '\ProductVersion'),
106     lpBuffer, sz);
107   str := lpBuffer;
108   FProductVersion := str;
109 
110   VerQueryValue(FData, PChar('\\StringFileInfo\' + strtbl + '\Comments'), lpBuffer,
111     sz);
112   str := lpBuffer;
113   FComments := str;
114 end;
115 
116 destructor TVersionInfo.Destroy;
117 begin
118   FreeMem(FData);
119   inherited;
120 end;
121 
122 end.


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC