0

Well, actually I know I can communicate with the window itself, the plane GUI, through it's message pump, but let's say I want to call a COM exposed function in the Delphi DLL that produced and maintains that window? I would first somehow have to determine the module that owns the window.

Communications to the Delphi side are minimal: you are now hosted, your host ID is x, can you close, you must close, etc. The rest of the time I will expose my host as a COM object the Delphi code can more easily talk to.

mate64
  • 9,876
  • 17
  • 64
  • 96
ProfK
  • 49,207
  • 121
  • 399
  • 775

2 Answers2

1

If you have the HWND, you can use GetWindowLong/Ptr(GWL_HINSTANCE) to retrieve the module that the window is associated with.

Another option is to have the DLL register its COM object in the ROT (Running Object Table) and then you can simply query the ROT for the COM object when needed. No HWND needed.

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
0

Since this is in process, and since you have a window available, you can send a user defined message to request the COM object. And then you are all set.

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
  • How does the guest window respond to such a request? Does it return the module name and object name, or an int pointer to an object and an int pointer to some module register somewhere? – ProfK Jan 14 '14 at 04:52
  • It just returns a pointer to the COM object. I don't understand why you are interested in module names. – David Heffernan Jan 14 '14 at 07:09
  • instrumentation, audit, and control. I'll be hosting tens of plugins. – ProfK Jan 14 '14 at 12:14
  • I mean, why is module name important for finding this COM object? – David Heffernan Jan 15 '14 at 07:44
  • I don't know how COM objects are identified in Windows. Does each have a unique pointer across the whole process. I thought maybe the pointer was coupled to module. – ProfK Jan 15 '14 at 10:01