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
| Private Sub Form_Load()
CommonDialog1.ShowOpen
If Err.Number <> 0 Then Exit Sub
LabInfosImg.Caption = InformationsFichier(CommonDialog1.FileName, CommonDialog1.FileTitle)
End Sub
Private Function InformationsFichier(CheminFich As String, Fichier As String) As String
'necessite d'activer reference Microsoft Shell Controls and Automation
Dim Chemin As String
Chemin = Left(CheminFich, Len(CheminFich) - Len(Fichier))
Dim objShell As Shell
Dim objFolder As Folder
Dim strFileName As FolderItem
Dim T as Integer
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.NameSpace(Chemin)
Set strFileName = objFolder.Items.IteM(Fichier)
InformationsFichier = Fichier & vbCrLf
If objFolder.GetDetailsOf(strFileName, 1) <> "" Then
InformationsFichier = InformationsFichier & Trim(objFolder.GetDetailsOf(strFileName, 1))
End If
If objFolder.GetDetailsOf(strFileName, 31) <> "" Then
Dim Extrat As String
Extrat = Trim(objFolder.GetDetailsOf(strFileName, 31))
MsgBox Extrat '"?120 x ?90"
'pourquoi sa ne fonctionne pas?, mystère
'Extrat = Replace(Extrat, "?", "")
'Extrat = Replace(Extrat, Chr(63), "")
'Extrat = Replace(CStr(Extrat), Chr(63), "")
'Extrat = Replace(Extrat, Chr(63), "", , , vbTextCompare)
'Extrat = Replace(Extrat, Chr(63), "", , , vbBinaryCompare)
' en désespoir de cause
Dim recompo As String
For T = 1 To Len(Extrat)
If Asc(Mid(Extrat, T, 1)) <> 63 Then recompo = recompo & Mid(Extrat, T, 1)
Next T
InformationsFichier = InformationsFichier & " - " & recompo
End If
Set objShell = Nothing: Set objFolder = Nothing: Set strFileName = Nothing
End Function |
Partager