27 #include "precompiled.h"
39 #pragma comment(lib, "version.lib") // DLL version
51 const DWORD ver_size = GetFileVersionInfoSizeW(
OsString(modulePathname).c_str(), &unused);
56 HMODULE hModule = LoadLibraryExW(
OsString(modulePathname).c_str(), 0, LOAD_LIBRARY_AS_DATAFILE);
63 shared_ptr<u8> mem =
Allocate(ver_size);
64 if(!GetFileVersionInfoW(
OsString(modulePathname).c_str(), 0, ver_size, mem.get()))
69 const BOOL ok = VerQueryValueW(mem.get(), L
"\\VarFileInfo\\Translation", (
void**)&lang, &lang_len);
70 if(!ok || !lang || lang_len != 4)
74 swprintf_s(subblock,
ARRAY_SIZE(subblock), L
"\\StringFileInfo\\%04X%04X\\FileVersion", lang[0], lang[1]);
75 const wchar_t* in_ver;
77 if(!VerQueryValueW(mem.get(), subblock, (
void**)&in_ver, &in_ver_len))
80 wcscpy_s(out_ver, out_ver_len, in_ver);
93 OsPath modulePathname(pathname);
100 wchar_t versionString[500];
114 list += moduleName.Filename().string();
116 list += versionString;
shared_ptr< u8 > Allocate(size_t size)
static Status ReadVersionString(const OsPath &modulePathname, wchar_t *out_ver, size_t out_ver_len)
some WinAPI functions SetLastError(0) on success, which is bad because it can hide previous errors...
int swprintf_s(wchar_t *buf, size_t max_chars, const wchar_t *fmt,...) WPRINTF_ARGS(3)
int wcscpy_s(wchar_t *dst, size_t max_dst_chars, const wchar_t *src)
const Status NOT_SUPPORTED
void wdll_ver_Append(const OsPath &pathname, VersionList &list)
Read DLL version information and append it to a string.
i64 Status
Error handling system.
Path ChangeExtension(Path extension) const
#define WARN_RETURN(status)
static std::string OsString(const OsPath &path)