###User Defined Function###
_WinAPI_CreateStreamOnHGlobal

###Description###
Creates a stream object that uses a memory handle to store the stream contents.

###Syntax###
#include <WinAPICom.au3>
_WinAPI_CreateStreamOnHGlobal ( [$hGlobal = 0 [, $fDeleteOnRelease = 1]] )


###Parameters###
@@ParamTable@@
$hGlobal
	[optional] The memory handle, or if 0 (Default) a new handle is to be allocated instead. The handle must be allocated as moveable and nondiscardable.
$fDeleteOnRelease
	[optional] Specifies whether the underlying handle for this stream object should be automatically freed when the stream object is released, valid values:
		True             - The final release will automatically free the $hGlobal parameter (Default).
		False            - The user must free the $hGlobal after the final release.
@@End@@

###ReturnValue###
@@ReturnTable@@
Success 	The pointer to the new stream object.
Failure 	0 and sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.
@@End@@


###Remarks###
If $hGlobal is 0, the function allocates a new memory handle and the stream is initially empty, otherwise, the initial contents of the stream are the current contents of the memory block.
Thus, <a href="_WinAPI_CreateStreamOnHGlobal.htm">_WinAPI_CreateStreamOnHGlobal()</a> can be used to open an existing stream in memory. The memory handle and its contents are undisturbed by the creation of the new stream object.

After creating the stream object with <a href="_WinAPI_CreateStreamOnHGlobal.htm">_WinAPI_CreateStreamOnHGlobal()</a>, call <a href="_WinAPI_GetHGlobalFromStream.htm">_WinAPI_GetHGlobalFromStream()</a> to retrieve the memory handle associated with the stream object.

To release the stream object, use the <a href="_WinAPI_ReleaseStream.htm">_WinAPI_ReleaseStream()</a> function.


###Related###
_WinAPI_ReleaseStream, _WinAPI_GetHGlobalFromStream


###See Also###
@@MsdnLink@@ CreateStreamOnHGlobal


###Example###
@@IncludeExample@@
