Strange problem with PythonCOM 
Author Message
 Strange problem with PythonCOM

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.*-*-*.com/
Before you buy.



Sat, 07 Dec 2002 03:00:00 GMT  
 Strange problem with PythonCOM

Quote:

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

I found a partial answer to this myself - it appears that the
TLIApplication class does not support IDispatch, even though its main
interface derives from IDispatch! I determined this when I got the same
error creating the object from C++. This looks like an egregious error
to me!

There's still the question of how this works in VB. Maybe they're doing
something "questionable" under the hood that allows this to work.

I'm still interested in a Python-only solution to this. My workaround
has been to write a C++ COM component that creates the object for me
and does the work for me (although VB would've worked as well).

-----------------------------
Barry Hart

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



Sat, 07 Dec 2002 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. pythoncom.Missing vs. pythoncom.Empty

2. PythonCOM Problem: Automating WinFAX from Python

3. problems with pythoncom and VB-generated OLE/ActiveX DLL

4. How to compile PythonCOM.dll and Variant problem

5. Problem with 1.5 PythonCom beta

6. Pythoncom shutdown problems

7. Strange, very strange

8. Strange and serious problem on WinXP

9. Very strange problem in 5i

10. Strange problem with Linux/Vwnc30/Socketes

11. Strange Problem...

 

 
Powered by phpBB® Forum Software