existing code from c++
-
Hi There, I hope somebody can give me some good advices: I need to use an existing Programming Interface which is available whether as a 'COM object dll' or' 2 C++ header files' under .NET. I used the COM object, this works quite nice in VB.NET and as well in C#, using the System.Runtime.InteropServices.TypeLibConverter class. In fact everything will be done automatically and i can use my Interface like in the unmanaged world, great! The main problem is, I develop an application on a PocketPC, under the .NET Compact Framwork. Since this System.Runtime.InteropServices.TypeLibConverter class does not exist under the .NET CF, i need to use the C++ interface, but this gives me headache. So far I found out the following: 1)use (unmanaged) C++ Code in the managed world of .NET 2)use the built-in .NET runtime interop facilities to talk directly to the existing code. 3)wrap the code using the managed extensions to C++. 4)rewrite the code in a .NET language. I wanted to go in direction 4) originally, but I'm no longer sure what makes really sense on this one... My interface is consisting of 3 header files. 2 of them are simply describing enumerations and structs. The third one consists of helper classes in C++ which are easing the use of this interface a lot. I assume that when I would go the wrapping way, that I would only need to wrap the classes I directly touch from my App in c#? If yes then I woud need to wrap only 2 classes? What way to go would be the best, wrapping interop, rewrite? But how would I do that best? Could somebody give me an idea how to do that? Thanks a lot, stonee Attached the sample classes:
//sender.h Class1 to wrap: // Macro to compact duplicate code #define DATA_PACKET &Data.DataPacket, sizeof(Data.DataPacket) class Command { public: CESAPICommand() {TRACE(_T("CESAPICommand()\n"));} virtual bool SendPacket(void* PacketStart, long PacketSize) { TRACE(_T("Virtual SendPacket() called!\n")); return false; }; // Send commands bool inline Init() {CInit Data; return SendPacket(DATA_PACKET);} bool inline SetBox(double dX1, double dY1, double dZ1, double dX2, double dY2, double dZ2) {CSetBox Data(dX1, dY1, dZ1, dX2, dY2, dZ2); return SendPacket(DATA_PACKET);} }; Class2 to wrap: ///Receiver.h class Receive { public: Receive() {TRACE(_T("Receive()\n"));} protected: bool ReceiveData(void* packetStart, long packetSize) { if (packet