winapi32.GetFileVersionInfo() - problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • L. Shestov

    #1

    winapi32.GetFileVersionInfo() - problem

    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.p y" distributed in the win32api download
    that does exactly what I need.

    Unfortunately I get this error when I execute the script:

    C:\work>getfile ver.py
    Traceback (most recent call last):
    File "C:\work\getfil ever.py", line 8, in ?
    d=win32api.GetF ileVersionInfo( fname, '\\')
    pywintypes.erro r: (1812, 'GetFileVersion Info:GetFileVer sionInfoSize',
    '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,

  • Heiko Wundram

    #2
    Re: winapi32.GetFil eVersionInfo() - problem

    > <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.GetFil eVersionInfo(fn ame,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/zvf0bpgh6uVAMRA hDoAJ9q7KMdPZZW jSqE/TalM/rxfcBoggCeMz+q
    k5kvMLFFiDUMYTQ wk9VWDSo=
    =yQI2
    -----END PGP SIGNATURE-----

    Comment

    • Martin v. Löwis

      #3
      Re: winapi32.GetFil eVersionInfo() - problem

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

      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

      Comment

      Working...