I'm trying to get the version from a dll file, here is my code:
std::string getVersionNumber()
{
LPCTSTR pFilePath = L"C:\\File.dll";
boost::filesystem::path full_path( boost::filesystem::current_path() );
std::string dllFile = full_path.string() + "/File.dll";
DWORD dwDummy;
DWORD dwFVISize = GetFileVersionInfoSize( pFilePath, &dwDummy );
LPBYTE lpVersionInfo = new BYTE[dwFVISize];
UINT uLen;
VS_FIXEDFILEINFO *lpFfi;
GetFileVersionInfo( pFilePath , 0 , dwFVISize , lpVersionInfo );
VerQueryValue( lpVersionInfo , L"\\" , (LPVOID *)&lpFfi , &uLen );
DWORD dwFileVersionMS = lpFfi->dwFileVersionMS;
DWORD dwFileVersionLS = lpFfi->dwFileVersionLS;
delete [] lpVersionInfo;
std::ostringstream stringStream;
stringStream << HIWORD(dwFileVersionMS) << ".";
stringStream << LOWORD(dwFileVersionMS) << ".";
stringStream << HIWORD(dwFileVersionLS) << ".";
stringStream << LOWORD(dwFileVersionLS);
return (stringStream.str());
}
if I try calling GetFileVersionInfoSize
and GetFileVersionInfo
with pFilePath
as the first parameter, it compiles and runs perfectly.
However, if I try calling them with dllFile
, it (of course) doesn't compile, and any attempt to somehow convert dllFile
to LPCTSTR
gives me rubbish unicode characters.
I'm kinda lost, any ideas?