2

我知道这可能是一个很长的镜头,所以请原谅我,因为我对 COM 不太了解。

基本上我要做的是获取指向正在运行的应用程序的 IUnknown 接口的指针,问题是我对应用程序唯一了解的是它的主窗口句柄。

这可能吗?

4

2 回答 2

3

执行此操作的“标准”方法是使用AccessibleObjectFromWindow Win32 API。也就是说,实际上支持这一点的东西并不多,因此您的里程可能会有所不同。您将 PInvoke 到 AccessibleObjectFromWindow,传递 HWND,然后在返回的 IntPtr 上使用 Marshal.GetObjectForIUnknown。

于 2009-11-19T04:29:59.943 回答
1

Sometimes yes, if the window is in your process (otherwise a pointer in another process is meaningless to you) and the window's writer explicitly tell you that it is expecting a message and returning an interface. Mostly no, people usually do not write hacks when there is no need to and sending messages unknown to the writer would have unpredictable behavior.

于 2009-11-19T01:03:07.360 回答