Version API 
Author Message
 Version API

Hi all,
Is that any window API that return the version of an EXE file?
Or what are the steps I need to accomplish that?

I am programming using VC5,6 and VB5,6 on NT4/WS/SVR

Thanks,
Bob.



Tue, 22 Jan 2002 03:00:00 GMT  
 Version API
Bob,

Give this a try ....

Put this code in a .BAS file

Public Type VS_FIXEDFILEINFO
    dwSignature             As Long
    dwStrucVersion          As Long     '  e.g. 0x00000042 = "0.42"
    dwFileVersionMS         As Long     '  e.g. 0x00030075 = "3.75"
    dwFileVersionLS         As Long     '  e.g. 0x00000031 = "0.31"
    dwProductVersionMS      As Long     '  e.g. 0x00030010 = "3.10"
    dwProductVersionLS      As Long     '  e.g. 0x00000031 = "0.31"
    dwFileFlagsMask         As Long     '  = 0x3F for version "0.42"
    dwFileFlags             As Long     '  e.g. VFF_DEBUG Or VFF_PRERELEASE
    dwFileOS                As Long     '  e.g. VOS_DOS_WINDOWS16
    dwFileType              As Long     '  e.g. VFT_DRIVER
    dwFileSubtype           As Long     '  e.g. VFT2_DRV_KEYBOARD
    dwFileDateMS            As Long     '  e.g. 0
    dwFileDateLS            As Long     '  e.g. 0
End Type

'
****************************************************************************
*******
' Version...
'
****************************************************************************
*******
Public Declare Function GetFileVersionInfoSize Lib "version.dll" Alias
"GetFileVersionInfoSizeA" (ByVal lptstrFilename As String, lpdwHandle As
Long) As Long
Public Declare Function GetFileVersionInfo Lib "version.dll" Alias
"GetFileVersionInfoA" (ByVal lptstrFilename As String, ByVal dwHandle As
Long, ByVal dwLen As Long, lpData As Byte) As Long
Public Declare Function VerQueryValue Lib "version.dll" Alias
"VerQueryValueA" (pBlock As Byte, ByVal lpSubBlock As String, lplpBuffer As
Long, puLen As Long) As Long

Private Function GetVersionInfo(ByVal sApp As String, sFileVer As String) As
Boolean
Dim udtFileInfo         As VS_FIXEDFILEINFO
Dim lpdwHandle          As Long
Dim lSize               As Long
Dim di                  As Long
Dim lpData()            As Byte
Dim FileAddress         As Long
Dim FileLen             As Long
Dim sNetwork            As String
Dim nMajorMS            As Integer
Dim nMinorMS            As Integer
Dim nMinorLS            As Integer

    On Error GoTo err_Handler

    sFileVer = ""

    GetVersionInfo = False

    ' Determine if version information is present, and
    ' if so how large a buffer is needed to hold it.
    lSize = GetFileVersionInfoSize(sApp, lpdwHandle)

    ' Version info is unlikely to ever be greater than 64k
    ' but check anyway. If it was larger than 64k, we would
    ' need to allocate a huge buffer instead.  Note, we
    ' are only using an approximation to 64k here to take
    ' into account the VB string overhead.
    If lSize > 64000 Then lSize = 64000

    ReDim lpData(lSize + 1)

    ' Load the string with the version information
    di = GetFileVersionInfo(sApp, lpdwHandle, lSize, lpData(0))
    If di = 0 Then
        'MsgBox "Unable to locate file : " & sApp
        GoTo exit_Function
    End If

    di = VerQueryValue(lpData(0), "\", FileAddress, FileLen)
    If di = 0 Then
        'MsgBox "No fixed version information in this file"
        GoTo exit_Function
    End If

    ' Copy the fixed file info into the structure
    Call MoveMemoryStrToUdt(udtFileInfo, FileAddress, FileLen)

    nMajorMS = CInt(udtFileInfo.dwFileVersionMS / &H10000)
    nMinorMS = CInt(udtFileInfo.dwFileVersionMS And &HFFFF&)
    nMinorLS = CInt(udtFileInfo.dwFileVersionLS And &HFFFF&)
    sFileVer = Trim$(Str$(nMajorMS)) + "." + Trim$(Str$(nMinorMS)) + "." +
Trim$(Str$(nMinorLS))

    GetVersionInfo = True

exit_Function:
    Exit Function

err_Handler:
 Err.Clear
End Function

--KK


Quote:
> Hi all,
> Is that any window API that return the version of an EXE file?
> Or what are the steps I need to accomplish that?

> I am programming using VC5,6 and VB5,6 on NT4/WS/SVR

> Thanks,
> Bob.



Tue, 22 Jan 2002 03:00:00 GMT  
 Version API
Thanks for the info.  What I really need is that:
to be able to find out the version of external exe file rather than the
current file.. Can you help?

Thxs.Bob



Tue, 22 Jan 2002 03:00:00 GMT  
 Version API
I have a FREE DLL that gives you most file properties and can open and
read an ascii text file. It is much lighter than the FILE SYTEM OBJECT!
You can buy the source cheap at

http://www.hughes.net/~badcomics

Richard Wittmann



Tue, 22 Jan 2002 03:00:00 GMT  
 Version API
Bob,

All you have to do is this:

Dim sApp As String
Dim sVersion As String
Dim bRC As Boolean

sApp = "ExternalExeName.Exe"
bRC = GetVersionInfo(sApp, sVersion)
If bRC = True Then
    MsgBox sVersion
End If

--KK


Quote:
> Thanks for the info.  What I really need is that:
> to be able to find out the version of external exe file rather than the
> current file.. Can you help?

> Thxs.Bob



Tue, 22 Jan 2002 03:00:00 GMT  
 Version API

were released on Fri, 6 Aug 1999 09:27:49 -0500
bearing the following fruit:

Quote:
>Thanks for the info.  What I really need is that:
>to be able to find out the version of external exe file rather than the
>current file.. Can you help?

Thats exactly what KK has given you.

Drac



Tue, 22 Jan 2002 03:00:00 GMT  
 Version API
Yep!

I have a Free DLL that gives most all the files properties at

http://www.hughes.net/~badcomics

Comes with a sample program

Richard Wittmann

Quote:


> were released on Fri, 6 Aug 1999 09:27:49 -0500
> bearing the following fruit:

> >Thanks for the info.  What I really need is that:
> >to be able to find out the version of external exe file rather than the
> >current file.. Can you help?

> Thats exactly what KK has given you.

> Drac



Tue, 22 Jan 2002 03:00:00 GMT  
 Version API
I have checked you site but
it complained that the link to the DLL file was bad.
Bob.
Quote:

>Yep!

>I have a Free DLL that gives most all the files properties at

>http://www.hughes.net/~badcomics

>Comes with a sample program

>Richard Wittmann





Tue, 22 Jan 2002 03:00:00 GMT  
 Version API
Oopsey! I see it now.
Thanks ya'll.

Great people!



Tue, 22 Jan 2002 03:00:00 GMT  
 Version API
Is MoveMemoryStrToUdt a VB6 function? My VB5 connot recognize it.

Bob.

Quote:
>Bob,

>All you have to do is this:

>Dim sApp As String
>Dim sVersion As String
>Dim bRC As Boolean

>sApp = "ExternalExeName.Exe"
>bRC = GetVersionInfo(sApp, sVersion)
>If bRC = True Then
>    MsgBox sVersion
>End If

>--KK



>> Thanks for the info.  What I really need is that:
>> to be able to find out the version of external exe file rather than the
>> current file.. Can you help?

>> Thxs.Bob



Tue, 22 Jan 2002 03:00:00 GMT  
 Version API
Bob,

Oops. Missed this declaration:

Public Declare Sub MoveMemoryStrToUdt Lib "kernel32" Alias "RtlMoveMemory"
(destBuffer As Any, ByVal srcBuffer As Any, ByVal nSize As Long)

Include this declare as well...

--KK


Quote:
> Is MoveMemoryStrToUdt a VB6 function? My VB5 connot recognize it.

> Bob.

> >Bob,

> >All you have to do is this:

> >Dim sApp As String
> >Dim sVersion As String
> >Dim bRC As Boolean

> >sApp = "ExternalExeName.Exe"
> >bRC = GetVersionInfo(sApp, sVersion)
> >If bRC = True Then
> >    MsgBox sVersion
> >End If

> >--KK



> >> Thanks for the info.  What I really need is that:
> >> to be able to find out the version of external exe file rather than the
> >> current file.. Can you help?

> >> Thxs.Bob



Tue, 22 Jan 2002 03:00:00 GMT  
 
 [ 11 post ] 

 Relevant Pages 

1. Windows 2000 Version Api

2. HELP Windows Version API

3. File Version API...

4. Windows Version API Query

5. New version API for NT accounting. I'am put AccLoc,AccDisabled - NTACC.ZIP

6. Word API fails with Japaneze versions?

7. API to retrieve O/S version

8. DOES ANYONE HAVE THE ODBC32 VERSION 3 API DECLARATIONS FOR VB

9. Problem with VerQueryValue Win32 API function from version.dll

10. Old version Windows API Bible.

11. api not in WORKING MODEL VERSIONS??

12. New API-Guide version now available !

 

 
Powered by phpBB® Forum Software