(Creating an ATL EXE server, VC6, SP5.)
I am trying to create an event (usable by VB) in which I pass a safearray of
bytes. Here's the idl definition:
[id(1), helpstring("method TestEvent")] HRESULT TestEvent([in, out]
SAFEARRAY(unsigned char) *TestBuf);
I used ([in, out] SAFEARRAY(unsigned char) *TestBuf) since this is what VB
itself generates in the idl when I create an activeX dll with an event in the
class as follows:
Public Event TestEvent(TestBuf() As Byte)
(This I learned from looking at the IDL of the activeX dll with OLE View.)
When I try to implement the connection point however, I get the following
compile warning:
warning C4800: 'struct tagSAFEARRAY ** ' : forcing value to bool 'true' or
'false' (performance warning)
This is similar to what I get when I try using ([in] VARIANT TestBuf) in the
event. This bug is documented however and all I have to do is remove the & from
the line
pvars[0] = &TestBuf;
from the ATL generated code to fix the problem. But in the SAFEARRAY case, I
can't get rid of the warning, and even though it compiles, VB never sees the
event when I fire it.
Can someone please explain what's going on, or point me to a reference where I
can try to learn it myself? Is there a similar bug for SAFEARRAYs? I know I
can work around it by using a VARIANT, but (1) I'd like to be more specific
about the data types in the IDL than just VARIANT, (2) VARIANT is going away in
VB.NET (I think I read that somewhere), and I don't know what problems that will
cause, and (3) I just want to understand what's happening. I want to be able to
use this interface with some VB clients, but even more so, I'd like to make sure
I'm writing 'proper' interfaces.
Thanks in advance.
--
*************************************************
Patrick Noffke
QTI
Sussex, WI
*************************************************