Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How do I use the GetFileVersionInfo() API?
Message
De
02/10/1997 01:03:56
 
 
À
30/09/1997 16:06:57
John Ward
Golden American Life Ins. Co.
Wilmington, Washington, États-Unis
Information générale
Forum:
Visual C++
Catégorie:
Autre
Divers
Thread ID:
00052530
Message ID:
00052809
Vues:
88
...
>Does anyone know how to call the "VER.DLL" API correctly with VB4 16-bit?

Declare the following functions in you .BAS file...

Declare Function GetFileVersionInfo% Lib "Ver.dll" (ByVal FileName$,_
ByVal dwHandle&, ByVal cbBuff&, ByVal lpvData$)
Declare Function GetFileVersionInfoSize& Lib "Ver.dll" (ByVal_
FileName$, dwHandle&)
Declare Sub hmemcpy Lib "kernel" (hpvDest As Any, hpvSrc As Any,_
ByVal cbBytes&)

Create a UDType...

Type FileInfo
wLength As Integer
wValueLength As Integer
szKey As String * 16
dwSignature As Long
dwStrucVersion As Long
dwFileVersionMS As Long
dwFileVersionLS As Long
End Type

Add the following two functions in the module:

Function LOWORD (x As Long) As Integer
LOWORD = x And &HFFFF&
'Low 16 bits contain Minor revision number.
End Function

Function HIWORD (x As Long) As Integer
HIWORD = x \ &HFFFF&
'High 16 bits contain Major revision number.
End Function

Add to the command button's OnClick:

Private Sub Command1_OnClick()
Dim x As FileInfo
Dim FileVer As String
Dim FileName As String
'*** Get Version Information If Available ****
FileVer = ""
FileName = Me![FName]
BufSize& = GetFileVersionInfoSize(FileName, dwHandle&)
If BufSize& = 0 Then
MsgBox "Invalid File Name or no Version information available"
Exit Sub
End If
lpvData$ = Space$(BufSize&)
r% = GetFileVersionInfo(FileName, dwHandle&, BufSize&, lpvData$)
hmemcpy x, ByVal lpvData$, Len(x)

'**** Parse File Version Number ****
FileVer = Trim$(Str$(HIWORD(x.dwFileVersionMS))) + "."
FileVer = FileVer + Trim$(Str$(LOWORD(x.dwFileVersionMS))) + "."
FileVer = FileVer + Trim$(Str$(HIWORD(x.dwFileVersionLS))) + "."
FileVer = FileVer + Trim$(Str$(LOWORD(x.dwFileVersionLS)))

MsgBox FileVer, 64, "Version of " & FileName
End Sub

...And that's all :)
Some things are better be left unknown...NOT!!!
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform