Re: How to get my own version?

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



broznoober@xxxxxxxxx wrote:
I have a DLL, built using VC6, and I want to programatically get its
version number. I have searched the web for how to do this, and have
found a bunch of pages saying to use GetFileVersionInfoSize,
GetFileVersionInfo, and VerQueryValue.

However, all of them seem to be written from the point of view of
getting the version of *another* DLL. I want to get the version of a
DLL from within that DLL itself. Is there an easier way to do this
(e.g. something akin to VB6's App.Major and so forth), or do I have to
go the GetFileVersionInfoSize / GetFileVersionInfo / VerQueryValue
route?

In particular, GetFileVersionInfo and ...Size require the pathname of
the DLL in question. So do I seriously have to determine my own
pathname in order to get my own version information?

Yes.


Assuming that I really do have to use that stuff, is there an easy way
to get the pathname of a DLL from within the DLL itself?

Yes, there is.

Use VirtualQuery, passing the address of something (e.g. a function)
declared in your DLL as the 'lpAddress' parameter. After the call, the
BaseAddress field of the MEMORY_BASIC_INFORMATION structure that you
supplied will be the HMODULE of your DLL.

Use GetModuleFileName, passing the HMODULE obtained above to get the full
path to your DLL.

-cd


.



Relevant Pages

  • Re: How to get my own version?
    ... GetFileVersionInfo, and VerQueryValue. ... DLL from within that DLL itself. ... go the GetFileVersionInfoSize / GetFileVersionInfo / VerQueryValue ... block including the header. ...
    (microsoft.public.vc.language)
  • Re: DLL vs Shared Library
    ... It might help avoid future embarrassment if you learned the technology ... Here's a random URL from Googling "DLL Version": ... GetFileVersionInfo() ...
    (Ubuntu)
  • Re: How to get my own version?
    ... GetFileVersionInfo, and VerQueryValue. ... DLL from within that DLL itself. ... go the GetFileVersionInfoSize / GetFileVersionInfo / VerQueryValue ... pathname in order to get my own version information? ...
    (microsoft.public.vc.language)
  • How to get my own version?
    ... I have a DLL, built using VC6, and I want to programatically get its ... GetFileVersionInfo, and VerQueryValue. ... go the GetFileVersionInfoSize / GetFileVersionInfo / VerQueryValue ... pathname in order to get my own version information? ...
    (microsoft.public.vc.language)
  • GetFileVersionInfoSize()=0, obwohl Versionsressource enthalten zu sein scheint
    ... Sie enthält eine Versionsressource, ... deren Inhalt in den Eigenschaften der Datei auch korrekt angezeigt ... GetFileVersionInfo() auf andere DLLs anwende, ... vermute die Ursache also in der fehlerhaften ersten DLL. ...
    (microsoft.public.de.vc)