The documentation for ReleaseStgMedium
provides the details. In short, if punkForRelease
is not null, then the data provider still owns the data; if punkForRelease
is null, then the caller owns the data. The documentation spells out the correct steps to dispose of the data in either case.
Who is an owner of data rendered by IDataObject::GetData?
Documentation wording on that matter is somewhat confusing. First it states:
The caller then assumes responsibility for releasing the STGMEDIUM structure
then in parameters description:
A pointer to the STGMEDIUM structure that indicates the storage medium containing the returned data through its tymed member, and the responsibility for releasing the medium through the value of its pUnkForRelease member.
I can't draw a reliable conclusion that I'm an owner from that and can modify the data without copying it. Obligation to release through pUnkForRelease makes returning the medium handle (e.g. HBITMAP or whatever) from a function impossible. Thus my ownership of the data is restricted, if it exists at all.
I don't want to make a needless copy. I think an implementer of IDataObject have to make a copy of data even if it will be identical to the source data, because nothing says that a user isn't allowed to modify it. Then why should I copy it again? Am I an owner of it?
1 answer
Sort by: Most helpful
-
Igor Tandetnik 1,106 Reputation points
2021-01-20T14:40:20.767+00:00