title: Passing different type of objects to unmanaged function
body: <p>First: I'm sorry if the title is wrong. I'm not sure how to name my problem.</p>
  
  <p>In my C API I have a function:</p>
  
  <pre><code>MYAPI_STATUS SetParam(void *hInst, unsigned long param, void *value);
  </code></pre>
  
  <p>This function accepts different types of pointers depending on <code>param</code> type. Like this:</p>
  
  <pre><code>SetParam(hInst, 1, (void*)"somevalue");
  int x = 55;
  SetParam(hInst, 2, &amp;x); 
  </code></pre>
  
  <p>I'm just writing a wrapper/binding in C# and I have a problem.</p>
  
  <pre><code>[DllImport("myapi", CallingConvention = CallingConvention.Cdecl]
  public static extern uint SetParam(IntPtr hInst, uint paramCode, IntPtr paramValue);
  </code></pre>
  
  <p>What's the best way to replicate behaviour from C? So the function would look like:</p>
  
  <pre><code>public static uint SetParam(IntPtr hInst, uint paramCode, ref object paramValue);
  </code></pre>
  
  <p>or possibly:</p>
  
  <pre><code>public static uint SetParam(IntPtr hInst, uint paramCode, object paramValue);
  </code></pre>