@@ -20,32 +20,32 @@ Option Explicit
2020' Datei auf einem Datenträger bereit.
2121#If VBA7 Then
2222 'we assume in VBA7 ansi is obsolete
23- Private Declare PtrSafe Function pGetFileVersionInfoSize Lib "version " Alias "GetFileVersionInfoSizeW " (ByVal lptstrFilename As LongPtr , ByRef lpdwHandle As LongPtr ) As Long
24- Private Declare PtrSafe Function pGetFileVersionInfo Lib "version " Alias "GetFileVersionInfoW " (ByVal lptstrFilename As LongPtr , ByVal dwHandle As LongPtr , ByVal dwLen As Long , lpData As Any ) As Long
25- Private Declare PtrSafe Function pVerQueryValue Lib "version " Alias "VerQueryValueW " (pBlock As Any , ByVal lpSubBlock As LongPtr , lplpBuffer As Any , puLen As Long ) As Long
26- Private Declare PtrSafe Function pVerLanguageName Lib "kernel32 " Alias "VerLanguageNameW " (ByVal wLang As Long , ByVal szLang As LongPtr , ByVal nSize As Long ) As Long
27- Private Declare PtrSafe Function plstrlen Lib "kernel32 " Alias "lstrlenW " (ByVal lpString As LongPtr ) As Long
28- Private Declare PtrSafe Function plstrcpy Lib "kernel32 " Alias "lstrcpyW " (ByVal dst As LongPtr , ByVal src As LongPtr ) As Long
23+ Private Declare PtrSafe Function GetFileVersionInfoSize Lib "version " Alias "GetFileVersionInfoSizeW " (ByVal lptstrFilename As LongPtr , ByRef lpdwHandle As LongPtr ) As Long
24+ Private Declare PtrSafe Function GetFileVersionInfo Lib "version " Alias "GetFileVersionInfoW " (ByVal lptstrFilename As LongPtr , ByVal dwHandle As LongPtr , ByVal dwLen As Long , lpData As Any ) As Long
25+ Private Declare PtrSafe Function VerQueryValue Lib "version " Alias "VerQueryValueW " (pBlock As Any , ByVal lpSubBlock As LongPtr , lplpBuffer As Any , puLen As Long ) As Long
26+ Private Declare PtrSafe Function VerLanguageName Lib "kernel32 " Alias "VerLanguageNameW " (ByVal wLang As Long , ByVal szLang As LongPtr , ByVal nSize As Long ) As Long
27+ Private Declare PtrSafe Function lstrlen Lib "kernel32 " Alias "lstrlenW " (ByVal lpString As LongPtr ) As Long
28+ Private Declare PtrSafe Function lstrcpy Lib "kernel32 " Alias "lstrcpyW " (ByVal dst As LongPtr , ByVal src As LongPtr ) As Long
2929 Private Declare PtrSafe Sub RtlMoveMemory Lib "kernel32 " (ByRef pDst As Any , ByRef pSrc As Any , ByVal bytLen As Long )
3030#Else
3131Private Enum LongPtr
3232 [_]
3333End Enum
3434#Const defUnicode = 1
3535#If defUnicode Then
36- Private Declare Function pGetFileVersionInfoSize Lib "version " Alias "GetFileVersionInfoSizeW " (ByVal lptstrFilename As LongPtr , ByRef lpdwHandle As LongPtr ) As Long
37- Private Declare Function pGetFileVersionInfo Lib "version " Alias "GetFileVersionInfoW " (ByVal lptstrFilename As LongPtr , ByVal dwHandle As LongPtr , ByVal dwLen As Long , lpData As Any ) As Long
38- Private Declare Function pVerQueryValue Lib "version " Alias "VerQueryValueW " (pBlock As Any , ByVal lpSubBlock As LongPtr , lplpBuffer As Any , puLen As Long ) As Long
39- Private Declare Function pVerLanguageName Lib "kernel32 " Alias "VerLanguageNameW " (ByVal wLang As Long , ByVal szLang As LongPtr , ByVal nSize As Long ) As Long
40- Private Declare Function plstrlen Lib "kernel32 " Alias "lstrlenW " (ByVal lpString As LongPtr ) As Long
41- Private Declare Function plstrcpy Lib "kernel32 " Alias "lstrcpyW " (ByVal dst As LongPtr , ByVal src As LongPtr ) As Long
36+ Private Declare Function GetFileVersionInfoSize Lib "version " Alias "GetFileVersionInfoSizeW " (ByVal lptstrFilename As LongPtr , ByRef lpdwHandle As LongPtr ) As Long
37+ Private Declare Function GetFileVersionInfo Lib "version " Alias "GetFileVersionInfoW " (ByVal lptstrFilename As LongPtr , ByVal dwHandle As LongPtr , ByVal dwLen As Long , lpData As Any ) As Long
38+ Private Declare Function VerQueryValue Lib "version " Alias "VerQueryValueW " (pBlock As Any , ByVal lpSubBlock As LongPtr , lplpBuffer As Any , puLen As Long ) As Long
39+ Private Declare Function VerLanguageName Lib "kernel32 " Alias "VerLanguageNameW " (ByVal wLang As Long , ByVal szLang As LongPtr , ByVal nSize As Long ) As Long
40+ Private Declare Function lstrlen Lib "kernel32 " Alias "lstrlenW " (ByVal lpString As LongPtr ) As Long
41+ Private Declare Function lstrcpy Lib "kernel32 " Alias "lstrcpyW " (ByVal dst As LongPtr , ByVal src As LongPtr ) As Long
4242#Else
43- Private Declare Function pGetFileVersionInfoSize Lib "version " Alias "GetFileVersionInfoSizeA " (ByVal lptstrFilename As LongPtr , ByRef lpdwHandle As LongPtr ) As Long
44- Private Declare Function pGetFileVersionInfo Lib "version " Alias "GetFileVersionInfoA " (ByVal lptstrFilename As LongPtr , ByVal dwHandle As Long , ByVal dwLen As Long , lpData As Any ) As Long
45- Private Declare Function pVerQueryValue Lib "version " Alias "VerQueryValueA " (pBlock As Any , ByVal lpSubBlock As LongPtr , lplpBuffer As Any , puLen As Long ) As Long
46- Private Declare Function pVerLanguageName Lib "kernel32 " Alias "VerLanguageNameA " (ByVal wLang As Long , ByVal szLang As LongPtr , ByVal nSize As Long ) As Long
47- Private Declare Function plstrlen Lib "kernel32 " Alias "lstrlenA " (ByVal lpString As LongPtr ) As Long
48- Private Declare Function plstrcpy Lib "kernel32 " Alias "lstrcpyA " (ByVal dst As LongPtr , ByVal src As LongPtr ) As Long
43+ Private Declare Function GetFileVersionInfoSize Lib "version " Alias "GetFileVersionInfoSizeA " (ByVal lptstrFilename As LongPtr , ByRef lpdwHandle As LongPtr ) As Long
44+ Private Declare Function GetFileVersionInfo Lib "version " Alias "GetFileVersionInfoA " (ByVal lptstrFilename As LongPtr , ByVal dwHandle As Long , ByVal dwLen As Long , lpData As Any ) As Long
45+ Private Declare Function VerQueryValue Lib "version " Alias "VerQueryValueA " (pBlock As Any , ByVal lpSubBlock As LongPtr , lplpBuffer As Any , puLen As Long ) As Long
46+ Private Declare Function VerLanguageName Lib "kernel32 " Alias "VerLanguageNameA " (ByVal wLang As Long , ByVal szLang As LongPtr , ByVal nSize As Long ) As Long
47+ Private Declare Function lstrlen Lib "kernel32 " Alias "lstrlenA " (ByVal lpString As LongPtr ) As Long
48+ Private Declare Function lstrcpy Lib "kernel32 " Alias "lstrcpyA " (ByVal dst As LongPtr , ByVal src As LongPtr ) As Long
4949#End If
5050Private Declare Sub RtlMoveMemory Lib "kernel32 " (ByRef pDst As Any , ByRef pSrc As Any , ByVal bytLen As Long )
5151
@@ -145,34 +145,27 @@ Private mSpecialBuild As String
145145
146146Friend Sub New_ (aPathFileName As String )
147147 mFileName = aPathFileName
148- 'End Sub
149-
150- 'Public Shared Function GetVersionInfo(ByVal fileName As String) As System.Diagnostics.FileVersionInfo
151- 'Public Function GetVersionInfo(ByVal FileName As String) As FileVersionInfo
152148 If (LenB(Dir$(mFileName)) = 0 ) Then
153149 MsgBox "FileNotFoundException: " & mFileName
154150 Exit Sub
155151 End If
156- Dim num2 As Long : num2 = pGetFileVersionInfoSize(StrPtr(mFileName), 0 )
157- 'Dim info1 As FileVersionInfo: Set info1 = New_FileVersionInfo(FileName)
158- If (num2 = 0 ) Then
152+ Dim siz As Long : siz = GetFileVersionInfoSize(StrPtr(mFileName), 0 )
153+ If (siz = 0 ) Then
159154 'Set GetVersionInfo = info1:
160- Exit Sub
161155 End If
162- Dim buffer1() As Byte : ReDim buffer1(0 To num2 - 1 )
163- Dim numRef1 As LongPtr : numRef1 = VarPtr(buffer1(0 ))
164- Dim ptr1 As LongPtr : ptr1 = numRef1 ': Set ptr1 = New_IntPtr(numRef1)
165- If CBool(pGetFileVersionInfo(StrPtr(mFileName), 0 , num2, ByVal ptr1)) Then
156+ ReDim Buffer(0 To siz - 1 )
157+ Dim pBuffer As LongPtr : pBuffer = VarPtr(Buffer(0 ))
158+ If CBool(GetFileVersionInfo(StrPtr(mFileName), 0 , siz, ByVal pBuffer)) Then
166159 'Debug.Print buffer1
167- Dim num3 As Long : num3 = GetVarEntry(ptr1)
160+ Dim ve As Long : ve = GetVarEntry(pBuffer) 'num3
168161 'If Not info1.GetVersionInfoForCodePage(ptr1, ConvertTo8DigitHex(num3)) Then
169- If Not GetVersionInfoForCodePage(ptr1 , ConvertTo8DigitHex(num3 )) Then
162+ If Not GetVersionInfoForCodePage(pBuffer , ConvertTo8DigitHex(ve )) Then
170163 'Wenn die Sprache nicht geklappt hat, dann noch mit den drei anderen probieren
171- Dim num4, numArray1: numArray1 = Array(&H40904B0 , &H40904E4 , &H4090000 )
172- For Each num4 In numArray1
173- If (num4 <> num3 ) Then
164+ Dim v, vArr: vArr = Array(&H40904B0 , &H40904E4 , &H4090000 ) 'num4
165+ For Each v In vArr
166+ If (v <> ve ) Then
174167 'If info1.GetVersionInfoForCodePage(ptr1, ConvertTo8DigitHex(num4)) Then
175- If GetVersionInfoForCodePage(ptr1 , ConvertTo8DigitHex(num4 )) Then
168+ If GetVersionInfoForCodePage(pBuffer , ConvertTo8DigitHex(v )) Then
176169 Exit For
177170 End If
178171 End If
@@ -189,14 +182,14 @@ End Function
189182
190183'Private Shared Function ConvertTo8DigitHex(ByVal value As Integer) As String
191184Friend Function ConvertTo8DigitHex (ByVal value As Long ) As String
192- Dim StrVal As String : StrVal = Hex$(value)
193- ConvertTo8DigitHex = String $(8 - Len(StrVal ), "0" ) & StrVal
185+ Dim s As String : s = Hex$(value)
186+ ConvertTo8DigitHex = String $(8 - Len(s ), "0" ) & s
194187End Function
195188
196189'Private Shared Function GetVarEntry(ByVal memPtr As IntPtr) As Integer
197190Friend Function GetVarEntry (ByVal memPtr As LongPtr ) As Long
198191 Dim num1 As Long , ptr1 As LongPtr
199- If pVerQueryValue (ByVal memPtr, StrPtr("\VarFileInfo\Translation" ), ByVal VarPtr(ptr1), num1) Then
192+ If VerQueryValue (ByVal memPtr, StrPtr("\VarFileInfo\Translation" ), ByVal VarPtr(ptr1), num1) Then
200193 GetVarEntry = ShL(ReadInt16(ptr1), 16 ) + CLng(ReadInt16(ptr1, 2 ))
201194 Exit Function
202195 End If
@@ -207,15 +200,15 @@ End Function
207200Friend Function GetFileVersionLanguage (ByVal memPtr As LongPtr ) As String
208201 Dim num1 As Long : num1 = ShR(GetVarEntry(memPtr), 16 )
209202 'Dim buffer As String * 256
210- ReDim buffer (0 To 511 ) As Byte
211- Dim L As Long : L = pVerLanguageName (num1, VarPtr(buffer (0 )), 256 ) 'hmm hier * 2???????????????????????
212- GetFileVersionLanguage = Left$(buffer, L )
203+ ReDim Buffer (0 To 511 ) As Byte
204+ Dim l As Long : l = VerLanguageName (num1, VarPtr(Buffer (0 )), 256 ) 'hmm hier * 2???????????????????????
205+ GetFileVersionLanguage = Left$(Buffer, l )
213206End Function
214207
215208'Private Shared Function GetFileVersionString(ByVal memPtr As IntPtr, ByVal name As String) As String
216209Friend Function GetFileVersionString (ByVal memPtr As LongPtr , ByVal name As String ) As String
217210 Dim num1 As Long , ptr1 As LongPtr
218- If pVerQueryValue (ByVal memPtr, StrPtr(name), ptr1, num1) Then
211+ If VerQueryValue (ByVal memPtr, StrPtr(name), ptr1, num1) Then
219212 If (ptr1 <> 0 ) Then
220213 GetFileVersionString = PtrToString(ptr1)
221214 End If
@@ -254,7 +247,7 @@ End Function
254247'Private Shared Function GetFixedFileInfo(ByVal memPtr As IntPtr) As VS_FIXEDFILEINFO
255248Friend Function GetFixedFileInfo (ByVal memPtr As LongPtr ) As VS_FIXEDFILEINFO
256249 Dim num1 As Long , ptr As LongPtr
257- pVerQueryValue ByVal memPtr, StrPtr("\" ), ptr, num1
250+ VerQueryValue ByVal memPtr, StrPtr("\" ), ptr, num1
258251 PtrToStructure ptr, VarPtr(GetFixedFileInfo), LenB(GetFixedFileInfo)
259252End Function
260253
@@ -282,17 +275,17 @@ End Function
282275
283276'##############################' Marshal '##############################'
284277Private Function ReadInt16 (ByVal ptr As LongPtr , Optional ByVal ofs As Long ) As Integer
285- ' pDst , pSrc
286- Call RtlMoveMemory ( ByVal VarPtr(ReadInt16), ByVal (ptr + ofs), 2 )
278+ ' pDst , pSrc
279+ RtlMoveMemory ByVal VarPtr(ReadInt16), ByVal (ptr + ofs), 2
287280End Function
288- Private Function PtrToString (ByVal ptr As LongPtr , Optional ByVal sLen As Long ) As String
289- If (ptr = 0 ) Then
290- MsgBox "Marshal.PtrToString: Ptr =Nullpointer"
291- Exit Function
281+ Private Function PtrToString (ByVal pStr As LongPtr , Optional ByVal sLen As Long ) As String
282+ If (pStr = 0 ) Then
283+ MsgBox "Marshal.PtrToString: pStr =Nullpointer"
284+ Exit Function
292285 End If
293- Dim num1 As Long : num1 = plstrlen(ptr )
294- PtrToString = Space$(num1 )
295- Call plstrcpy ( StrPtr(PtrToString), ptr)
286+ Dim l As Long : l = lstrlen(pStr )
287+ PtrToString = Space$(l )
288+ lstrcpy StrPtr(PtrToString), pStr
296289#If defUnicode Then
297290 'ist es dann schon der richtige String?
298291 'MsgBox PtrToString
@@ -305,7 +298,7 @@ End Function
305298Private Sub PtrToStructure (ByVal ptr As LongPtr , ByVal pStruct As LongPtr , ByVal LenBStruct As Long )
306299 'hier wird nicht der Pointer übertragen, sondern vielmehr der gesamte Speicherbereich
307300 'in das Objekt structure hineinkopiert
308- Call RtlMoveMemory ( ByVal pStruct, ByVal ptr, LenBStruct)
301+ RtlMoveMemory ByVal pStruct, ByVal ptr, LenBStruct
309302End Sub
310303
311304
0 commit comments