Marshaling c structures in c#

前端 未结 2 1952
暖寄归人
暖寄归人 2020-12-11 12:13

i have one \'C\' \'DLL\' which can take structures as input, i have to call that dll from my c# program

fallowing are the sample structures i have in c, i have to m

2条回答
  •  时光取名叫无心
    2020-12-11 12:52

    (Scratch my original answer)

    You need to have this at the top of each struct:

    [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
    

    Note the CharSet named parameter. That's important, or you'll end up with wchar_t arrays instead of char arrays.

提交回复
热议问题