Advertisement
4_2005-2006 Files/ File Controls/ Input/ Output #150012

CheckFileVersion

Retrieve the version of a file (EXE/DLL etc). This code should be paste into a module and just called via CheckFileVersion('Path to the Exe or DLL').

AI

Yapay Zeka Özeti: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Kaynak Kod
original-source
'Example to use this function
'  MsgBox " Notepad's Version is " & CheckFileVersion("C:\Windows\Notepad.exe")
Public Function CheckFileVersion(FilenameAndPath As Variant) As Variant
On Error GoTo HandelCheckFileVersionError
  Dim lDummy As Long, lsize As Long, rc As Long
  Dim lVerbufferLen As Long, lVerPointer As Long
  Dim sBuffer() As Byte
  Dim udtVerBuffer As VS_FIXEDFILEINFO
  Dim ProdVer As String
  
  lsize = GetFileVersionInfoSize(FilenameAndPath, lDummy)
  If lsize < 1 Then Exit Function
  
  ReDim sBuffer(lsize)
  rc = GetFileVersionInfo(FilenameAndPath, 0&, lsize, sBuffer(0))
  rc = VerQueryValue(sBuffer(0), "\", lVerPointer, lVerbufferLen)
  MoveMemory udtVerBuffer, lVerPointer, Len(udtVerBuffer)
  
  '**** Determine Product Version number ****
  ProdVer = Format$(udtVerBuffer.dwProductVersionMSh) & "." & Format$(udtVerBuffer.dwProductVersionMSl)
  CheckFileVersion = ProdVer
  
  Exit Function
HandelCheckFileVersionError:
  CheckFileVersion = "N/A"
  Exit Function
End Function
Orijinal Yorumlar (3)
Wayback Machine'den kurtarıldı