简体   繁体   中英

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. 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.

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).

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. The tool is part of the 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. 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.

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.
  3. You got an error when adding the DLL as a reference, saying something like "Could not load DLL".

Just in case of 1. - check if there is a TLB or OLB file for this component. If you got the error in 2. - then you are out of luck. 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. Try to find the dependent TLB or DLL, and register it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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