How do I share a constant between C# and C++ code?

后端 未结 5 2181
鱼传尺愫
鱼传尺愫 2020-12-16 21:18

I\'m writing two processes using C# and WCF for one and C++ and WWSAPI for the second. I want to be able to define the address being used for communication between the two

5条回答
  •  旧时难觅i
    2020-12-16 21:49

    An easier alternative to a method for each constant may be a class containing the constants as instance properties. You could create it in C# and expose it via COM interfaces to C++. That's easier and less error-prone than P/Invoke, since you don't have to worry about getting all the types and names right - it's all done for you by the compiler.

    Note: I have not tried this, I'm only speculating that it should work.

提交回复
热议问题