Hi,
I'm using the function "CreateStreamOnHGlobal":
"Invoke CreateStreamOnHGlobal, 0, TRUE, Offset GDIStream"
But not how to call Release to free memory.
Anyone know how to release memory of the "CreateStreamOnHGlobal"?
Thank you very much.
WINOLEAPI CreateStreamOnHGlobal(
_In_ HGLOBAL hGlobal,
_In_ BOOL fDeleteOnRelease,
_Out_ LPSTREAM *ppstm
);
QuoteDo not free the hGlobal memory handle during the lifetime of the stream object. IStream::Release must be called before freeing the memory handle.
QuoteIf the caller sets the fDeleteOnRelease parameter to FALSE, then the caller must also free the hGlobal after the final release. If the caller sets the fDeleteOnRelease parameter to TRUE, the final release will automatically free the hGlobal.
http://msdn.microsoft.com/en-us/library/windows/desktop/aa378980%28v=vs.85%29.aspx
Hi Vortex,
I use to loop for capture images, but "Invoke CreateStreamOnHGlobal, 0, TRUE, Offset GDIStream" not release memory. I know the parameters of the function are to release automatically. But not release memory.
in the CreateStreamOnHGlobal documentation,
QuoteConsider using the SHCreateMemStream function, which produces better performance...
if you still choose to use CreateStreamOnHGlobal, you pass an HGLOBAL
that is a memory handle that has been created using GlobalAlloc
so, to free that memory when done, you would use GlobalFree
to free the memory used by the function, you would use IUnknown::Release
i imagine it would be desirable to Release before GlobalFree
Thank you,
How can I call "IUnknown :: Release". Might you give an example please?
Thank you very much.
try this,
mov ecx,GDIStream
push ecx
mov eax,[ecx]
call DWORD PTR [eax + 8] ; IUnknown::Release
Hi AsmAlmeria12,
Here is an example for you. You can check the attached project.
ReleaseIStream PROC
push eax
mov eax,DWORD PTR [eax]
call IStream.IUnknown.Release[eax] ; release the stream
ret
ReleaseIStream ENDP
Thank you very much