BinaryStream.Constructor(Handle as Integer, Type as Integer)

From Xojo Documentation

Revision as of 21:11, 23 August 2017 by PLefebvre (talk | contribs)
You are currently browsing the old Xojo documentation site. Please visit the new Xojo documentation site!


BinaryStream.Constructor(Handle as Integer, Type as Integer)

Creates a BinaryStream from an OS handle.


Type is one of the HandleType class constants and Handle is the appropriate handle type specified by the Type parameter.

The BinaryStream class constants given below can be passed as the parameter.

Constant Description
HandleTypeWin32Handle A Windows32 OS handle.
HandleTypeFilePointer A file pointer.
HandleTypeFileNumber A file descriptor.
HandleTypeMacFileRefNum A file reference number. (FSRef type)
HandleTypeMacFileSpecPointer An FSSpec (obsolete on Mac OS X. Use HandleTypeMacFileRefNum instead.)

For instance, you can use a Declare to open a file with whatever permissions that you wish, and then pass the Handle to a stream object's constructor. When you do this, the BinaryStream now retains the ownership rights to the file handle, so you should not close the file handle (via a declare for example), since it will close when the BinaryStream is destructed.


Dim b As New BinaryStream(i, binaryStream.HandleTypeWin32Handle)