Strange problem with PythonCOM

barryhart at my-deja.com barryhart at my-deja.com
Tue Jun 20 00:01:03 EDT 2000


I'm trying to use PythonCOM to call into TLBINF32.dll (the Microsoft
type library info DLL), and I'm getting a strange error. My call to
create the object - Dispatch("TLI.TLIApplication") - fails with "No
such interface supported."

On the surface, this error would appears to indicate the TLIApplication
class does not support IDispatch. This makes no sense, however, because
I am able to use the class successfully using late bound calls (i.e.
using an Object variable) from VB.

The code is posted below - the currently non-working Python code and
the working VB code.

Any ideas?

Thanks,
Barry Hart

---Python code---

import win32com.client

def GetTypeLibPath(sGuid, nMajorVersion, nMinorVersion):
    objTypeLibApplication = win32com.client.Dispatch
("TLI.TLIApplication")
    objTypeLibInfo = objTypeLibApplication.TypeLibInfoFromRegistry(
        sGuid,
        nMajorVersion,
        nMinorVersion,
        0)
    return objTypeLibInfo.ContainingFile

print GetTypeLibPath("{00000600-0000-0010-8000-00AA006D2EA4}", 2, 1)

---equivalent VB code---

Function GetTypeLibPath(ByVal sGuid As String, ByVal nMajorVersion As
Integer, ByVal nMinorVersion As Integer) As String
    Set objTypeLibApplication = CreateObject("TLI.TLIApplication")
    Set objTypeLibInfo = objTypeLibApplication.TypeLibInfoFromRegistry(
_
        sGuid, _
        nMajorVersion, _
        nMinorVersion, _
        0)
    GetTypeLibPath = objTypeLibInfo.ContainingFile
End Function

Sub test()
    MsgBox GetTypeLibPath("{00000600-0000-0010-8000-00AA006D2EA4}", 2,
1)
End Sub


Sent via Deja.com http://www.deja.com/
Before you buy.



More information about the Python-list mailing list