Re: Help with CreateStreamFromHGlobal in Win 2000



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

.



Relevant Pages

  • Re: Help with CreateStreamFromHGlobal in Win 2000
    ... But memcpy for a 5 MB file is time consuming and so I have implemented ... What makes you think writing to an in-memory stream is faster than ... Why do you assign an IStream pointer to hGlobal and not to pstm? ...
    (microsoft.public.vc.atl)
  • Re: misc question #2:: howto stream .RAM/realplay via "kmplayer"??
    ... got kmplayer working with Konqueror. ... streams windows audio (using the Mplayer ... you need to confirm that you can play Real in kmplayer. ... Fast forward and such in a Real stream will be a bitch. ...
    (freebsd-questions)
  • Re: RTSP Problems
    ... Unless they're windows PCs, I'm not sure WPF ... Our original idea was to stream video with MPG-4 H.264 with RTSP protocol ... WMP is extensible using DirectShow plugins. ... Currently Windows Media Player follows all the MS-RTSP negotiation, ...
    (microsoft.public.windowsmedia.player)
  • Re: C00D11C0
    ... If I reverse the stream then I don't get an error. ... Tried streaming with Windows Firewall off. ... is "An existing connection was forcibly closed by the remote host" ... a differnet remote computer but not for the one that has the error. ...
    (microsoft.public.windowsmedia.player)
  • Re: using a PC as an extender
    ... audio source, go to the following website and download the Windows Media ... Once you have downloaded and installed the encoder application, ... if you wish to have a copy of the stream ...
    (microsoft.public.windows.mediacenter)

Loading