The Winamp Remote Control suite
a remote control client and plugin for Winamp 2.x, 5.x
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
VersionInfoU.cpp
Go to the documentation of this file.
1 /*
2 winamp remote control suite ŠPatrick Michael Martin 2000, 2001, 2002
3 
4 Copyright (C) 2000,2001,2002 Patrick M. Martin
5 
6 This program is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License
8 as published by the Free Software Foundation; either version 2
9 of the License, or (at your option) any later version.
10 
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15 
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 
20 Patrick M. Martin may be reached by email at patrickmmartin@gmail.com.
21 */
22 
23 #include <vcl.h>
24 #pragma hdrstop
25 
26 #include "VersionInfoU.h"
27 
28 const int MaxVersionKeys = 10;
29 const AnsiString VersionKeyNames[MaxVersionKeys] =
30  {"CompanyName", "FileDescription", "FileVersion",
31  "InternalName", "LegalCopyright", "LegalTrademarks",
32  "OriginalFilename", "ProductName", "ProductVersion",
33  "Comments"};
34 
35 
36 __fastcall TModuleVersionInfo::TModuleVersionInfo(AnsiString ThisSourceFile)
37 {
38 
39  int ThisInfo;
40  UINT InfoLength;
41  DWORD Len;
42  DWORD Handle;
43  int * PCharset;
44 
45 
46  // Get size of version info
47  Len = GetFileVersionInfoSize (ThisSourceFile.c_str(), &Handle);
48  // Allocate VersionInfo buffer size
49  VersionInfo = new BYTE[Len];
50  // Get version info
51  if (GetFileVersionInfo (ThisSourceFile.c_str(), Handle, Len, VersionInfo))
52  {
53  // Get translation info for Language / CharSet IDs
54  if (VerQueryValue ( (void *) VersionInfo, "\\VarFileInfo\\Translation", (void **) &PCharset, &InfoLength))
55  {
56  LangCharset = AnsiString().sprintf("%.4x%.4x", LOWORD(*PCharset), HIWORD(*PCharset));
57  InfoAvailable = True;
58  // Get standard version information
59  for (ThisInfo = 0 ; ThisInfo < MaxVersionKeys; ThisInfo++)
60  StandardKeys[ThisInfo] = GetKey (VersionKeyNames[ThisInfo]);
61  }
62  }
63  }
64 
65 
67 {
68 
69  if (VersionInfo)
70  delete[] VersionInfo;
71 }
72 
73 
74 AnsiString __fastcall TModuleVersionInfo::GetKey (AnsiString ThisKeyName)
75 {
76  UINT InfoLength;
77  char * buf;
78  AnsiString Result;
79 
80  if (InfoAvailable)
81  {
82  Result.SetLength(255);
83  if (VerQueryValue ( (void *) VersionInfo,
84  AnsiString().sprintf("\\StringFileInfo\\%s\\%s",
85  LangCharset.c_str(),
86  ThisKeyName.c_str()
87  ).c_str(),
88  (void **) &buf, &InfoLength))
89 
90 
91  {
92  Result = buf;
93  }
94  else
95  {
96  Result = "";
97  }
98  }
99  else
100  {
101  Result = "N/A";
102  }
103  return Result;
104 
105 
106 }
107 
108 AnsiString __fastcall TModuleVersionInfo::GetVersionInfo (int Index)
109 {
110 
111  return StandardKeys[Index];
112 
113 }
114 
115 
116 
117 
118 
119 #pragma package(smart_init)