Re: How to get my own version?
- From: "Carl Daniel [VC++ MVP]" <cpdaniel_remove_this_and_nospam@xxxxxxxxxxxxxxx>
- Date: Wed, 7 May 2008 09:18:41 -0700
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
.
- References:
- How to get my own version?
- From: broznoober
- How to get my own version?
- Prev by Date: Re: Visual Studio's 2005 help?
- Next by Date: Re: Visual Studio 2005 x64 mode.
- Previous by thread: How to get my own version?
- Next by thread: Re: How to get my own version?
- Index(es):
Relevant Pages
|