title: passing a HANDLE variable to an unmanaged .dll in C++/CLI
body: <p>I am trying to wrap an unmanaged c++ dll that talks to a video capture card in c++/CLI so i can reference the functions from a c# project that i have.  I am having trouble getting the 1st wrapped call to work as I am new to c++/cli syntax.  here is what i have.</p>
  
  <p>here is the function declataion i am trying to wrap.</p>
  
  <pre><code>__declspec(dllimport) BOOL AZ_DeviceCreate(HANDLE&amp; hLiveEvent, DWORD* hEncoderEvent, DWORD* pdwEncoderAddress, HANDLE&amp; hAudioEvent, DWORD&amp; dwAudioAddress);
  </code></pre>
  
  <p>here is my c++/cli .h file</p>
  
  <pre><code>namespace CaptureLibrary 
  {
      public ref class CaptureCard
      {
      public:
          HANDLE m_hLiveEvent;
          DWORD *m_hEncoderEvent;
          HANDLE m_hAudioEvent;
  
      public:
          CaptureCard();
          bool CreateDevice();
          void DisposeDevice();
      };
  }
  </code></pre>
  
  <p>and my .cpp</p>
  
  <pre><code>namespace CaptureLibrary
  {
      CaptureCard::CaptureCard()
      {
          m_hLiveEvent = INVALID_HANDLE_VALUE;
  
          m_hEncoderEvent = new DWORD[MAX_VIDEO_CHANNEL];
          for (BYTE i=0;i&lt;MAX_VIDEO_CHANNEL;i++)
          {
              m_hEncoderEvent[i] = (DWORD)INVALID_HANDLE_VALUE;
          }
  
          m_hAudioEvent = INVALID_HANDLE_VALUE;
      }
  
      bool CaptureCard::CreateDevice()
      {
          DWORD dwEncoderBuff[MAX_VIDEO_CHANNEL];
          DWORD dwACaptureBuffer = 0;
  
          if(AZ_DeviceCreate(m_hLiveEvent, m_hEncoderEvent, dwEncoderBuff, m_hAudioEvent, dwACaptureBuffer)==FALSE)
          {
              return false;
          }
  
          return true;
      }
  
      void CaptureCard::DisposeDevice()
      {
          AZ_DeviceClose();
      }
  }
  </code></pre>
  
  <p>when i compile this with the required headers, i get this error:</p>
  
  <blockquote>
    <p>error C2664: <code>'AZ_DeviceCreate'</code> : cannot convert parameter 1 from <code>'HANDLE'</code> to <code>'HANDLE &amp;'</code></p>
  </blockquote>
  
  <p>Can anyone help me as I know this is a stupid syntax thing that I am doing wrong.</p>
  
  <p>Thanks in advance.</p>