title: Using P/Invoke correctly
body: <p>I need to call an external dll from c#. This is the header definition:</p>
  
  <pre><code>enum WatchMode { 
     WATCH_MODE_SYSTEM = 0,          
     WATCH_MODE_APPLICATION  = 1 };  
  
  LONG ADS_API WDT_GetMode ( LONG i_hHandle, WatchMode * o_pWatchMode );
  </code></pre>
  
  <p>I've added the enum and the call in C#:</p>
  
  <pre><code>public enum WatchMode
  {
      WATCH_MODE_SYSTEM = 0,
      WATCH_MODE_APPLICATION = 1       
  }
  [DllImport("AdsWatchdog.dll")]
  internal static extern long WDT_GetMode(long hHandle, ref WatchMode watchmode);
  </code></pre>
  
  <p>This generates an AccessViolationException. I know the dll is 'working' because I've also added a call to <code>GetHandle</code> which returns the <code>hHandle</code> mentioned above. I've tried to change the param to an <code>int</code> (<code>ref int watchmode</code>) but get the same error. Doesn anyone know how I can PInvoke the above call?</p>