ReactOS 0.4.16-dev-1273-g5b94656
CFileVersionInfo Class Reference

#include <filedefext.h>

Collaboration diagram for CFileVersionInfo:

Classes

struct  _LANGANDCODEPAGE_
 

Public Member Functions

 CFileVersionInfo ()
 
 ~CFileVersionInfo ()
 
BOOL Load (LPCWSTR pwszPath)
 
LPCWSTR GetString (LPCWSTR pwszName)
 
VS_FIXEDFILEINFOGetFixedInfo ()
 
LPCWSTR GetLangName ()
 

Private Types

typedef struct CFileVersionInfo::_LANGANDCODEPAGE_ LANGANDCODEPAGE
 
typedef struct CFileVersionInfo::_LANGANDCODEPAGE_LPLANGANDCODEPAGE
 

Private Attributes

PVOID m_pInfo
 
WORD m_wLang
 
WORD m_wCode
 
WCHAR m_wszLang [64]
 

Detailed Description

Definition at line 24 of file filedefext.h.

Member Typedef Documentation

◆ LANGANDCODEPAGE

◆ LPLANGANDCODEPAGE

Constructor & Destructor Documentation

◆ CFileVersionInfo()

CFileVersionInfo::CFileVersionInfo ( )
inline

Definition at line 38 of file filedefext.h.

38 :
40 {
41 m_wszLang[0] = L'\0';
42 }
WCHAR m_wszLang[64]
Definition: filedefext.h:29
#define NULL
Definition: types.h:112
#define L(x)
Definition: ntvdm.h:50

◆ ~CFileVersionInfo()

CFileVersionInfo::~CFileVersionInfo ( )
inline

Definition at line 44 of file filedefext.h.

45 {
46 if (m_pInfo)
48 }
#define GetProcessHeap()
Definition: compat.h:736
#define HeapFree(x, y, z)
Definition: compat.h:735

Member Function Documentation

◆ GetFixedInfo()

VS_FIXEDFILEINFO * CFileVersionInfo::GetFixedInfo ( )

Definition at line 191 of file filedefext.cpp.

192{
193 if (!m_pInfo)
194 return NULL;
195
196 VS_FIXEDFILEINFO *pInfo;
197 UINT cBytes;
198 if (!VerQueryValueW(m_pInfo, L"\\", (PVOID*)&pInfo, &cBytes))
199 return NULL;
200 return pInfo;
201}
BOOL WINAPI VerQueryValueW(LPCVOID pBlock, LPCWSTR lpSubBlock, LPVOID *lplpBuffer, PUINT puLen)
Definition: version.c:1171
unsigned int UINT
Definition: ndis.h:50

Referenced by CFileDefExt::InitVersionPage().

◆ GetLangName()

LPCWSTR CFileVersionInfo::GetLangName ( )

Definition at line 203 of file filedefext.cpp.

204{
205 if (!m_pInfo)
206 return NULL;
207
208 if (!m_wszLang[0])
209 {
211 ERR("VerLanguageNameW failed\n");
212 }
213
214 return m_wszLang;
215}
#define ERR(fmt,...)
Definition: precomp.h:57
DWORD WINAPI VerLanguageNameW(DWORD wLang, LPWSTR szLang, DWORD nSize)
Definition: locale.c:3084
#define _countof(array)
Definition: sndvol32.h:70

Referenced by CFileDefExt::InitVersionPage().

◆ GetString()

LPCWSTR CFileVersionInfo::GetString ( LPCWSTR  pwszName)

Definition at line 161 of file filedefext.cpp.

162{
163 if (!m_pInfo)
164 return NULL;
165
166 WCHAR wszBuf[256];
167 swprintf(wszBuf, L"\\StringFileInfo\\%04x%04x\\%s", m_wLang, m_wCode, pwszName);
168
169 /* Query string in version block */
170 LPCWSTR pwszResult = NULL;
171 UINT cBytes = 0;
172 if (!VerQueryValueW(m_pInfo, wszBuf, (LPVOID *)&pwszResult, &cBytes))
173 pwszResult = NULL;
174
175 if (!pwszResult)
176 {
177 /* Try US English */
178 swprintf(wszBuf, L"\\StringFileInfo\\%04x%04x\\%s", MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), 1252, pwszName);
179 if (!VerQueryValueW(m_pInfo, wszBuf, (LPVOID *)&pwszResult, &cBytes))
180 pwszResult = NULL;
181 }
182
183 if (!pwszResult)
184 ERR("VerQueryValueW %ls failed\n", pwszName);
185 else
186 TRACE("%ls: %ls\n", pwszName, pwszResult);
187
188 return pwszResult;
189}
#define swprintf
Definition: precomp.h:40
#define MAKELANGID(p, s)
Definition: nls.h:15
#define LANG_ENGLISH
Definition: nls.h:52
#define SUBLANG_ENGLISH_US
Definition: nls.h:222
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

Referenced by CFileDefExt::AddVersionString(), CFileDefExt::InitGeneralPage(), CFileDefExt::InitOpensWithField(), and CFileDefExt::SetVersionLabel().

◆ Load()

BOOL CFileVersionInfo::Load ( LPCWSTR  pwszPath)

Definition at line 120 of file filedefext.cpp.

121{
122 ULONG cbInfo = GetFileVersionInfoSizeW(pwszPath, NULL);
123 if (!cbInfo)
124 {
125 WARN("GetFileVersionInfoSize %ls failed\n", pwszPath);
126 return FALSE;
127 }
128
130 if (!m_pInfo)
131 {
132 ERR("HeapAlloc failed bytes %x\n", cbInfo);
133 return FALSE;
134 }
135
136 if (!GetFileVersionInfoW(pwszPath, 0, cbInfo, m_pInfo))
137 {
138 ERR("GetFileVersionInfoW failed\n");
139 return FALSE;
140 }
141
142 LPLANGANDCODEPAGE lpLangCode;
143 UINT cBytes;
144 if (!VerQueryValueW(m_pInfo, L"\\VarFileInfo\\Translation", (LPVOID *)&lpLangCode, &cBytes) || cBytes < sizeof(LANGANDCODEPAGE))
145 {
146 ERR("VerQueryValueW failed\n");
147 return FALSE;
148 }
149
150 /* FIXME: find language from current locale / if not available,
151 * default to english
152 * for now default to first available language
153 */
154 m_wLang = lpLangCode->wLang;
155 m_wCode = lpLangCode->wCode;
156 TRACE("Lang %hx Code %hu\n", m_wLang, m_wCode);
157
158 return TRUE;
159}
#define WARN(fmt,...)
Definition: precomp.h:61
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define HeapAlloc
Definition: compat.h:733
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
BOOL WINAPI GetFileVersionInfoW(LPCWSTR filename, DWORD handle, DWORD datasize, LPVOID data)
Definition: version.c:967
DWORD WINAPI GetFileVersionInfoSizeW(LPCWSTR filename, LPDWORD handle)
Definition: version.c:738
uint32_t ULONG
Definition: typedefs.h:59

Referenced by CFileDefExt::Initialize(), and CFileDefExt::InitOpensWithField().

Member Data Documentation

◆ m_pInfo

PVOID CFileVersionInfo::m_pInfo
private

Definition at line 27 of file filedefext.h.

Referenced by GetFixedInfo(), GetLangName(), GetString(), Load(), and ~CFileVersionInfo().

◆ m_wCode

WORD CFileVersionInfo::m_wCode
private

Definition at line 28 of file filedefext.h.

Referenced by GetString(), and Load().

◆ m_wLang

WORD CFileVersionInfo::m_wLang
private

Definition at line 28 of file filedefext.h.

Referenced by GetLangName(), GetString(), and Load().

◆ m_wszLang

WCHAR CFileVersionInfo::m_wszLang[64]
private

Definition at line 29 of file filedefext.h.

Referenced by CFileVersionInfo(), and GetLangName().


The documentation for this class was generated from the following files: