Re: Help with CreateStreamFromHGlobal in Win 2000
- From: "ss2905" <ss2905@xxxxxxxxx>
- Date: 9 Aug 2006 04:34:29 -0700
Hello Igor,
Thanks for the replies.
I am able to get the contents of the dropped file in Windows 2000.
However, I am still not able to figure out as to why the code worked on
Win XP. Did it do a seek operation on an Istream pointer assigned to
the global memory handle?
It was a silly mistake on my part to assign the IStream pointer to the
HGlobal member of Stgmedium.
Internally, memcpy is used in most places. However, when i tried to
memcpy the contents of a large file to the global buffer, the whole
contents were not getting copied.
I am not sure, but it could have been an oversight on my part. On some
systems, the size of the file is not shown properly immediately after
dropping. Once the entire contents are copied, the size is shown
correctly. I will check whether that was the case with the memcpy
related code.
Any idea about the earlier query regarding CF_HDDOP? Windows Explorer
is calling my IDataObject_GetData code multiple times during drag and
after drop, if I support CF_HDROP.
Regards,
ss2905
Igor Tandetnik wrote:
ss2905 <ss2905@xxxxxxxxx> wrote:
I am using CFSTR_FILEDESCRIPTOR and CFSTR_FILECONTENTS to drag an
email attachment from a web application and drop it to the local PC.
But memcpy for a 5 MB file is time consuming and so I have implemented
the functionality using IStream. The API used is
CreateStreamFromHGlobal.
----------------------------------------------
IStream *l_pStream = NULL;
CreateStreamFromHGlobal(NULL, TRUE, &l_pStream);
// Error checking code
l_pStream->Write(l_pbData, l_nDataSize, &l_dwBytesWritten);
What makes you think writing to an in-memory stream is faster than
memcpy into a memory block? How do you think the stream moves the data
around - magic?
// Error checking code
f_pStgMedium->tymed = TYMED_ISTREAM;
f_pStgMedium->hGlobal = l_pStream;
Why do you assign an IStream pointer to hGlobal and not to pstm?
In Windows XP, with the above code, I am still able to copy the file
data into the stream and drop the virtual file on to the local
machine. However, when the same code is executed on Windows 2000 (
Professional & Advanced ), the file is created but with zero bytes.
After writing, position the stream back to the beginning with
IStream::Seek. The drop target tries to read from the current position,
which after Write is at the end of the stream.
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925
.
- Follow-Ups:
- Re: Help with CreateStreamFromHGlobal in Win 2000
- From: Igor Tandetnik
- Re: Help with CreateStreamFromHGlobal in Win 2000
- References:
- Help with CreateStreamFromHGlobal in Win 2000
- From: ss2905
- Re: Help with CreateStreamFromHGlobal in Win 2000
- From: Igor Tandetnik
- Help with CreateStreamFromHGlobal in Win 2000
- Prev by Date: Re: ATL Performance DLL unregistration
- Next by Date: Re: CComBSTR, std::endl and stack overflow
- Previous by thread: Re: Help with CreateStreamFromHGlobal in Win 2000
- Next by thread: Re: Help with CreateStreamFromHGlobal in Win 2000
- Index(es):
Relevant Pages
|
Loading