|> Since VBS can't deal with direct
| > byte data like that, it's hard to guess what you might be
| > trying to accomplish.
| A generic data container for use with remote process memory access. An
| uncommon IPC.
:) I meant what the code is trying to accomplish, not
the aim of the software. Since you can only write to the
stream from a byte array, and presumably you have a
byte array coming in, I don't get the problem.
I was all the more curious because, given the limitations,
I've only use Stream a couple of times. I needed it recently
to write a byte array to disk coming from a winhttp image
download. But of course, that's all I could do. VBS can't
handle the winhttp byte array. If I wanted to edit the bytes
I'd have to save to disk and then open as a Textstream.
Microsoft seem to have gone out of their way to prevent
scripters from being able to edit/write binary data. I usually
do it with Textstream. (Which works as long as the local
codepage is not a multibyte language, like Japanese, Chinese,
I tried just setting the stream Position to 2000, which should
be fine, according to the docs. But it tells me that's an invalid
operation. "The parameter is incorrect." Yet the docs for
Position say this:
"The current position can be moved to a point after the end of the stream.
If you specify the current position beyond the end of the stream, the Size
of the Stream object will be increased accordingly. Any new bytes added in
this way will be null."
On the other hand, using your method of writing a string
and then converting to binary, returns 0.0625 seconds when
I time how long that takes to create a 10 MB stream. I'd call
that pretty fast. So then you have your byte array, created
almost instantly, but you can't write bytes to it using VBS.
And if you have a byte array coming in then you don't need
to fill the Stream first.