Click here to Skip to main content
15,903,632 members
Home / Discussions / C#
   

C#

 
GeneralRe: Sockets/Objects/Serializable Pin
James T. Johnson25-May-02 4:17
James T. Johnson25-May-02 4:17 
GeneralRe: Sockets/Objects/Serializable Pin
Paddy25-May-02 4:39
Paddy25-May-02 4:39 
GeneralRe: Sockets/Objects/Serializable Pin
tmagoo26-May-02 3:35
tmagoo26-May-02 3:35 
GeneralRe: Sockets/Objects/Serializable Pin
Paddy27-May-02 2:37
Paddy27-May-02 2:37 
GeneralRe: Sockets/Objects/Serializable Pin
tmagoo29-May-02 10:59
tmagoo29-May-02 10:59 
GeneralRe: Sockets/Objects/Serializable Pin
James T. Johnson29-May-02 18:02
James T. Johnson29-May-02 18:02 
GeneralRe: Sockets/Objects/Serializable Pin
tmagoo30-May-02 3:14
tmagoo30-May-02 3:14 
GeneralPlatform Interop - Structures and Arrays Pin
Mikko Puonti24-May-02 0:09
Mikko Puonti24-May-02 0:09 
Hi!

I have following structures:

[ StructLayout( LayoutKind.Sequential, CharSet=CharSet.Ansi )]
struct ISEG
{
public short soffset; // segment position (offset)
public short slength; // segment length
public short segmode; // segment mode
}

[ StructLayout( LayoutKind.Sequential, CharSet=CharSet.Ansi )]
struct IIDX
{
public short inumseg; // number of segments
public IntPtr seg; // (ISEG*) segment information
// + some other data
}

So IIDX structure contains pointer to array of ISEG structures, inumseg defines how many structures there is in array.

And I have following DLL function that uses IIDX structure:

// short (__cdecl * Open)( pIIDX indexPtr );
[DllImport( "mydll.dll")]
private static extern short Open( ref IIDX indexPtr );

In unmanaged C/C++ you would use structure following way:

IIDX udtIndex;
ISEG udtBseg[2];

udtIndex.inumseg = 2;
udtIndex.seg = udtBseg;
udtBseg[0].soffset = 1;
udtBseg[0].slength = 2;
udtBseg[0].segmode = 1;
udtBseg[1].soffset = 3;
udtBseg[1].slength = 2;
udtBseg[1].segmode = 1;

Open( &udtIndex );

So, my problem is how I marshal ISEG array pointer to IIDX structure in C#? Should I first allocate memory for two ISEG structures, and then marshal each ISEG structures to right positions in the allocated memory? Or is there easier way to do marshaling (like function or attribute)? Could I use unsafe blocks to get pointer to the array? Any samples?

Thank you!
GeneralXmlDocument with DTD driving me insane! Pin
Daniel Turini23-May-02 10:21
Daniel Turini23-May-02 10:21 
QuestionWindows services???? Pin
Rickard Andersson2023-May-02 4:37
Rickard Andersson2023-May-02 4:37 
AnswerRe: Windows services???? Pin
Nish Nishant23-May-02 17:06
sitebuilderNish Nishant23-May-02 17:06 
GeneralRe: Windows services???? Pin
Rickard Andersson2023-May-02 20:48
Rickard Andersson2023-May-02 20:48 
GeneralRe: Windows services???? Pin
Nish Nishant23-May-02 20:52
sitebuilderNish Nishant23-May-02 20:52 
GeneralRe: Windows services???? Pin
Rickard Andersson2023-May-02 21:20
Rickard Andersson2023-May-02 21:20 
GeneralRe: Windows services???? Pin
Nish Nishant23-May-02 21:20
sitebuilderNish Nishant23-May-02 21:20 
GeneralRe: Windows services???? Pin
Rickard Andersson2023-May-02 22:17
Rickard Andersson2023-May-02 22:17 
GeneralRe: Windows services???? Pin
Nish Nishant23-May-02 22:17
sitebuilderNish Nishant23-May-02 22:17 
GeneralRe: Windows services???? Pin
A.A.29-May-02 17:20
A.A.29-May-02 17:20 
QuestionNotifyIcon and ContextMenu Bug ?? Pin
2sky23-May-02 1:28
2sky23-May-02 1:28 
AnswerRe: NotifyIcon and ContextMenu Bug ?? Pin
Nish Nishant23-May-02 1:34
sitebuilderNish Nishant23-May-02 1:34 
GeneralRe: NotifyIcon and ContextMenu Bug ?? Pin
23-May-02 1:57
suss23-May-02 1:57 
GeneralRe: NotifyIcon and ContextMenu Bug ?? Pin
2sky23-May-02 2:05
2sky23-May-02 2:05 
GeneralComponent staying alive Pin
Oyvind Bratland22-May-02 20:32
Oyvind Bratland22-May-02 20:32 
GeneralAny sources of C# Pin
dlhson22-May-02 16:47
dlhson22-May-02 16:47 
GeneralRe: Any sources of C# Pin
Nick Parker22-May-02 17:25
protectorNick Parker22-May-02 17:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.