I'm trying to use an in/out SAFEARRAY with COM and VC++ 5, but it doesn't
work very fine :
First, when I add the following definition to my dispatch interface IDL
[id(10), helpstring("method testSafeArrayInt")] HRESULT
testSafeArrayInt([in, out] SAFEARRAY(int) theArray, [in] int increment);
the wizard adds the following to the c++ file :
STDMETHODIMP SimpleTest1::testSafeArrayInt(SAFEARRAY ( int ) theArray,
int increment)
which of course is not understood by the c++ compiler .....
when I correct this to
STDMETHODIMP SimpleTest1::testSafeArrayInt(SAFEARRAY /*( int )*/ theArray,
int increment)
it says following :
C:\Program Files\DevStudio\VC\ATL\include\atlcom.h(162) : error C2259:
'CComObject<class SimpleTest1>' : cannot instantiate abstract class due to
following members:
C:\Program Files\DevStudio\VC\ATL\include\atlcom.h(162) : warning C4259:
'long __stdcall ISimpleTest1::testSafeArrayInt(struct tagSAFEARRAY *,int)' :
pure virtual function was not defined
C:\Program Files\DevStudio\VC\ATL\include\atlcom.h(162) : error C2259:
'CComObject<class SimpleTest1>' : cannot instantiate abstract class due to
following members:
C:\Program Files\DevStudio\VC\ATL\include\atlcom.h(162) : warning C4259:
'long __stdcall ISimpleTest1::testSafeArrayInt(struct tagSAFEARRAY *,int)' :
pure virtual function was not defined
C:\Program Files\DevStudio\VC\ATL\include\atlcom.h(874) : error C2259:
'CComContainedObject<class SimpleTest1>' : cannot instantiate abstract class
due to following members:
C:\Program Files\DevStudio\VC\ATL\include\atlcom.h(874) : warning C4259:
'long __stdcall ISimpleTest1::testSafeArrayInt(struct tagSAFEARRAY *,int)' :
pure virtual function was not defined
and if I make the final correction :
STDMETHODIMP SimpleTest1::testSafeArrayInt(SAFEARRAY* /*( int )*/ theArray,
int increment)
my server compiles, but returns a "type mismatch" error when I call the
function via COM, which is
normal, as this is not what I defined in the IDL !
Does anybody have a solution to this ?
Please help !
Then access the SAFEARRAY in the VARIANT structure in your function.
Scott
Michel Voide wrote in message <36656...@epflnews.epfl.ch>...
Scott Rabon wrote in message <8yf92.671$vR3....@news.ntplx.net>...
: Then access the SAFEARRAY in the VARIANT structure in your function.
<snip>
Don't forget to check that
variant.vt == (VT_ARRAY | VT_I4)
----- (or whatever the array should contain)
before accessing the array, though.
--
Any opinions expressed are my own and not necessarily those of Laser-Scan.
But, just for curiosity ... I've read in some DCOM book that to send
directly a safearray, you
should use the following syntax in the IDL :
[in, out] SAFEARRAY(int) *myVar
Do you know if it is possible this way, or is it mandatory to use a VARIANT
type ? It seems at least that
the VC5 has a problem with this (refer to my previous message for more
infos....)
Thanks again ....
mvo