title: Sending handle over Windows RPC
body: <p>I'm developing a RPC client and a local RPC server using <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/aa378651%28v=vs.85%29.aspx" rel="nofollow noreferrer">Windows RPC</a>. I need the server to be able to manipulate a window created by the client.</p>
  
  <p>As described <a href="https://stackoverflow.com/questions/2499487/sharing-hdc-between-different-processes">here</a> and <a href="https://stackoverflow.com/questions/819710/duplicatehandle-use-in-first-or-second-process?rq=1">here</a>, HWND are cross-process handles (system-wise) and can be used by another process as long as they are being duplicated properly (by using <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/ms724251%28v=vs.85%29.aspx" rel="nofollow noreferrer">DuplicateHandle</a>).</p>
  
  <p>I'm trying to send the client's HWND to the server but i'm getting the following error when trying to make the RPC call:</p>
  
  <blockquote>
    <p>0x000006C5: The tag is invalid</p>
  </blockquote>
  
  <p>I defined the HWND parameter in the IDL file as follows:</p>
  
  <pre><code>HRESULT MyRpcFunction ([in, out] HWND hwnd);
  </code></pre>
  
  <p>Any suggestions on how I can properly send the handle to the server?</p>