title: How to write my C++ function so I can call it from C#?
body: <p>I have C++ code. That code contains Windows mobile GPS enable/disable functionality. I want to call that method from C# code, that means when the user clicks on a button, C# code should call into C++ code.</p>
  
  <p>This is the C++ code for enabling the GPS functionality:</p>
  
  <pre><code>#include "cppdll.h"
  
  void Adder::add()
  {
  // TODO: Add your control notification handler code here
    HANDLE hDrv = CreateFile(TEXT("FNC1:"), GENERIC_READ | GENERIC_WRITE,
                  0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
    if (0 == DeviceIoControl(hDrv, IOCTL_WID_GPS_ON, NULL, 0, NULL, 0, NULL, NULL))
    {
       RETAILMSG(1, (L"IOCTL_WID_RFID_ON Failed !! \r\n")); return;
    }
       CloseHandle(hDrv);
  
   return (x+y);
  }
  </code></pre>
  
  <p>And this is the header file <code>cppdll.h</code>:</p>
  
  <pre><code>class __declspec(dllexport) Adder
  {
    public:
     Adder(){;};
    ~Adder(){;};
   void add();
  };
  
  </code></pre>
  
  <p>How can I call that function using C#?</p>
  
  <p>Please, can anybody help me out with this issue?</p>