简体   繁体   English

如何从后期绑定的COM对象获取方法列表

[英]How to get a list of Methods from a late bound COM object

I need a list of the methods and properties exposed by a COM object. 我需要一个COM对象公开的方法和属性的列表。 I am able to late bind the object and use some basic methods that I found in an example code snippet but I need to find out the full list of methods and properties on the object. 我可以后期绑定对象,并使用在示例代码片段中找到的一些基本方法,但是我需要找出对象上方法和属性的完整列表。

More info: 更多信息:

I am trying to pull data from a fairly old system and am unable to early bind any of the dlls. 我正在尝试从相当旧的系统中提取数据,并且无法早期绑定任何dll。

I do have some snippets of example code from the company that creates these dlls (it was packaged with the software), however it does not have code for all of the advanced functionality I am seeing from their example application (which I do not have source code to). 我确实有创建这些dll的公司的一些示例代码片段(它与软件打包在一起),但是它没有我从其示例应用程序中看到的所有高级功能的代码(我没有源代码)代码)。

I have already tried using reflection without much success. 我已经尝试过使用反射,但没有成功。

Assuming that you don't need to programatically access the information, the easiest way is to the OLE-COM object viewer. 假设您不需要以编程方式访问信息,最简单的方法是使用OLE-COM对象查看器。 The tool is part of the Windows SDK . 该工具是Windows SDK的一部分。

Once running, look in the Type Library node and locate the type library of the component that you are using. 运行后,在“类型库”节点中查找并找到您正在使用的组件的类型库。 The Type Library viewer will show you all of the dispatch interfaces defined by the component. 类型库查看器将向您显示该组件定义的所有调度接口。

If you can't add the DLL to VB6 in the References dialogue, then there is no Type Library resource embedded in the DLL. 如果无法在“引用”对话框中将DLL添加到VB6,则DLL中没有嵌入类型库资源。 If you can load the DLL, you should be able to use F2 to bring up Object Browser, and see all of the properties and methods of the component. 如果可以加载DLL,则应该能够使用F2来打开“对象浏览器”,并查看组件的所有属性和方法。

It seems unlikely that you hadn't tried this. 您似乎没有尝试过此方法的可能性很小。 So there are three possibilities: 因此,存在三种可能性:

  1. There is an external type library for the component. 该组件有一个外部类型库。
  2. You got an error when adding the DLL as a reference, which essentially said the VB IDE couldn't find a type library in the component. 将DLL添加为引用时出现错误,这实际上表示VB IDE在组件中找不到类型库。
  3. You got an error when adding the DLL as a reference, saying something like "Could not load DLL". 将DLL作为参考添加时出现错误,提示类似“无法加载DLL”。

Just in case of 1. - check if there is a TLB or OLB file for this component. 以防万一。-检查此组件是否有TLB或OLB文件。 If you got the error in 2. - then you are out of luck. 如果您在2中遇到错误,则表示您不走运。 You will require access to documentation and/source code. 您将需要访问文档和/源代码。 If you got the error in 3. - then there is probably a dependent library which has not been registered. 如果您在3中遇到错误--则可能是一个未注册的从属库。 Try to find the dependent TLB or DLL, and register it. 尝试找到相关的TLB或DLL,然后注册它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM