I have been successful in the past using COM from Python to control ActiveX elements such as LabView programs and a few third-party device servers. I recently tried to integrate a new component which came with a LabView example and some Visual Basic sample code. The LabView example works for me and I can examine the methods and properties of the server but I can't seem to do anything with the server from Python.

I can successfully get an instance with:

>>>ps = Dispatch("PPServer.PPServerClass")
>>>ps
<win32com.gen_py.PPServer 1.0 Type Library.IPPServerClass instance at 0x20239664>
>>>cha = ps.ChannelA <--- Fails

and none of the expected methods or properties are exposed except those seen in the attached genpy file.

The VB example shows:

    Set pps = New PServer
    cha = pps.ChannelA

I've tried various combinations, in Python, of ps.ChannelA, ps.Start() etc and none of the documented methods or properties seem to work.

Any thoughts on how to proceed?

Thanks
Rob


# -*- coding: mbcs -*-
# Created by makepy.py version 0.5.00
# By python version 2.7 (r27:82525, Jul  4 2010, 09:01:59) [MSC v.1500 32 bit 
(Intel)]
# From type library 'sniffpol.dll'
# On Wed Nov 03 09:43:53 2010
"""PPServer 1.0 Type Library"""
makepy_version = '0.5.00'
python_version = 0x20700f0

import win32com.client.CLSIDToClass, pythoncom, pywintypes
import win32com.client.util
from pywintypes import IID
from win32com.client import Dispatch

# The following 3 lines may need tweaking for the particular server
# Candidates are pythoncom.Missing, .Empty and .ArgNotFound
defaultNamedOptArg=pythoncom.Empty
defaultNamedNotOptArg=pythoncom.Empty
defaultUnnamedArg=pythoncom.Empty

CLSID = IID('{23D1AE21-8023-11D3-8D47-00C04F949D33}')
MajorVersion = 1
MinorVersion = 0
LibraryFlags = 8
LCID = 0x0

from win32com.client import DispatchBaseClass
class IPPServerClass(DispatchBaseClass):
        """IPPServerClass Interface"""
        CLSID = IID('{23D1AE2F-8023-11D3-8D47-00C04F949D33}')
        coclass_clsid = IID('{23D1AE30-8023-11D3-8D47-00C04F949D33}')

        def AllowAutomaticSniffing(self):
                """method AllowAutomaticSniffing"""
                return self._ApplyTypes_(1, 1, (12, 0), (), 
u'AllowAutomaticSniffing', None,)

        _prop_map_get_ = {
        }
        _prop_map_put_ = {
        }

from win32com.client import CoClassBaseClass
# This CoClass is known by the name 'PPServer.PPServerClass.1'
class PPServerClass(CoClassBaseClass): # A CoClass
        # PPServerClass Class
        CLSID = IID('{23D1AE30-8023-11D3-8D47-00C04F949D33}')
        coclass_sources = [
        ]
        coclass_interfaces = [
                IPPServerClass,
        ]
        default_interface = IPPServerClass

IPPServerClass_vtables_dispatch_ = 1
IPPServerClass_vtables_ = [
        (( u'AllowAutomaticSniffing' , u'pvarShow' , ), 1, (1, (), [ (16396, 
10, None, None) , ], 1 , 1 , 4 , 0 , 28 , (3, 0, None, None) , 0 , )),
]

RecordMap = {
}

CLSIDToClassMap = {
        '{23D1AE2F-8023-11D3-8D47-00C04F949D33}' : IPPServerClass,
        '{23D1AE30-8023-11D3-8D47-00C04F949D33}' : PPServerClass,
}
CLSIDToPackageMap = {}
win32com.client.CLSIDToClass.RegisterCLSIDsFromDict( CLSIDToClassMap )
VTablesToPackageMap = {}
VTablesToClassMap = {
        '{23D1AE2F-8023-11D3-8D47-00C04F949D33}' : 'IPPServerClass',
}


NamesToIIDMap = {
        'IPPServerClass' : '{23D1AE2F-8023-11D3-8D47-00C04F949D33}',
}


_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to