By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,629 Members | 1,222 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,629 IT Pros & Developers. It's quick & easy.

winapi32.GetFileVersionInfo() - problem

P: n/a
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,

Jul 18 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
> <snip the fourth and hopefully last repost>

Do you actually think anybody will reply to your mail if you keep repostingat
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-----

Jul 18 '05 #2

P: n/a
Dennis Lee Bieber wrote:
<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
Jul 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.