Here are a couple of routines for finding the Audio and Image type. I don't claim they are exhaustive as they were written for my needs. I hope someone finds them useful.
Code:
Private Function GetAudioType(sFileName As String) As String
Dim FF As Integer, s As String
s = Space$(420)
FF = FreeFile
Open sFileName For Binary As FF
Get #FF, 1, s
Close FF
Select Case True
Case Mid$(s, 413, 4) = "alac": GetAudioType = "Alac" 'This must come before 'aac'
Case Left$(s, 4) = "ÿñP", InStr(17, s, "mp4"): GetAudioType = "aac"
Case Mid$(s, 9, 4) = "AIFF": GetAudioType = "Aiff"
Case Left$(s, 4) = "fLaC": GetAudioType = "Flac"
Case Left$(s, 3) = "MAC": GetAudioType = "Monkey"
Case Left$(s, 2) = "ÿû", Left$(s, 3) = "ID3": GetAudioType = "mp3"
Case Left$(s, 3) = "MPC": GetAudioType = "Musepack"
Case InStr(1, s, "OPUS", 1): GetAudioType = "Opus"
Case InStr(1, s, "VORBIS", 1): GetAudioType = "Vorbis"
Case Left$(s, 4) = "RIFF": GetAudioType = "Wav"
Case Left$(s, 4) = "wvpk": GetAudioType = "Wavpack"
Case Left$(s, 7) = "0&²ufÏ": GetAudioType = "Wma"
Case Else: GetAudioType = "Unknown"
End Select
End Function
Code:
Private Function GetImageType(sFileName As String) As String
Dim FF As Integer, s As String
s = Space$(12)
FF = FreeFile
Open sFileName For Binary As FF
Get #FF, 1, s
Close FF
Select Case True
Case Left$(s, 4) = Chr$(0) & Chr$(0) & Chr$(1) & Chr$(0): GetImageType = "ICO"
Case Left$(s, 4) = "PNG": GetImageType = "PNG"
Case Left$(s, 4) = "ÿØÿà": GetImageType = "JPG"
Case Left$(s, 2) = "BM": GetImageType = "BMP"
Case Left$(s, 3) = "GIF": GetImageType = "GIF"
Case Left$(s, 3) = "II*": GetImageType = "TIFF"
Case Mid$(s, 9, 4) = "WEBP": GetImageType = "WEBP"
Case Mid$(s, 5, 8) = "ftypmif1", Mid$(s, 5, 8) = "ftypheic": GetImageType = "HEIF"
Case Else: GetImageType = "UNKNOWN"
End Select
End Function