Who is an owner of data rendered by IDataObject::GetData?

infinityeternity 21 Reputation points
2021-01-20T09:48:50.053+00:00

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?

Windows development | Windows API - Win32
Developer technologies | C++
{count} votes

1 answer

Sort by: Most helpful
  1. Igor Tandetnik 1,116 Reputation points
    2021-01-20T14:40:20.767+00:00

    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.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.