COM objects do not like being moved between threads within the same process. If you access a COM server in one thread, you cannot simply pass the object to another thread since and expect everything to work.
This ComStream class makes it simple to pass a reference to a COM object between threads.
A ComStream acts rather like an wallet. If you want to give someone
some high-value banknotes, you would put them in a wallet and hand the wallet over.
In the same way, a COM object is a valuable thing -- to pass it between threads, first
put it in the ComStream object. The other thread can then get it out
of the ComStream and use it.
A ComStream is created by using the
create function eg.
(create ComStream myDispatch)
where myDispatch is a Dispatch object.
You can also create a ComStream which contains an
Unknown object, but in that case you also need to
supply the GUID of the interface required ie.
(create ComStream myGuid myUnknown)
where myUnknown is a Unknown object and
myGuid is a Guid.
The only property of a ComStream is as follows:
| property name | property type | description |
|---|---|---|
iid |
Guid | the identifier for the interface on the ComStream --
this is a readOnly property |
| method name | description |
|---|---|
set |
set the contents of the stream |
unknown |
get the unknown object from the stream |
dispatch |
get the dispatch object from the stream -- an error is raised if the object on the stream does not support IDispatch |
clear |
clear the object from the stream |
full |
determines if the stream is full ie. if it contains a COM object |
set
Set the contents of the stream. This works in the identical way to
ComStream creation described above ie.
Arguments:
| dispatch | Dispatch |
or
Arguments:
| guid | Guid |
| unknown | Unknown |
Return type: the empty List is returned
unknownGet the Unknown object from the stream.
Arguments: none
Return type: Unknown
dispatchGet the Dispatch object from the stream. An error is raised if the object on the stream does not support IDispatch.
Arguments: none
Return type: Dispatch
clearClear the object from the stream. An empty stream results.
Arguments: none
Return type: the empty List ()
fullDetermines if the stream is full ie. if it contains a COM object.
Arguments: none
Return type: the Symbol true or
the empty List ()
| Contents | Index | Current topic: COM | Related Links: COM helpers, objects, built-in objects |