@@ -109,16 +109,16 @@ Private Const MAX_PATH As Long = 260
109109'the versions here are only words so drop the "d"
110110Private Type VS_FIXEDFILEINFO
111111 dwSignature As Long
112- wStrucVersionl As Integer ' minor
113- wStrucVersionh As Integer 'major
114- wFileVersionMSl As Integer ' minor
115- wFileVersionMSh As Integer 'major
116- wFileVersionLSl As Integer ' private
117- wFileVersionLSh As Integer ' build
118- wProductVersionMSl As Integer ' minor
119- wProductVersionMSh As Integer 'major
120- wProductVersionLSl As Integer ' private
121- wProductVersionLSh As Integer ' build
112+ wStrucVersionl As Integer ' minor 'unsigned!
113+ wStrucVersionh As Integer 'major 'unsigned!
114+ wFileVersionMSl As Integer ' minor 'unsigned!
115+ wFileVersionMSh As Integer 'major 'unsigned!
116+ wFileVersionLSl As Integer ' private 'unsigned!
117+ wFileVersionLSh As Integer ' build 'unsigned!
118+ wProductVersionMSl As Integer ' minor 'unsigned!
119+ wProductVersionMSh As Integer 'major 'unsigned!
120+ wProductVersionLSl As Integer ' private 'unsigned!
121+ wProductVersionLSh As Integer ' build 'unsigned!
122122 dwFileFlagsMask As Long
123123 dwFileFlags As Long
124124 dwFileOS As Long
@@ -144,6 +144,7 @@ Private mProductVersion As String
144144Private mSpecialBuild As String
145145
146146Friend Sub New_ (aPathFileName As String )
147+ Try: On Error GoTo Catch
147148 mFileName = aPathFileName
148149 If (LenB(Dir$(mFileName)) = 0 ) Then
149150 MsgBox "FileNotFoundException: " & mFileName
@@ -153,7 +154,7 @@ Friend Sub New_(aPathFileName As String)
153154 If (siz = 0 ) Then
154155 'Set GetVersionInfo = info1:
155156 End If
156- ReDim Buffer(0 To siz - 1 )
157+ ReDim Buffer(0 To siz - 1 ) As Byte
157158 Dim pBuffer As LongPtr : pBuffer = VarPtr(Buffer(0 ))
158159 If CBool(GetFileVersionInfo(StrPtr(mFileName), 0 , siz, ByVal pBuffer)) Then
159160 'Debug.Print buffer1
@@ -173,6 +174,9 @@ Friend Sub New_(aPathFileName As String)
173174 End If
174175 End If
175176 'Set GetVersionInfo = info1
177+ Exit Sub
178+ Catch:
179+ MsgBox "Error in creating FileVersionInfo"
176180End Sub
177181
178182'in ein Modul MNew kopieren
@@ -301,7 +305,6 @@ Private Sub PtrToStructure(ByVal ptr As LongPtr, ByVal pStruct As LongPtr, ByVal
301305 RtlMoveMemory ByVal pStruct, ByVal ptr, LenBStruct
302306End Sub
303307
304-
305308'##############################' My Properties '##############################'
306309'All properties ReadOnly
307310Public Property Get FileName() As String : FileName = mFileName: End Property
@@ -317,10 +320,10 @@ Public Property Get SpecialBuild() As String: SpecialBuild = mSpecialBui
317320
318321'##############################' Fileversion '##############################'
319322Public Property Get FileVersion() As String : FileVersion = mFileVersion: End Property
320- Public Property Get FileMajorPart() As Long : FileMajorPart = CLng (mVSFileInfo.wFileVersionMSh): End Property
321- Public Property Get FileMinorPart() As Long : FileMinorPart = CLng (mVSFileInfo.wFileVersionMSl): End Property
322- Public Property Get FileBuildPart() As Long : FileBuildPart = CLng (mVSFileInfo.wFileVersionLSh): End Property
323- Public Property Get FilePrivatePart() As Long : FilePrivatePart = CLng (mVSFileInfo.wFileVersionLSl): End Property
323+ Public Property Get FileMajorPart() As Long : FileMajorPart = UInt16_ToInt32 (mVSFileInfo.wFileVersionMSh): End Property
324+ Public Property Get FileMinorPart() As Long : FileMinorPart = UInt16_ToInt32 (mVSFileInfo.wFileVersionMSl): End Property
325+ Public Property Get FileBuildPart() As Long : FileBuildPart = UInt16_ToInt32 (mVSFileInfo.wFileVersionLSh): End Property
326+ Public Property Get FilePrivatePart() As Long : FilePrivatePart = UInt16_ToInt32 (mVSFileInfo.wFileVersionLSl): End Property
324327
325328'------------------------------------------------------------------
326329Public Property Get FileDescription() As String : FileDescription = mFileDescription: End Property
@@ -329,11 +332,14 @@ Public Property Get ProductName() As String: ProductName = mProductName: End Pr
329332
330333'##############################' Productversion '##############################'
331334Public Property Get ProductVersion() As String : ProductVersion = mProductVersion: End Property
332- Public Property Get ProductMajorPart() As Long : ProductMajorPart = CLng (mVSFileInfo.wProductVersionMSh): End Property
333- Public Property Get ProductMinorPart() As Long : ProductMinorPart = CLng (mVSFileInfo.wProductVersionMSl): End Property
334- Public Property Get ProductBuildPart() As Long : ProductBuildPart = CLng (mVSFileInfo.wProductVersionLSh): End Property
335- Public Property Get ProductPrivatePart() As Long : ProductPrivatePart = CLng (mVSFileInfo.wProductVersionLSl): End Property
335+ Public Property Get ProductMajorPart() As Long : ProductMajorPart = UInt16_ToInt32 (mVSFileInfo.wProductVersionMSh): End Property
336+ Public Property Get ProductMinorPart() As Long : ProductMinorPart = UInt16_ToInt32 (mVSFileInfo.wProductVersionMSl): End Property
337+ Public Property Get ProductBuildPart() As Long : ProductBuildPart = UInt16_ToInt32 (mVSFileInfo.wProductVersionLSh): End Property
338+ Public Property Get ProductPrivatePart() As Long : ProductPrivatePart = UInt16_ToInt32 (mVSFileInfo.wProductVersionLSl): End Property
336339
340+ Private Function UInt16_ToInt32 (ByVal uint16 As Integer ) As Long
341+ If uint16 < 0 Then UInt16_ToInt32 = 65536 + uint16 Else UInt16_ToInt32 = uint16
342+ End Function
337343
338344'##############################' Bool Props '##############################'
339345'All properties ReadOnly
0 commit comments