You can specify local extra fields only when creating a new file in an archive,
because the local header is written at that time. You need to:
const WORD id = 0xABCD;
CZipArchive zip;
zip.Open(_T("C:\\Temp\\test.zip"), CZipArchive::zipCreate);
CZipFileHeader templ;
templ.SetFileName(_T("file.dat"));
CZipExtraData* extra = templ.m_aLocalExtraData.CreateNew(id);
const char* data = "data to save";
size_t dataSize = strlen(data);
extra->m_data.Allocate((DWORD)dataSize);
memcpy(extra->m_data, data, dataSize);
zip.OpenNewFile(templ);
zip.CloseNewFile();
zip.Close();
const WORD id = 0xABCD;
CZipArchive zip;
zip.Open(_T("C:\\Temp\\test.zip"));
CZipExtraData* extra = zip[0]->m_aCentralExtraData.CreateNew(id);
const char* data = "data to save";
size_t dataSize = strlen(data);
extra->m_data.Allocate((DWORD)dataSize);
memcpy(extra->m_data, data, dataSize);
zip.RemoveCentralDirectoryFromArchive();
zip.Close();
const WORD id = 0xABCD;
CZipArchive zip;
zip.Open(_T("C:\\Temp\\test.zip"));
const int index = 0;
zip.OpenFile(index);
zip.CloseFile();
const CZipFileHeader* info = zip[index];
CZipExtraData* extra = info->m_aLocalExtraData.Lookup(id);
if (extra != NULL)
{
}
extra = info->m_aCentralExtraData.Lookup(id);
if (extra != NULL)
{
}
zip.Close();