Thank you for your continued help. Because of the code you wrote above it made me go and look at TagsLibrary Defs.Pas. I found that the VB6 function definition is not correct for AddCoverArt. Here is a before and after:
Before:
Public Declare Function TagsLibrary_SetCoverArtFromFile Lib "TagsLib.dll" _
(ByVal Tags As Long, ByVal TagType As TTagType, ByVal index As Long, ByVal _
FileName As Long, ByRef CoverArt As TCoverArtData) As Long
Public Declare Function TagsLibrary_AddCoverArt Lib "TagsLib.dll" (ByVal _
Tags As Long, ByVal TagType As TTagType, ByVal CoverArt_Name As Long, ByVal _
CoverArt_Data As Long, ByVal CoverArt_DataSize As Int64, ByVal _
CoverArt_Description As Long, ByVal CoverArt_CoverType As Long, ByVal _
CoverArt_MIMEType As Long, ByVal CoverArt_PictureFormat As _
TTagPictureFormat, ByVal CoverArt_Width As Long, ByVal CoverArt_Height As _
Long, ByVal CoverArt_ColorDepth As Long, ByVal CoverArt_NoOfColors As Long, _
ByVal CoverArt_ID3v2TextEncoding As Long, ByVal CoverArt_Index As Long) As _
Long
After:
Public Declare Function TagsLibrary_SetCoverArtFromFile Lib "TagsLib.dll" _
(ByVal Tags As Long, ByVal TagType As TTagType, ByVal Index As Long, ByVal _
FileName As Long, ByVal CoverArt As Any) As Long
Public Declare Function TagsLibrary_AddCoverArt Lib "TagsLib.dll" (ByVal _
Tags As Long, ByVal TagType As TTagType, ByVal CoverArt As Any) As Long
What happens now is I get a 'Bad DLL call convention' error on the AddCoverArt line, then the IDE crashes.
I think I have tried every permutation of CoverArt:
ByVal CoverArt as Long: Called with varptr(Coverart)
ByRef CoverArt as Long: Called with varptr(Coverart)
ByVal CoverArt as Any: Called with varptr(Coverart)
ByRef CoverArt as Any: Called with Coverart
My current code:
GetTags Trk.FullPath '//Gives lTags a value
CoverArt.Name = StrPtr("Album Art")
CoverArt.CoverType = 3 '//* ID3v2 cover type (3: front cover)
CoverArt.MIMEType = StrPtr("image/jpeg")
CoverArt.Description = StrPtr("")
CoverArt.Width = ScaleX(ImageStart.Picture.Width, vbTwips, vbPixels)
CoverArt.Height = ScaleY(ImageStart.Picture.Height, vbTwips, vbPixels)
CoverArt.ColorDepth = 24
CoverArt.NoOfColors = 0
CoverArt.PictureFormat = tpfJPEG
CoverArt.Data = 0 '; //PictureStream.Memory;
CoverArt.DataSize.LowPart = 0 '//PictureStream.Size;
CoverArt.DataSize.HighPart = 0 '//PictureStream.Size;
Index = TagsLibrary_AddCoverArt(lTags, ttAutomatic, CoverArt)
If Not TagsLibrary_SetCoverArtFromFile(lTags, ttAutomatic, Index, StrPtr(PicFileName), CoverArt) Then
MsgBox "Error while adding cover art: " & PicFileName, vbExclamation
End If