> I've looked both at MSDN online and in the help that comes with VC6,
> and they both say the same. The description of it says:
>
> "Creates a one-dimensional array whose lower bound is always zero"
>
> But the second parameter is described as:
>
> "lLbound
> The lower bound for the array. Can be negative."
>
>
>
> Is it me or does that not make sense? How can it be "always zero" and
> then asks you to specify the lower bound and it can be negative?!!
Nope, you're not alone.
Personally, I have always used SafeArrayCreate( ). And I suggest if you're
using VC7 or above, take a look at CComSafeArray. It's extremely handy.
> Now, in the second part of this exciting episode, I'm having trouble
> using it (big surprise!). I've got an ActiveX control that I'm trying
> to get to fire an event back to the container. One of the parameters
> being sent back in this event is a variant - eventually I want the
> variant to contain an array of BYTE (VT_UI1). I have a tiny VB client
> compiled to an EXE to test it - it doesn't try to use the parameter at
> this stage, it simply flags that the event was captured.
>
> Now, if I fill the VARIANT like this:
>
> varBuffer.iVal = 1 ;
> varBuffer.vt = VT_I2 ;
A small suggestion:
V_I2(&varBuffer) = 1;
V_VT(&varBuffer) = VT_I2;
> and fire the event, no problemo - the VB client runs just fine,
> acknowledging that the event was captured successfully.
>
> But if I try like this:
>
> SAFEARRAY *pSA = ::SafeArrayCreateVector(VT_UI1, 0, dwNumBytes);
> varBuffer.parray = pSA ;
> varBuffer.vt = VT_ARRAY|VT_UI1 ;
>
> the client crashes with an access violation {:v(
>
> Any ideas of what I've done wrong?
Erm, have you tried filling the array? Also, have you tried using
SafeArrayCreate( ) instead?
-------------
Ehsan Akhgari
Farda Technology (www.farda-tech.com)
List Owner: [EMAIL PROTECTED]
[ Email: [EMAIL PROTECTED] ]
[ WWW: http://www.beginthread.com/Ehsan ]
Every deep thinker is more afraid of being understood than of being
misunderstood. The latter perhaps wounds his vanity, but the former wounds
his heart, his sympathy, which always says: "Ah, why would you also have as
hard a time of it as I have?"
-Beyond Good And Evil, F. W. Nietzsche