Menu

#194 Com dll fails to write to field text in a new frame

happens every time
open
nobody
5
2008-12-09
2008-12-09
TomB
No

Even in the included VB6 sample, whenever i try to set the text of a frame, the frame gets written but there is no text in it and numTextItems returns 0. In VB6, the code i use is

oFrame = oTag.FindFrame(ID3_CONTENTTYPE)
oFrame.Field(ID3_FORMAT_TEXT).Text(1) = "Some undefined genre"
oTag.SaveV2Tag

I traced through the id3com code and found that put_Text seems to always call the 'Set' method in field_strings_unicode.cpp which returns without writing the text as GetEncoding shows it as being ID3TE_ISO8859_1 when it expects ID3TE_UNICODE.

The following change fixed the issue for me but this is only the second time i've ever looked at c++ code so there may be a good reason why this wasn't done in the first place!

In id3com's ID3Field.cpp i modified put_Text to be:

STDMETHODIMP CID3Field::put_Text(long ItemNum, BSTR newVal)
{
USES_CONVERSION;
try
{
m_Field->Set(OLE2A(newVal));
return S_OK;
}
catch (...)
{
return Error(IDS_UNEXPECTED_ERROR, IID_IID3ComField, E_UNEXPECTED);
}
}

the changes being:
USES_CONVERSION;
and
OLE2A(newVal)

Now the text gets set absolutely fine.

Discussion


Log in to post a comment.