|
-
Mar 5th, 2004, 12:31 PM
#1
Thread Starter
Hyperactive Member
Passing a structure by reference to C++ DLL
Hi,
Confused where to post this since it has to do with both C++ and VB.
Using C++, I've made a DLL library (ATL Component) which contains a strucutre. I want to expose the structure definition to the VB application as a data type so it can create a variable with this data type, manipulate it, and pass it by reference to functions in the DLL. Question is: How is that possible?
Thanks in advance!
-
Mar 5th, 2004, 12:52 PM
#2
couldn't you just create a UDT in VB that has the same set of variables as your C structure?? like when you are using windows API and pass a rect UDT to an API function because it needs the rect structure for its return values.
So if your structure is made up of 3 longs and a string, making a UDT of the same parameters should work for passing..
this is just a guess.. I am not a C programmer so I am not sure if it will work
-
Mar 6th, 2004, 03:01 PM
#3
Thread Starter
Hyperactive Member
Yeah, it's fine in theory, yet I lack the technique 
Am facing some trouble because whenever I try to make one of the variables passed into the function a UDT, I get some errors with the compile!
Wonder if anyone could help, or post some code?!?!?
-
Mar 6th, 2004, 04:37 PM
#4
Frenzied Member
do you get error in vb or c?
show the struct plz, so we can help you translate it to a udt.
-
Mar 7th, 2004, 08:40 AM
#5
Thread Starter
Hyperactive Member
Am getting the error in C++, anyway: the problem is technical as I said before, and I should face no problem translating the structure, here it is anyway:
Code:
typedef struct
{
int Piece[65];
int AttackPiece[65];
int BlackKingP;
int WhiteKingP;
int MSF1;
int MSF2;
int MyRate;
int ByPassPos;
int Cast1; //Black Long
int Cast2; //Black Short
int Cast3; //White Long
int Cast4; //White Shor
} ChessBoard;
-
Mar 7th, 2004, 01:48 PM
#6
The thing is that I don't know for sure how the C/C++ compiler you have will take the Int ?, as 16 bit or 32 bit, but it is more likely that it is 32 bit...
So, the struct in VB should be like this:
VB Code:
Type ChessBoard
Piece(65 - 1) As Long
AttackPiece(65 - 1) As Long
BlackKingP As Long
WhiteKingP As Long
MSF1 As Long
MSF2 As Long
MyRate As Long
ByPassPos As Long
Cast1 As Long ' Black Long
Cast2 As Long ' Black Short
Cast3 As Long ' White Long
Cast4 As Long ' White Shor
End Type
-
Mar 8th, 2004, 06:08 AM
#7
Thread Starter
Hyperactive Member
Anyway, I've managed to do some roundabout solution. so I'll consider it resolved for me, Thanks All!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|