Re: How to cast a buffer pointer into a byte array
- From: "Jim Mack" <jmack@xxxxxxxxxxxxxxx>
- Date: Thu, 17 May 2007 08:31:54 -0400
Cmtk Software wrote:
Hi all,
I'm developing a VC++.NET ATL in-process COM which dynamically
allocates a buffer in memory. After filling this buffer (with bitmap
image data) it is needed in the VB6 application which will reference
this COM I'm writing. The VB application needs this data as a byte
array ( Byte() ) because this is the type the OCX display control it
uses requires. Due to the frequent updates that will take place, I
cannot copy the data anywhere along the way.
I know that a possible solution is that the VB will define the byte
array and send it's VarPtr(byteArray(1)) to the C++ COM but that
doesn't sit right with the design of this COM because it might need
to serve several GUIs simultaneously.
So, the question is: Is there a way to send a pointer to the buffer
from the C++ COM to the VB (Possible ways: long value of the memory
address, VARIANT*, SAFEARRAY, etc.) and "wrap" this pointer with a VB
byte array type (cast this pointer to a byte() in VB)?
Any other creative solution will be most welcomed...
Thanks in advance!
Will the COMponent be serving other languages besides VB6?
If not, then the solution is to create and return an OLE SafeArray. VB can manage this (including disposing of it) as a normal Byte() array.
It's dead easy and quite fast using SafeArrayCreate (with VT_UI1). You just return the pointer to the descriptor as the result.
Ask if you need more info.
--
Jim Mack
MicroDexterity Inc
www.microdexterity.com
.
- Prev by Date: Re: Date difference and date compare
- Next by Date: Re: How to cast a buffer pointer into a byte array
- Previous by thread: Date difference and date compare
- Next by thread: Re: How to cast a buffer pointer into a byte array
- Index(es):
Relevant Pages
|