|
试试如下代码:
Private Function FindPicDate(PicFile As String) As String
Dim bytes() As Byte
Dim sLine() As String
Dim fSize As Long, ExifDate As Long
Dim i As Long, d As Long
Dim ff As Integer
Dim Found As Boolean
ff = FreeFile
fSize = FileLen(PicFile)
If fSize > 1024 Then fSize = 1024 ' get 1st 1K of file.
ReDim bytes(1 To fSize)
Open PicFile For Binary As #ff
Get #ff, 1, bytes
Close ff
sLine = Split(StrConv(bytes(), vbUnicode), Chr$(0))
For i = 0 To UBound(sLine) ' does "Exif" exsist?
ExifDate = InStr(1, sLine(i), "xif") '这是本来应该是Exif
If ExifDate > 0 Then
Found = True
Exit For
End If
Next i
If Found = False Then Exit Function ' return nothing, "Exif" not found!
For d = i + 1 To UBound(sLine) ' find first ":" in file
ExifDate = InStr(1, sLine(d), ":")
If ExifDate > 0 Then
FindPicDate = sLine(d) ' return date string
Exit For
End If
Next d
End Function
原文请参考这里:
http://www.vbforums.com/showthread.php?t=515109 |
|