[python-win32] How to implement a callback COM object
Michael Bode
m.g.bode at web.de
Wed Nov 17 07:40:34 CET 2010
Hi,
I've problems to get started with COM programming. I'm trying to write a
COM client which uses a COM server controlling an instrument (power
meter). The COM Server is using a DLL called FieldMax2ServerDLL which is
registered. I've run makepy to get the bindings. Now to do anything
useful with the server I have to implement a callback object which
implements an interface from said DLL. I have VB sample code, but don't
know how to translate that to python:
Option Explicit
Implements IFM2DeviceEvents
Private m_CallbackEvent As String
Private m_CallbackMessage As String
Private m_DeviceIndex As Integer
Private m_SerialNumber As String
Private m_ZeroDeviceTimeoutCounter As Integer
' Methods
Private Sub IFM2DeviceEvents_DisplayErrorToClient()
frmTest.DisplayErrorMessage m_CallbackMessage
End Sub
Private Sub IFM2DeviceEvents_NotifyData(ByVal CallbackData As
IFM2DeviceEvents)
frmTest.NotifyData CallbackData
End Sub
Private Sub IFM2DeviceEvents_NotifyDeviceStatus(ByVal CallbackData As
IFM2DeviceEvents, ByVal DevicesList As cFM2Devices)
frmTest.NotifyDeviceStatus CallbackData, DevicesList
End Sub
Private Sub IFM2DeviceEvents_DisplayZeroDeviceProgressToClient()
frmTest.DisplayZeroDeviceProgress m_CallbackMessage,
m_ZeroDeviceTimeoutCounter
End Sub
' Read/write properties
Private Property Let IFM2DeviceEvents_CallbackEvent(ByVal RHS As String)
m_CallbackEvent = RHS
End Property
Private Property Get IFM2DeviceEvents_CallbackEvent() As String
IFM2DeviceEvents_CallbackEvent = m_CallbackEvent
End Property
...
--
PGP fingerprint: A391 4109 F8D0 F67B C504 1EF6 0158 E3BB 3687 53CF
More information about the python-win32
mailing list