TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Martin
NA
2
0
Marshal.Copy Struct -> ushort[]
Feb 23 2006 5:59 PM
Hi,
Here is a stuct that I have to fill using a
dll
function :
CODE
struct InfoRegister
{
public uint TargetIdBitField;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 9) ]
public char[] Label;
public byte Mode;
public byte Index;
public byte CS;
}
The function signature : (Standart for ModBus communication protocol)
CODE
public MODBUS_ERROR ReadRegisters( ..., ushort[] pun16RegArray );
I would like to use it like :
CODE
InfoRegister ir = new InfoRegister();
ReadRegisters( ir );
But how can I convert my struct to a ushort[] reference ? And after that, how can I convert my ushort[] to a InfoRegister struct ?
I can't use the UNSAFE mode for technical reasons. So I hope Marshal can do the trick ?
Thanks for you help.
Reply
Answers (
0
)
Process Class problem using within a Windows Service ..Help Please
Asp.net: How to retrive the DataGrid checkbox value