ReactOS 0.4.15-dev-7918-g2a2556c
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 153 of file filedefext.cpp.

154{
155 if (!m_pInfo)
156 return NULL;
157
158 VS_FIXEDFILEINFO *pInfo;
159 UINT cBytes;
160 if (!VerQueryValueW(m_pInfo, L"\\", (PVOID*)&pInfo, &cBytes))
161 return NULL;
162 return pInfo;
163}
BOOL WINAPI VerQueryValueW(LPCVOID pBlock, LPCWSTR lpSubBlock, LPVOID *lplpBuffer, PUINT puLen)
Definition: version.c:1049
unsigned int UINT
Definition: ndis.h:50

Referenced by CFileDefExt::InitVersionPage().

◆ GetLangName()

LPCWSTR CFileVersionInfo::GetLangName ( )

Definition at line 165 of file filedefext.cpp.

166{
167 if (!m_pInfo)
168 return NULL;
169
170 if (!m_wszLang[0])
171 {
173 ERR("VerLanguageNameW failed\n");
174 }
175
176 return m_wszLang;
177}
#define ERR(fmt,...)
Definition: debug.h:110
DWORD WINAPI VerLanguageNameW(DWORD wLang, LPWSTR szLang, DWORD nSize)
Definition: lang.c:1699
#define _countof(array)
Definition: sndvol32.h:68

Referenced by CFileDefExt::InitVersionPage().

◆ GetString()

LPCWSTR CFileVersionInfo::GetString ( LPCWSTR  pwszName)

Definition at line 123 of file filedefext.cpp.

124{
125 if (!m_pInfo)
126 return NULL;
127
128 WCHAR wszBuf[256];
129 swprintf(wszBuf, L"\\StringFileInfo\\%04x%04x\\%s", m_wLang, m_wCode, pwszName);
130
131 /* Query string in version block */
132 LPCWSTR pwszResult = NULL;
133 UINT cBytes = 0;
134 if (!VerQueryValueW(m_pInfo, wszBuf, (LPVOID *)&pwszResult, &cBytes))
135 pwszResult = NULL;
136
137 if (!pwszResult)
138 {
139 /* Try US English */
140 swprintf(wszBuf, L"\\StringFileInfo\\%04x%04x\\%s", MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), 1252, pwszName);
141 if (!VerQueryValueW(m_pInfo, wszBuf, (LPVOID *)&pwszResult, &cBytes))
142 pwszResult = NULL;
143 }
144
145 if (!pwszResult)
146 ERR("VerQueryValueW %ls failed\n", pwszName);
147 else
148 TRACE("%ls: %ls\n", pwszName, pwszResult);
149
150 return pwszResult;
151}
#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 82 of file filedefext.cpp.

83{
84 ULONG cbInfo = GetFileVersionInfoSizeW(pwszPath, NULL);
85 if (!cbInfo)
86 {
87 WARN("GetFileVersionInfoSize %ls failed\n", pwszPath);
88 return FALSE;
89 }
90
92 if (!m_pInfo)
93 {
94 ERR("HeapAlloc failed bytes %x\n", cbInfo);
95 return FALSE;
96 }
97
98 if (!GetFileVersionInfoW(pwszPath, 0, cbInfo, m_pInfo))
99 {
100 ERR("GetFileVersionInfoW failed\n");
101 return FALSE;
102 }
103
104 LPLANGANDCODEPAGE lpLangCode;
105 UINT cBytes;
106 if (!VerQueryValueW(m_pInfo, L"\\VarFileInfo\\Translation", (LPVOID *)&lpLangCode, &cBytes) || cBytes < sizeof(LANGANDCODEPAGE))
107 {
108 ERR("VerQueryValueW failed\n");
109 return FALSE;
110 }
111
112 /* FIXME: find language from current locale / if not available,
113 * default to english
114 * for now default to first available language
115 */
116 m_wLang = lpLangCode->wLang;
117 m_wCode = lpLangCode->wCode;
118 TRACE("Lang %hx Code %hu\n", m_wLang, m_wCode);
119
120 return TRUE;
121}
#define WARN(fmt,...)
Definition: debug.h:112
#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:845
DWORD WINAPI GetFileVersionInfoSizeW(LPCWSTR filename, LPDWORD handle)
Definition: version.c:611
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: