Difference between revisions of "BinaryStream.Constructor(Handle as Integer, Type as Integer)"
From Xojo Documentation
(Note about ownership of resource.)
|Line 45:||Line 45:|
b BinaryStream(i, .HandleTypeWin32Handle)
Revision as of 21:11, 23 August 2017
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.
|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.