hello,
My code is this:
#include
typedef struct CalTest{
int x;
int y;
}OurType;
extern "C"{
_declspec(dllexport) OurType MyFun(int a,int b){OurType ot;/*Do some processing.*/ot.x=a; // Assumed to be aot.y=b; // Assumed to be breturn ts;}
}
In addition, What types can accept its(OurType)in c#?
Thanks.


VulpesRank #55 · 29.2K reputationPosted Feb 16, 2014, 6:22 AM EST
VulpesRank #55 · 29.2K reputationPosted Feb 15, 2014, 10:51 AM EST
1. You'll need to import it using the DllImport attribute.
2. You'll need to mimic the struct, OurType, from C# code.
Here's some code. I've assumed the dll is called calltest.dll and has been copied to the C# executable's directory:
Ken HRank #2,315 · 610 reputationPosted Feb 15, 2014, 8:37 PM EST
Dll source codes:
C Sharp codes:
[StructLayout(LayoutKind.Sequential,Pack=1)]
Ken HRank #2,315 · 610 reputationPosted Feb 16, 2014, 4:18 PM EST
Thank for you,Vulpes. :)