How do Imaging API's work?

Hi,
We are developing wrappers for custom Image Encoders/Decoders for Windows Mobile 5.0 using the Imaging Interfaces given in Windows Mobile 5.0.
But we are having problems identifying the Flow as some of the functions do not seem to be giving the expected result.
For instance, calls to IImagingFactory->InstallImageCodec() fail even though we pass the settings specified by default in the
.
.
.
ImageCodecInfo ImgDcoder , *pinmageinfo = NULL;
//Gets info of of Default Decoders installed in System
pImagingFactory->GetInstalledDecoders(&icount,&pinmageinfo);
HRESULT hr;
//this is the information about thedefault JPEG Codec
memcpy(&ImgDcoder , &pinmageinfo[2], sizeof(ImgDcoder));
//keep the Jpeg format info same as default
//Now just change related information
ImgDcoder.Clsid = CLSID_CMyJpedDecoder ;
.
.
wcscpy( (wchar_t *) ImgDcoder.CodecName , L"My Jpeg Decoder" ) ;
.
.
.
.
hr = pImagingFactory->InstallImageCodec( &ImgDcoder );

And the call returns E_INVALIDARGUMENT though the arguments are just same as the default.
Are there any relevant samples(the one given merely calls the API)
Any help would be deeply appreciated.
Regards,
Jimble

[1342 byte] By [jimble] at [2008-3-6]
# 1
The ImageCodecInfo struct contains pointers which point pass the end of the struct. In this way, GetInstalledCodecs can return to you one big block of memory containing both the ImageCodecInfo struct and strings.

So you can't just do:
memcpy(&ImgDcoder , &pinmageinfo[2], sizeof(ImgDcoder));

because that copies just the struct and not the strings. Although, it will still work as along as the original block of memory is still around.

But you certainly can't do:
wcscpy( (wchar_t *) ImgDcoder.CodecName , L"My Jpeg Decoder" ) ;
because you don't know how big is the buffer pointed to by ImgDcoder.CodecName. You are probably trashing the next string in memory.

JasonFuller at 2007-9-9 > top of Msdn Tech,Smart Device Development,Smart Devices Native C++ Development...