Problem in Passing 1d array from VC++ to VB

G

George

Hi all,

I have VB applicatoin , which calls a function in VC++ DLL

Arguement of function is a one dimensional string array.

Array will get filled in VC++ dll function.

I have written the programme given below.

But I am unable to get the array elements from VC++.

Programme is given below.

VC++ COM
/*****************************************/
STDMETHODIMP CTest111CL::myFun(SAFEARRAY **ppOutputArray)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())

HRESULT hresult;

SAFEARRAYBOUND aDim[1] ;

aDim[0].lLbound = 0;
aDim[0].cElements = 3;

BSTR HUGEP *pbstr;

*ppOutputArray = SafeArrayCreate(VT_BSTR , 1, aDim);

hresult=SafeArrayAccessData(*ppOutputArray,(void HUGEP**)&pbstr);

pbstr[0] = SysAllocString(OLESTR("SOURCE_VA"));
pbstr[1] = SysAllocString(OLESTR("ACV"));
pbstr[2] = SysAllocString(OLESTR("10"));

SafeArrayUnaccessData(*ppOutputArray);

return S_OK;
}
/**********************************************/

VB Application
---------------
''''''''''''''''''''''''''''
Dim i As Test111CL

Private Sub Command1_Click()

Dim arr_str(3) As String
Set i = New Test111CL
i.myFun arr_str()
MsgBox arr_str(1)
End Sub

''''''''''''''''''''''''''

MsgBox arr_str(1) , The message Box shows and empty string.

How can I rectify it. Please help me.

Thanks
George
 
I

Ian Collins

George said:
Hi all,

I have VB applicatoin , which calls a function in VC++ DLL
You'd be better off asking on a VC or general windows programming group.
 
A

Alf P. Steinbach

* George:
I have VB applicatoin , which calls a function in VC++ DLL

That's off-topic in clc++m (see the FAQ). Try posting in e.g.
[comp.os.ms-windows.programmer.win32]. Or see the FAQ for other
suggestions.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,983
Messages
2,570,187
Members
46,747
Latest member
jojoBizaroo

Latest Threads

Top