Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

BYREF in API Problem from VB to VC!

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
So.. i need to send from VB6 a STRUCTURED ARRAY into a VC++ DLL!!

i just prepared this 2 file:

VB6 EXE FILE
------------
public type secondarr
value1 as long
value2 as long
end type

publit type strarr
superarr() as secondarr
value3 as long
end type

Private Declare Function tryout Lib &quot;<myc++lib>&quot; (Byref PArr as strarr) as long

public sub PassArray()
dim myarr(0) as starr
redim myarr(0).superarr(0)
myarr(0).value3=3
myarr(0).superarr(0).value1=1
myarr(0).superarr(0).value2=2
msgbox tryout(myarr(0))
end sub

VC
----
[this is a Dynamic-DLL]
[....]
//only function and struct here

[in h]
struct secondarr
{
int value1;
int value2;
};

struct strarr
{
secondarr* superarr;
int value3;
};

[in cpp]
int tryout(strarr * myarr)
{
return strarr[0].superarr[0].value1; // <-- don't work
return stratt[0].value3; // <-- work correctly...
};


...................

so where is the problem????

i need to read a substructired array but... in this case i only operate on first level of array....

any one has other solution???????

thx....
 
Try changing &quot;int&quot; to &quot;long&quot;. I tried to avoid passing pointers from VB to a C++ dll. I always ran into problems. I have to remember how i did it. If i think of it I will post again.

Matt
 
if you change in VC all types from INT to LONG ....
the reselts it's the same :-((((

i suppose that the problem occur while attempting to recreate SUB-Structure DATA.......

thx anyway :-(
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top