apz
August 5th, 2005, 05:57 AM
Hello,
I am trying to call a vb dll (vb 6 originally, currently used in vs.net with minimal porting) from a c++(ansi) application (also from vs.net platform).I have built a COM dll and included an interface to access the VB function from C++. But I am having a great problem passing SAFEARRAY from C++ to the VB function, I have included a reduced version of my problem
VB function in the DLL :
Public Function AcceptInput(ByRef intValues() As Integer) As Integer
Dim firValue As Integer
Dim secValue As Integer
firValue = intValues.GetValue(1)
Return firValue
End Function
In the C++ Application:
SAFEARRAYBOUND NuTerms[1];
NuTerms[0].cElements = 100;
NuTerms[0].lLbound = 0;
SAFEARRAY* NuTermsSA;
NuTermsSA = SafeArrayCreate(VT_VARIANT,1,NuTerms);
VARIANT *NuTermsVar;
VariantInit(NuTermsVar);
NuTermsVar->vt = VT_VARIANT | VT_ARRAY | VT_BYREF;
NuTermsVar->parray = SafeArrayCreate(VT_VARIANT,1,NuTerms);
long sDimension[1];
sDimension[0]=1;
VARIANT x1;
x1.iVal=2;
SafeArrayPutElement(NuTermsVar->parray,sDimension,&x1);
int retVal;
retVal = dllCall->AcceptInput(&NuTermsSA);
//dllCall is the ATL::CComPtr which is a pointer to the interface in the vb
//dll
There seems to be something fundamentally wrong with this since i am not getting the return value of '2' in the C++ application.
I will be extremely glad if you could helpme out,
thank you
I am trying to call a vb dll (vb 6 originally, currently used in vs.net with minimal porting) from a c++(ansi) application (also from vs.net platform).I have built a COM dll and included an interface to access the VB function from C++. But I am having a great problem passing SAFEARRAY from C++ to the VB function, I have included a reduced version of my problem
VB function in the DLL :
Public Function AcceptInput(ByRef intValues() As Integer) As Integer
Dim firValue As Integer
Dim secValue As Integer
firValue = intValues.GetValue(1)
Return firValue
End Function
In the C++ Application:
SAFEARRAYBOUND NuTerms[1];
NuTerms[0].cElements = 100;
NuTerms[0].lLbound = 0;
SAFEARRAY* NuTermsSA;
NuTermsSA = SafeArrayCreate(VT_VARIANT,1,NuTerms);
VARIANT *NuTermsVar;
VariantInit(NuTermsVar);
NuTermsVar->vt = VT_VARIANT | VT_ARRAY | VT_BYREF;
NuTermsVar->parray = SafeArrayCreate(VT_VARIANT,1,NuTerms);
long sDimension[1];
sDimension[0]=1;
VARIANT x1;
x1.iVal=2;
SafeArrayPutElement(NuTermsVar->parray,sDimension,&x1);
int retVal;
retVal = dllCall->AcceptInput(&NuTermsSA);
//dllCall is the ATL::CComPtr which is a pointer to the interface in the vb
//dll
There seems to be something fundamentally wrong with this since i am not getting the return value of '2' in the C++ application.
I will be extremely glad if you could helpme out,
thank you