Seite 1 von 1

Hinzufügen eines "Interface" (IDL / tlb) zu einem

Verfasst: Montag 26. Februar 2007, 09:17
von VolkerS
Hallo,
Ich benötige Hilfe beim Hinzufügen eines Interfaces aus einer IDL bzw. TLB-Datei zu einem Objekt, das ich über win32com.client.dispatch erstellt habe. In Visual Basic ist das kein Problem und sieht so aus:
The Code for this in VisualBasic looks like that:

Code: Alles auswählen

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

Die Methoden (method1/_from_appl_module) sind Teil des Interfaces, das aus der interface_module geladen wurde und nicht von m_applJob-Object. Dennoch besitzt m_applModul jetzt auch alle Methoden des m_applJob-Object.

Die Frage ist: Wie mache ich das in Python?
Ich habe es so probiert (es hat nicht funktioniert...):

Code: Alles auswählen

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}")  ##das ist die uuid des Interfaces, das in der IDL-Datei beschrieben ist
Die Fehlermeldung sieht so aus:

Code: Alles auswählen

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)
Ebenso möchte ich Typ-deklarationen aus einer TLB in python reinldane. Ist das prinzipiell möglich?

Vielen Dank für Eure Hilfe!!

Edit (Leonidas): Code in Python-Tags gesetzt.

das selbe Problem

Verfasst: Freitag 16. November 2007, 14:21
von cos
Hallo,

ich habe das selbe Problem wie mein Vorredner und weiß nicht genau weiter. Hat jemand eine Idee oder einen Ansatz wie man das machen kann?

Gruß
cos