[python-win32] Adding an "Interface" from IDL / tlb files to an existing win32COM-Object
mail-an-XYZ at gmx.net
mail-an-XYZ at gmx.net
Mon Feb 26 09:29:17 CET 2007
Hallo,
I need help in adding an existing Interface to an object I dispatched from a COM-server via win32com in Python.
The Code for this in VisualBasic looks like that:
Private Obj_1 As Obj1_LIB.Impl_1
Private mHelper As Object
Private m_applJob As Object
Private m_applModul As interface_Module //interface_Module is described in an IDL/TLB-File
Private cont As Boolean
Private c_applJob As New ApplicationJob.Job
Set m_Obj_1 = CreateObject("Obj1_LIB.Impl_1")
m_Obj_1.Init
Set mHelper = CreateObject("ModulHelper.Helper")
Set m_applJob = CreateObject("ApplicationJob.Job")
Set m_applModul = m_applJob
m_applModul.method1_from_appl_module
m_applModul.method2_from_appl_module
These methods (method1/_from_appl_module) are part of the interface loaded from interface_module and not part of the m_applJob-Object. Nevertheless, m_applModul now also supports all methods from the m_applJob-Object.
So how can I do this in Python?
I tried this, which didn't work:
import win32com.client
Obj_1 = win32com.client.Dispatch("Obj1_LIB.Impl_1")
Obj_1.Init()
ModulHelp = win32com.client.Dispatch("ModulHelper.Helper")
applJob = win32com.client.Dispatch("ApplicationJob.Job")
applJob._oleobj_.QueryInterface("{7DE9DB29-1794-4C3B-95EA-E1324B15BBE6}") ##using the uuid of the interface described in the IDL
The error-message I receive is:
Traceback (most recent call last):
File "C:\PROGRA~1\python\lib\site-packages\Pythonwin\pywin\framework\scriptutils.py", line 310, in RunScript
exec codeObject in __main__.__dict__
File "M:\Diagnose\Projekt EE61\ApplJob4test.py", line 655, in ?
m_applJob=applJob._oleobj_.QueryInterface("{7DE9DB29-1794-4C3B-95EA-E1324B15BBE6}")
com_error: (-2147467262, 'Schnittstelle nicht unterst\xfctzt', None, None)
or, sometimes:
Traceback (most recent call last):
File "C:\PROGRA~1\python\lib\site-packages\Pythonwin\pywin\framework\scriptutils.py", line 310, in RunScript
exec codeObject in __main__.__dict__
File "M:\Diagnose\Projekt EE61\ApplJob4test.py", line 655, in ?
m_applJob=applJob._oleobj_.QueryInterface("{7DE9DB29-1794-4C3B-95EA-E1324B15BBE6}")
TypeError: There is no interface object registered that supports this IID
The second question is:
How can I import data-types from a tlb to my python-code? Is that possible at all???
Thanks for your help on this!
--
Ist Ihr Browser Vista-kompatibel? Jetzt die neuesten
Browser-Versionen downloaden: http://www.gmx.net/de/go/browser
More information about the Python-win32
mailing list