Hello everyone,
Now I want to read and write picture stream from contact items ,but I failed
with the following code,can you give me some advance please.
// IPOutlookApp2 * polApp = NULL;
// IContact * pContact = NULL;
IStream * istream = NULL;
BYTE* buf = NULL ;
STATSTG stg;
IItem * iitem = NULL;
CEPROPID propid = PIMPR_PICTURE;
CEOID oid;
//hr = pItems->Item(i,(IDispatch**)&pContact);//there is no problem to
get pContact
hr = pContact->get_Oid((long*)&oid);
hr = polApp->GetItemFromOidEx(oid, 0, &iitem);
if (iitem != NULL)
{
hr = iitem->OpenProperty(propid, GENERIC_READ | GENERIC_WRITE,
&istream);
}
readSize = 0;
if ( hr != 0 )
{
return GetLastError();
}
hr = istream->Stat(&stg, STATFLAG_NONAME ); //I want to get the real
size of istream
if (hr !=0)
{
return GetLastError();
}
hr = istream->Read(buf, stg.cbSize.LowPart, (ULONG*)&readSize );//I dont
know wether this works or not
Executing it for the first time ,istream is not NULL,but
hr=istream->Stat(...) is 0x80004001 and GetLastError is 0x00000000;Then the
second time,hr returned by iitem->OpenProperty(propid, GENERIC_READ |
GENERIC_WRITE, &istream) is 0x80070020 and GetLastError is 0x00000020.
I have no idea what the problem is ,give me some tips please.
Thank you in advance.