开发者

How do I get the assembly/file versions for an object in VB6?

Is there a way to get the file and/or assembly version for an object in VB6?

We are having some reference issues, and I am able to create the object in late binding on the machine 开发者_如何学运维that is having problems so I am hoping to spit out the version it is grabbing to figure out where that version is sitting.


It sounds as if you have access to the problem machine.

If this is an in-process object (DLL or OCX) can I recommend you just use ProcessExplorer instead?

Do Start\Run and type http://live.sysinternals.com/procexp.exe to run Process Explorer. Highlight your application in the process list, switch to DLL view, and the lower pane will show the path and version number of all DLLs and OCXs loaded by the process.

If it is an out-of-process object, I suggest looking in the registry to see which program is registered as the server.

  1. First find the CLSID by using the ProgID to find an entry in the registry. The ProgID is the human-readable string that can be used with CreateObject, e.g. Excel.Application. The CLSID is a 128-bit number, in hex, within a pair of curly braces. Look at the registry entry HKEY_LOCAL_MACHINE\SOFTWARE\Classes\{ProgID}\CLSID

  2. Look at the LocalServer32 entry underneath HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID\{ClsId}\, where {ClsId} is the class-id of the object. This entry gives you the path to the exe that provides the object.


You might try to use TypeLibInfo to fish some information out.

In VB6, go to References and reference TypeLib Information. Then create an object and, in the debugger, try to examine various properties. Example:

  Dim x As Object

  Set x = CreateObject("Excel.Application")
  x.Visible = True


  Dim ti As TLI.TLIApplication
  Set ti = New TLI.TLIApplication

  With ti.InterfaceInfoFromObject(x)
    MsgBox .Guid
  End With


  'Close Excel yourself if things went bad.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜