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!

Unmanaged data to managed CLI code

Status
Not open for further replies.

iipee

Programmer
Mar 23, 2006
6
0
0
FI
Hi!

I am trying to update an old data base application created earlier with VB3 and RDM45.dll. There is a data base definition routine which creates a C language header file which include the following definition
struct vets_r {
short vetno;
char vetnimi[30];
char prof[30];
char erik[30];
} VETS;

Today there is an updated RDM7.dll which has been created with unmanaged C++.

The database accessing functions can be transferred to managed CLI C++ code with
[DllImport("rdm7.dll", EntryPoint = "d_recread", CharSet = CharSet::Ansi, CallingConvention=CallingConvention::StdCall)]
extern "C" int d_recread(void*, void *, int);

For the data I have tried to use
[StructLayout( LayoutKind::Sequential )]
ref class mVETS
{
public:
static int mvetno;
static String^ mvetnimi;
static String^ mprof;
static String^ merik;
};

All called database functions perform correctly and return correct status messages, but when I try to read the old data base with definitions
mVETS^ pvet = gcnew mVETS();
d_recread(&pvet, Currtask, CURR_DB)

the routine performs without difficulties as many times as there are items in the old data base but - for instance with
pvet->mvetnimi
I receive no data. Can anyone tell me what is wrong.

Also, for the item vetno which is originally a 2-byte signed integer I have tried to use the conversion
[MarshalAs(UnmanagedType::I2)]
but no matter where in the code I try to implement it, errors are created.

Can anyone help me how to do it correctly.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top