Question

I have an old application that is built using MFC, and makes use of WinAPI function calls for Ethernet communication. It uses API calls for multithreading, synchronization (mutexes, etc), ReadFile to read overlapped IO, etc.

Is it possible to create a new WPF .Net application and import the existing Ethernet communication source code wirtten using WinAPI, without having to rewrite the code using .Net?

Was it helpful?

Solution

You have a variety of options:

  1. Expose the native code using COM.
  2. Compile the native code into a C++/CLI mixed mode assembly. Wrap the native code in a managed ref class which can be consumed by the C# code as any other managed assembly would be.
  3. Compile the native code into a native DLL. Expose the functionality through exported functions. Use p/invoke to call the native functions.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top