Send C++ string to C# string. Interop

后端 未结 3 868
眼角桃花
眼角桃花 2021-02-06 18:36

I am new to inter process communication and need some help. I want to be able to send a string from a C++ program to a C# program. My problem is that the resultant string is g

3条回答
  •  一个人的身影
    2021-02-06 19:29

    char* in C++ is ANSI character string (usually one byte per character), char* in C# is Unicode character string (like WCHAR* - two bytes per character).

    You in fact reinterpret_cast from char* to WCHAR*. This won't work. Use MultiByteToWideChar() on C++ side to convert.

提交回复
热议问题