如何查找动态加载的 com 对象的成员
我正在尝试使用没有任何文档的 OLE COM 对象。我通过以下方式动态加载com对象:
dynamic comObj = Activator.CreateInstance(Type.GetTypeFromProgID("The Program ID"));
注册表中的程序ID指向某个exe(或者至少我是这么认为的,我不能确定。有没有办法知道它到底指向哪里)。我尝试在 OLE COM 查看器中加载 exe,但无法从中获取任何有用的信息。例如,我无法找到一种我确信存在的方法。实际上,加载 comObject 后,我可以毫无问题地调用此方法,但我想知道是否有一种方法可以列出/查看此 COM 对象的所有成员。
I am trying to use an OLE COM object that I don't have any documentation for. I load the com object dynamically by:
dynamic comObj = Activator.CreateInstance(Type.GetTypeFromProgID("The Program ID"));
The Program ID in the registry points to some exe (or at least that is what I think, I cannot tell for sure. Is there a way to know where exactly does it point to). I tried loading the exe in an OLE COM viewer, but I was not able to get any useful information out of it. For example, I was not able to find a method that I knew for sure was there. Actually, after loading the comObject I am able to invoke this method without any problems, but I would like to know if there is a way that I can list/view all the members of this COM object.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
给定
ProgID
,您可以使用 API 函数和/或查找注册表(例如在HKEY_CLASSES_ROOT
键下)来获取 COM 服务器CLSID
以及托管类,包括可执行文件的完整路径。如果您在那里有对类型库的引用,您还可以加载它并检查已实现的接口和接口信息。您也可以从 COM 对象的实例获取此信息,前提是它实现了 IDispatch、IDispatchEx、IprovideClassInfo 等接口。
Given
ProgID
you can use API functions and/or look up registry (such as underHKEY_CLASSES_ROOT
key) for COM serverCLSID
and binary that hosts the class, including full path to executable.If you have a reference to a type library there, you can also load it and check implemented interfaced and interface information. You can also possibly obtain this information from an instance of COM object too, provided that it implements interfaces like
IDispatch
,IDispatchEx
,IProvideClassInfo
.您可以通过 IDispatch 接口枚举所有方法(如果它支持)。
这是一篇使用 IDispatch 获取成员信息的 MSDN 文章
You can enumerate all of the methods through the IDispatch interface, if it supports it.
Here is an MSDN article that uses IDispatch to get member info
我不记得我在哪里复制了这个来源。恳请作者原谅。
您可以在 C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\ 中找到 CustomMarshalers.dll
I don't remember where I copied this source. I beg a pardon from the author.
You can find the CustomMarshalers.dll in C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\