From 25d7ecde4751fa65e872c828e4eaf1e74bdf332c Mon Sep 17 00:00:00 2001 From: Huw Davies Date: Thu, 16 Apr 2009 12:34:07 +0100 Subject: [PATCH] ole32: Add support for getting stream based objects from a flushed clipboard. --- dlls/ole32/clipboard.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/dlls/ole32/clipboard.c b/dlls/ole32/clipboard.c index 57a48fbc04d..9f2f9e72fee 100644 --- a/dlls/ole32/clipboard.c +++ b/dlls/ole32/clipboard.c @@ -958,6 +958,33 @@ static HRESULT get_stgmed_for_global(HGLOBAL h, STGMEDIUM *med) return hr; } +/************************************************************************ + * get_stgmed_for_stream + * + * Returns a stg medium with a stream based on the handle + */ +static HRESULT get_stgmed_for_stream(HGLOBAL h, STGMEDIUM *med) +{ + HRESULT hr; + HGLOBAL dst; + + med->pUnkForRelease = NULL; + med->tymed = TYMED_NULL; + + hr = dup_global_mem(h, GMEM_MOVEABLE, &dst); + if(FAILED(hr)) return hr; + + hr = CreateStreamOnHGlobal(dst, TRUE, &med->u.pstm); + if(FAILED(hr)) + { + GlobalFree(dst); + return hr; + } + + med->tymed = TYMED_ISTREAM; + return hr; +} + /************************************************************************ * snapshot_GetData */ @@ -1005,6 +1032,8 @@ static HRESULT WINAPI snapshot_GetData(IDataObject *iface, FORMATETC *fmt, if(mask & TYMED_HGLOBAL) hr = get_stgmed_for_global(h, med); + else if(mask & TYMED_ISTREAM) + hr = get_stgmed_for_stream(h, med); else { FIXME("Unhandled tymed - emum tymed %x req tymed %x\n", entry->fmtetc.tymed, fmt->tymed);