1

I'm developing a RPC client and a local RPC server using Windows RPC. I need the server to be able to manipulate a window created by the client.

As described here and here, HWND are cross-process handles (system-wise) and can be used by another process as long as they are being duplicated properly (by using DuplicateHandle).

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:

0x000006C5: The tag is invalid

I defined the HWND parameter in the IDL file as follows:

HRESULT MyRpcFunction ([in, out] HWND hwnd);

Any suggestions on how I can properly send the handle to the server?

Community
  • 1
  • 1
Mr. Anderson
  • 1,609
  • 1
  • 13
  • 24
  • 4
    A `HWND` is a USER object. `DuplicateHandle` is meant for KERNEL objects. And why on earth would you implement RPC, only to bypass the carefully crafted communication channel, and reach out to manipulate the window directly? This is screaming *"wrong"* all over. – IInspectable May 27 '15 at 10:33
  • I need the RPC server to be able to create a separate window that is "linked" to the given window (location, size, prevent focus from given window until new window gets closed) – Mr. Anderson May 28 '15 at 10:32
  • You've marked the parameter as [in, out], but this typically means that the parameter is a pointer and that the thing it's pointing to is in/out. You don't want this behavior, so try removing the [in, out], and if that doesn't work try using UINT64 as the type and casting. You basically don't want MIDL to think this is a pointer to an object. – zhuman - MSFT Apr 18 '18 at 01:51

0 Answers0