Connecting Tech Pros Worldwide Forums | Help | Site Map

Adding an "Interface" from IDL / tlb files to an existing win32COM-Object

Newbie
 
Join Date: Feb 2007
Posts: 2
#1: Feb 23 '07
Hallo,
I need helping 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:
Expand|Select|Wrap|Line Numbers
  1. Private Obj_1 As Obj1_LIB.Impl_1
  2. Private mHelper As Object
  3. Private m_applJob As Object
  4. Private m_applModul As interface_Module //interface_Module is described in an IDL/TLB-File
  5. Private cont As Boolean
  6. Private c_applJob As New ApplicationJob.Job
  7.  
  8.  Set m_Obj_1 = CreateObject("Obj1_LIB.Impl_1")
  9. m_Obj_1.Init
  10.  
  11.  Set mHelper = CreateObject("ModulHelper.Helper")
  12. Set m_applJob = CreateObject("ApplicationJob.Job")
  13.     Set m_applModul = m_applJob
  14.  
  15.     m_applModul.method1_from_appl_module
  16.     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:
Expand|Select|Wrap|Line Numbers
  1. import win32com.client
  2. Obj_1 = win32com.client.Dispatch("Obj1_LIB.Impl_1")
  3. Obj_1.Init()
  4.  
  5. ModulHelp = win32com.client.Dispatch("ModulHelper.Helper")
  6. applJob = win32com.client.Dispatch("ApplicationJob.Job")
  7.  
  8. applJob._oleobj_.QueryInterface("{7DE9DB29-1794-4C3B-95EA-E1324B15BBE6}")  ##using the uuid of the interface described in the IDL
  9.  
This says "interface not supported"

I'd appreciate your help in this!

bartonc's Avatar
Moderator
 
Join Date: Sep 2006
Location: Minden, Nevada, USA
Posts: 6,400
#2: Feb 26 '07

re: Adding an "Interface" from IDL / tlb files to an existing win32COM-Object


Quote:

Originally Posted by VolkerS

Hallo,
I need helping 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:

Expand|Select|Wrap|Line Numbers
  1. Private Obj_1 As Obj1_LIB.Impl_1
  2. Private mHelper As Object
  3. Private m_applJob As Object
  4. Private m_applModul As interface_Module //interface_Module is described in an IDL/TLB-File
  5. Private cont As Boolean
  6. Private c_applJob As New ApplicationJob.Job
  7.  
  8.  Set m_Obj_1 = CreateObject("Obj1_LIB.Impl_1")
  9. m_Obj_1.Init
  10.  
  11.  Set mHelper = CreateObject("ModulHelper.Helper")
  12. Set m_applJob = CreateObject("ApplicationJob.Job")
  13.     Set m_applModul = m_applJob
  14.  
  15.     m_applModul.method1_from_appl_module
  16.     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:
Expand|Select|Wrap|Line Numbers
  1. import win32com.client
  2. Obj_1 = win32com.client.Dispatch("Obj1_LIB.Impl_1")
  3. Obj_1.Init()
  4.  
  5. ModulHelp = win32com.client.Dispatch("ModulHelper.Helper")
  6. applJob = win32com.client.Dispatch("ApplicationJob.Job")
  7.  
  8. applJob._oleobj_.QueryInterface("{7DE9DB29-1794-4C3B-95EA-E1324B15BBE6}")  ##using the uuid of the interface described in the IDL
  9.  
This says "interface not supported"

I'd appreciate your help in this!

It would help if you paste the whole error message. Sometimes, even if a pythoneer dosn't know a particular package, they can deduce what's wrong from the error message. Thanks.
Newbie
 
Join Date: Feb 2007
Posts: 2
#3: Feb 26 '07

re: Adding an "Interface" from IDL / tlb files to an existing win32COM-Object


The error message I get 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("{7DE9DB 29-1794-4C3B-95EA-E1324B15BBE6}")
com_error: (-2147467262, 'Schnittstelle nicht unterst\xfctzt', None, None)

in fact it also happens (sometimes, without changing the code) that I get this message:

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("{7DE9DB 29-1794-4C3B-95EA-E1324B15BBE6}")
TypeError: There is no interface object registered that supports this IID
Reply