0

My C code for dll creation is

  typedef struct st_struct{
     unsigned char a;
     unsigned char b;
   } st_struct;

  __declspec(dllexport) void  __stdcall ftn(st_struct *s )
{
     s->a =10;
     s->b =20;

}

My C # code code is as follows

namespace check_ex
{
    [Serializable]
    [StructLayout(LayoutKind.Sequential)]
    public class st_struct
    {
        public byte a;
        public byte b;
    };

[DllImport("exMydll.dll")]
public static extern void ftn(st_struct inputs); 

    public Form1()
    {
        InitializeComponent();
        st_struct x = new st_struct();
        ftn(x);
        Console.Write(x.a, x.b);
    }
}
sujith karivelil
  • 28,671
  • 6
  • 55
  • 88
Lakshmi
  • 1
  • 3

0 Answers0