PDA

View Full Version : How to find DLL version from VB6?


NiTroGen
4th March 2003, 17:59
I want to find the version of a DLL using Visual Basic 6. I've fount the following API calls:

Public Declare Function GetFileVersionInfo Lib "version.dll" Alias "GetFileVersionInfoA" (ByVal lptstrFilename As String, ByVal dwHandle As Long, ByVal dwLen As Long, lpData As Any) As Long

Public Declare Function GetFileVersionInfoSize Lib "version.dll" Alias "GetFileVersionInfoSizeA" (ByVal lptstrFilename As String, lpdwHandle As Long) As Long

Public Declare Function GetVersion Lib "kernel32" Alias "GetVersion" () As Long

Public Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" (lpVersionInformation As OSVERSIONINFO) As Long

Is any of these API calls the one I need? How can I use it? If not, which is the right procedure?

DaveEL
4th March 2003, 18:25
i think its the first 2 (the others are for windows version info)

call GetFileVersionInfoSize first param is a file name second is an int that will always be set to 0 (dont ask me why)

this returns the size of version info for that dll.

now for the hard bit you need to allocate the amount of memeory returned by the last function (i have no idea how to do this in vb (btw i HATE vb :) ))

now call GetFileVersionInfo with
1) the file name
2) an int which is ignored (once again dont ask me why)
3) the length returned above
4) the buffer to to the version info in
the decode the strange information put in that buffer

take a look at this page here http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wcesdk40/htm/cerefGetFileVersionInfo.asp
and this one here for the structure of the information returned
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wcesdk40/htm/cerefvs_versioninfo.asp

DaveEL
(Sorry i can't be of more help but i really hate vb and so have no idea how to do things like this in it, my advice if you know how is to do a small bit of c to call these functions and extract just the version info you want a (couple of version numbers) and call that from vb)

NiTroGen
4th March 2003, 20:23
Thanks for your help.:)