473,805 Members | 1,939 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Obtaining File Version Information (VerQueryValue) Queries

Hi, not sure if this is the right place for this but it was definitely the
closest I could find.

I am having trouble with the GetFileVersionI nformation/VerQueryValue
functions and was wondering if anyone could help.

All I am trying to do is obtain a string representation of a Version Info
value for a given file. Currently, I am only getting strange unicode
characters, so not sure if my problem is in the understanding of the
functions or of the syntax surrounding char sequences/pointers. I am not
totally at ease with the information in the Win32 API about VerQueryValue to
be honest with you.

Here is the code I am currently using:

LPDWORD temp; //dummy value for GetFileVersionI nfoSize function
DWORD size = GetFileVersionI nfoSize((char*) name.c_str(), temp); //Store size
of version info
delete temp; //delete dummy value

char* fvBuf = new char[size]; //buffer to hold version info
GetFileVersionI nfo((char*)name .c_str(), 0, size, fvBuf); //get version info

UINT bufLen; //buffer to hold length of version info string
char* tempBuf = new char[size];//buffer to hold version info string
VerQueryValue(f vBuf, TEXT("\\StringF ileInfo\\040904 E4\\FileDescrip tion"),
(LPVOID*)(&temp Buf), &bufLen); //supposedly get version info string and store
in tempBuf

out << tempBuf << "\n"; //output version info string to my output stream.

Thanks in advance for any info/assistance with this little issue, sorry if I
am way off course here.

Cheers.
Aug 7 '08 #1
4 5644

"jpshortstu ff" <jp**********@d iscussions.micr osoft.comescrib ió en el mensaje
news:5D******** *************** ***********@mic rosoft.com...
Hi, not sure if this is the right place for this but it was definitely the
closest I could find.
Well, maybe microsoft.publi c.vc.language is a better place.
>
I am having trouble with the GetFileVersionI nformation/VerQueryValue
functions and was wondering if anyone could help.

All I am trying to do is obtain a string representation of a Version Info
value for a given file. Currently, I am only getting strange unicode
characters, so not sure if my problem is in the understanding of the
functions or of the syntax surrounding char sequences/pointers. I am not
totally at ease with the information in the Win32 API about VerQueryValue to
be honest with you.

Here is the code I am currently using:

LPDWORD temp; //dummy value for GetFileVersionI nfoSize function
DWORD size = GetFileVersionI nfoSize((char*) name.c_str(), temp); //Store size
of version info
delete temp; //delete dummy value
"temp" mustn't be a pointer. Change the above code to:

DWORD temp;
DWORD size = GetFileVersionI nfoSize((char*) name.c_str(), &temp);
>
char* fvBuf = new char[size]; //buffer to hold version info
GetFileVersionI nfo((char*)name .c_str(), 0, size, fvBuf); //get version info

UINT bufLen; //buffer to hold length of version info string
char* tempBuf = new char[size];//buffer to hold version info string
VerQueryValue(f vBuf, TEXT("\\StringF ileInfo\\040904 E4\\FileDescrip tion"),
(LPVOID*)(&temp Buf), &bufLen); //supposedly get version info string and store
in tempBuf
Suggestion: Don't hardcode the code page, 040904E4 is not the same for all
programs. Use VerQueryValue with "\\VarFileInfo\ \Translation" to get the code
page needed to build the others strings.
out << tempBuf << "\n"; //output version info string to my output stream.

Thanks in advance for any info/assistance with this little issue, sorry if I
am way off course here.

Cheers.
Regards

--
Cholo Lennon
Bs.As.
ARG

Aug 8 '08 #2
Hi,

Thanks, that really helped, I have got it working now.

I do have a question though, if you have time.

When using the translation table, you get a pointer to an array of
Language/Codepage values. I am currently solely using the first, but is there
a difference? If so, is there a way of telling which one to use?

My new code is this:

DWORD temp;
DWORD size = GetFileVersionI nfoSize((char*) name.c_str(), &temp);

char* fvBuf = new char[size];
GetFileVersionI nfo((char*)name .c_str(), 0, size, fvBuf);

DWORD* langCodeArray;
UINT aLen;
VerQueryValue(f vBuf, TEXT("\\VarFile Info\\Translati on"),
(LPVOID*)&langC odeArray, &aLen);

TCHAR subBlock[25];
sprintf(subBloc k, TEXT("\\StringF ileInfo\\%04x%0 4x\\CompanyName "),
LOWORD(langCode Array[0]), HIWORD(langCode Array[0]));

UINT bufLen;
char* tempBuf = new char[size];
VerQueryValue(f vBuf, subBlock, (LPVOID*)(&temp Buf), &bufLen);

out << tempBuf << "\n";

Notice I am using [0].

Thanks a lot for all your help, it's greatly appreciated.
Aug 8 '08 #3
jpshortstuff wrote:
Hi,

Thanks, that really helped, I have got it working now.

I do have a question though, if you have time.

When using the translation table, you get a pointer to an array of
Language/Codepage values. I am currently solely using the first, but
is there a difference? If so, is there a way of telling which one to
use?
The idea is to choose a code page similar to OS code page. AFAIK nobody include
more than one code page per file, so, from my point of view, it's correct to
choose the first array position.

>
My new code is this:

DWORD temp;
DWORD size = GetFileVersionI nfoSize((char*) name.c_str(), &temp);

char* fvBuf = new char[size];
GetFileVersionI nfo((char*)name .c_str(), 0, size, fvBuf);

DWORD* langCodeArray;
UINT aLen;
VerQueryValue(f vBuf, TEXT("\\VarFile Info\\Translati on"),
(LPVOID*)&langC odeArray, &aLen);

TCHAR subBlock[25];
sprintf(subBloc k, TEXT("\\StringF ileInfo\\%04x%0 4x\\CompanyName "),
LOWORD(langCode Array[0]), HIWORD(langCode Array[0]));

UINT bufLen;
char* tempBuf = new char[size];
VerQueryValue(f vBuf, subBlock, (LPVOID*)(&temp Buf), &bufLen);

out << tempBuf << "\n";

Notice I am using [0].

Thanks a lot for all your help, it's greatly appreciated.
Regards

--
Cholo Lennon
Bs.As.
ARG

Aug 11 '08 #4
Thanks for the info.
Aug 12 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
5055
by: Rajesh Garg | last post by:
Do i have any way in which i can check the version number of a particular Dll. Eg. shdocvw.dll gives me version number of IE.How do i get this. I mean right click and version tab shows me this value but in code how to do that. similarly i ned o check version numbers of other dll files. Please Help RVG raj_chins@rediffmail.com
6
4964
by: seansan | last post by:
Hi, Does anyone know how to read the full access version number in visual basic? I need to know if the current program instance is SR-1 or SP-3, etc... I currently use: DB_DAO = DBEngine.Version DB_JET = CurrentDb().Version DB_VERSION = Application.SysCmd(acSysCmdAccessVer)
1
1527
by: Paul | last post by:
Hi, Does anyone know how to check a version of a file in C++? Any WIN32 API that does this? Please advice, thanks! -P
2
5565
by: Naraht | last post by:
I'm looking for information on getting the Version of a Windows Executable (or DLL) *after* the file has been copied to a Linux system. This probably means I will need to recreate GetFileVersionInfoSize, GetFileVersionInfo and VerQueryValue. Does anyone have any ideas on where I can find those either as libraries or the source for them? The languages I have available for this are C, Perl and shell scripts. (This is for a commerical...
2
3488
by: opswat | last post by:
Hello, I am currently working on a C++ project for a PocketPC with Windows Mobile 5.0 in Visual Studio 2005. I am currently looking for a way to get file version information, i.e. file version, product version, file modified date, file creation date, etc. The only way I could find was using the functions GetFileVersionInfoSize, GetFileVersionInfo, and then VerQueryValue, but when I ran it, it gave me an error saying: "The specified...
1
1598
by: dmeiser | last post by:
I need to write a query that returns the names of all queries in a library that start with the letters SC. I have not a clue how to even start something like this. If possible, the boss would like this done is QRY/400. Also, if anyone knows how to build a time machine so that I can have this done by when the boss called 15 minutes ago wanting to have it done by now, that would be great. Thanks for any help,
1
4590
by: O.B. | last post by:
I have the need to read a file (version.txt) that is embedded within an WAR file that is within an EAR file: foo.ear contains bar.war contains resources/version.txt I am able to get the bar.ear file as an inputstream as follows: import java.util.zip.ZipEntry; import java.util.zip.ZipFile; ZipFile zipFile = new ZipFile("foo.ear");
17
2746
by: NeoAlchemy | last post by:
I am starting to find more web pages that are using a query parameters after the JavaScript file. Example can be found at www.opensourcefood.com. Within the source you'll see: <script src="/shared/scripts/common.js?revision=1.6" type="text/javascript">. I am trying to see if there is any big deal to this or a best practice that is starting to creep up in the JavaScript community. If this is used only as a way to distinguish what...
0
9716
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9596
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10609
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10366
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10105
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7646
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5542
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4323
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3845
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.