[英]Passing a string from C# to cpp with COM
I have a C# COM server which is consumed by a cpp client. 我有一个C#COM服务器,由cpp客户端使用。
One of the C# methods returns a string. 其中一个C#方法返回一个字符串。
In cpp the returned string is represented in Unicode (UTF-16), at least according to the memory view. 在cpp中,返回的字符串以Unicode(UTF-16)表示,至少根据内存视图。
[return: MarshalAs(UnmanagedType.LPStr)]
before the method definition in C# if you'd like to return the string as an ANSI string instead of Unicode. [return: MarshalAs(UnmanagedType.LPStr)]
放在C#中的方法定义之前。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.