cast from structure to int in C++ to C#

G

Guest

Hi, I'm new to C#. I have a C++ program and need to develop it in C# now.

In C++ Program:
typedef struct A_T {
char id[17];
DWORD status;
} AStruct

AStruct rcd;
SYSTEMTIME st;
DWORD dwSN;

In which the rcd and st contain data.
Then I use a dll function "Function" in the C++ Program like this:
Function((DWORD) &rcd, (DWORD) &st, (DWORD) &dwSN);
Just cast to DWORD, and then pass this 3 parameters to the function.

In C#, I write like this:
[StructLayout(LayoutKind.Sequential )]
public struct AStruct {
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=17)] public string id;
public int status;
}

[StructLayoutAttribute(LayoutKind.Sequential)]
public struct SYSTEMTIME
{
public short year;
public short month;
public short dayOfWeek;
public short day;
public short hour;
public short minute;
public short second;
public short milliseconds;
}

But I do not have idea how to use the function in C#.
Can you help translate to C#?

Thanks
Grace
 

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

Top