Home > Net > C # call DLL C, how to transform a complex structure pointer passed as an argument
C # call DLL C, how to transform a complex structure pointer passed as an argument
Time:11-25
In c + + c # call DLL, how to transform a complex structure pointer passed as a parameter: Structure is as follows:
struct TagPoint { int x; Int y; }; Struct TagRect { int x; Int y; Int width; Int Height; }; Struct TagInfos { Char * name; PointList TagPoint *; TagRect the rect. Int pointCount; }; Struct FSize { Int width; Int height; Int the depth; }; Struct TagImageInfos { Char * path; TagInfos * tagList; FSize imageSize; Bool isLable; Int tagCount; };
[System. The Runtime. InteropServices. StructLayoutAttribute (System. The Runtime. InteropServices. LayoutKind. Sequential)] Public struct TagPoint {
///int Public int x;
///int Public int y; }
[System. The Runtime. InteropServices. StructLayoutAttribute (System. The Runtime. InteropServices. LayoutKind. Sequential)] Public struct TagRect {
///int Public int x;
///int Public int y;
///int Public int width;
///int Public int Height; }
[System. The Runtime. InteropServices. StructLayoutAttribute (System. The Runtime. InteropServices. LayoutKind. Sequential)] Public struct TagInfos {
///char * [System. The Runtime. InteropServices. MarshalAsAttribute (System. The Runtime. InteropServices. UnmanagedType. LPStr)] Public string name;
///TagPoint * * The public System. IntPtr pointList;
///TagRect Public TagRect the rect.
///int Public int pointCount; }
[System. The Runtime. InteropServices. StructLayoutAttribute (System. The Runtime. InteropServices. LayoutKind. Sequential)] Public struct FSize {
///int Public int width;
///int Public int height;
///int Public int the depth; }
[System. The Runtime. InteropServices. StructLayoutAttribute (System. The Runtime. InteropServices. LayoutKind. Sequential)] Public struct TagImageInfos {
///char * [System. The Runtime. InteropServices. MarshalAsAttribute (System. The Runtime. InteropServices. UnmanagedType. LPStr)] Public string path;
///TagInfos * * The public System. IntPtr tagList;
///FSize Public FSize imageSize;
///a Boolean Public bool isLable;
///int Public int tagCount; }
From you to send a TagImageInfos structure to c + +, c # problems at present is the inside of the structure pointer the value problems Struggle for several days. Still not fully resolved, the great god please help to provide a train of thought or solution, thank you!
CodePudding user response:
I think you should need a tool to help you to simplify work,
Baidu "interopsignaturetoolkit" this is a tool, although tool translation how much need to change, but at least 80% of the work can simplify your
If there is other h head with "swig" can also, but swig translation thing is too heavy, so I don't recommend commonly, unless there is a super large amount of translation work to do, it is still recommended that use interopsignaturetoolkit a a translation to insurance