How would the following c(++)-struct be converted to C# for p/invoke usage -


im trying wrap older dll , running issues representing structure uses in c#. nothing have tried seems working. magicians able help?

typedef struct _param_byname_data  {      n_char *szpntname; /* (in) point name */      n_char *szprmname; /* (in) parameter name */      n_long nprmoffset; /* (in) parameter offset */      parvalue *pupvvalue; /* (in/out) parameter value union */      n_ushort ntype; /* (in/out) value type */      n_long fstatus; /* (out) status of each value access */  } param_byname_data;  

if helps below vb port.

type param_byname_data      point_name string     param_name string     param_offset long     padding1 long 'for byte alignment between vb , c       param_value variant     param_type integer     padding2 integer 'for byte alignment between vb , c      status long status long  end type 

and following delphi well...

param_byname_data=record     pntname:pchar;       // (in) point name     prmname:pchar;       // (in) parameter name     prmoffset:longword;  // (in) parameter offset     pvalue:pointer;      // (out) parameter value union     ntype:word;          // (out) value type     fstatus:longword;    // (out) status of each value access */ end; 

the struct should this...

[structlayout(layoutkind.sequential)] public struct mystruct {     public string point_name;     public string param_name;     public int32 param_offset;     public variantwrapper param_value;     public int32 param_type;     public int32 status; }; 

here good article talks structs , alignment should help. main thing struct layout , bit alignment. has been while since have had marshal values out of c++ hope helps.


Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -