winapi32.GetFileVersionInfo() - problem

L

L. Shestov

I need to be able to programatically get the version info from a windows
DLL preferably in the same format as what is displayed in the properties
tab.

I was overjoyed to find Mark Hammond's Python Extensions
(http://starship.python.net/crew/mhammond/) The package includes a
little demo program "filevers.py" distributed in the win32api download
that does exactly what I need.

Unfortunately I get this error when I execute the script:

C:\work>getfilever.py
Traceback (most recent call last):
File "C:\work\getfilever.py", line 8, in ?
d=win32api.GetFileVersionInfo(fname, '\\')
pywintypes.error: (1812, 'GetFileVersionInfo:GetFileVersionInfoSize',
'The specified image file did not contain a resource section.')

Anybody know what this means, or more importantly, if there is a
work-around? "fname", in the code snippit above, contains the name of a
DLL compiled with MS Visual Studio .NET 2003.

Thanks,
 
H

Heiko Wundram

<snip the fourth and hopefully last repost>

Do you actually think anybody will reply to your mail if you keep reposting at
this frequency? It'll rather make most people here kill-file you.

One post is enough; we've seen your problem, and it seems as though nobody
here has a better solution than what Dennis Lee Bieber has already offered.

Just to make sure you understand what he said, I'll repeat it here: Your DLL
doesn't contain a resources section, which in turn contains the version
information you're asking for. So, please start reading MSDN and the VC++
documentation on how to add this information to your DLL.

If you wish to catch the exception that's raised (because the resource block
isn't present), use something like the following:

try:
d = win32api.GetFileVersionInfo(fname,r"\")
except:
d = None

if d is None:
print "No version info in file!"
else:
<do something with the version info>

--
--- Heiko.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQBCQ/zvf0bpgh6uVAMRAhDoAJ9q7KMdPZZWjSqE/TalM/rxfcBoggCeMz+q
k5kvMLFFiDUMYTQwk9VWDSo=
=yQI2
-----END PGP SIGNATURE-----
 
D

Dennis Lee Bieber

One post is enough; we've seen your problem, and it seems as though nobody
here has a better solution than what Dennis Lee Bieber has already offered.
<heh> And the only reason I could state that so quickly was that
I've been tasked, at work, with creating a "configuration" report
reporting the version(s) [file/product] of a whole slew of DLLs (I'm
running a multi-level directory walk from subsystem roots).

The first thing that the report revealed was that many of the
programmers on the system haven't maintained, or even created, the
resource data.

--
 
?

=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=

Dennis said:
<heh> And the only reason I could state that so quickly was that
I've been tasked, at work, with creating a "configuration" report
reporting the version(s) [file/product] of a whole slew of DLLs (I'm
running a multi-level directory walk from subsystem roots).

Yes, answering this question certainly requires detailed knowledge of
Win32. Unfortunately/However/Factually this is really what the OP needs
to do now: go and understand Win32. Apparently, doesn't/didn't know
how Windows stores the version information. What is worse is that it
did not occur to him that his code (and the Python implementation behind
it, and the Microsoft API behind that) are all correct, and that the
problem really is in the file.

Regards,
Martin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top