1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
Function Read_UUID(sPath As String) As String
Dim HEADER As String: HEADER = ";" & Chr(16) & String(16, 0) & ";" & Chr(16)
Dim sText As String
Dim lStart As Long
Dim sUUID As String
Dim n As Integer
MsgBox (HEADER)
'Initialize
Read_UUID = ""
'sPath = "C:\Documents and Settings\Franck\Mes documents\SmarTeam\Work\NeDrw-002361.CATDrawing"
'Read file (use this way or your preferred procedure to read the file!!!)
Open sPath For Binary Access Read As #1
sText = Space(LOF(1))
Get #1, , sText
Close #1
'Search header
lStart = InStr(sText, HEADER)
'If found, read the 16 following chars
If lStart > 0 Then
'Read characters, storing them by their hex value (00-FF)
For n = 1 To 16
Read_UUID = Read_UUID & Right("0" & Hex(Asc(Mid(sText, lStart + Len(HEADER) - 1 + n, 1))), 2)
Next n
'Insert spacers, so its formatted as "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
'Read_UUID = Left(Read_UUID, 8) & "_" & Mid(Read_UUID, 9, 4) & "_" & Mid(Read_UUID, 13, 4) & "_" & Mid(Read_UUID, 17, 4) & "_" & Right(Read_UUID, 12)
Read_UUID = Left(Read_UUID, 8) & "_" & Mid(Read_UUID, 14, 3) & "_" & Mid(Read_UUID, 17, 8) & "_" & Right(Read_UUID, 4)
Read_UUID = LCase(Read_UUID)
Else
'If not found, just return "NOT FOUND"
Read_UUID = "NOT FOUND"
End If
MsgBox (Read_UUID)
End Function |
Partager