[python-win32] Win32com , how select coclass interface?
e8micke
e8micke at yahoo.com
Thu Oct 19 09:14:53 CEST 2006
> > I have a DLL that have several interfaces
> accociated
> > with a CoClass, but there is one default
> interface.
> >
> > snip from my genpy generated .py file:
> > ------------------------------
> > coclass_sources = [
> > ]
> > coclass_interfaces = [
> > I2250Instrument,
> > IDisposable,
> > I2250Control,
> > IRemoteAPI,
> > IRemoteInfo,
> > I2250Connect,
> > _Object,
> > I2250Archive,
> > I2250Export,
> > ]
> > default_interface = IRemoteAPI
> > --------------------
> It should be possible to use win32com.client.CastTo
> - something like:
> q = win32com.client.CastTo(q, 'IRemoteAPI')
Thanks Mark, that worked very well!
Thank you very much, I am now able to talk to a
dBmeter from Brüel & Kjær, via USB and Python.
http://www.bksv.com/3156.asp
Sample Code if anyone else needs to do this task (on
the 2250 model):
import win32com.client
q =
win32com.client.Dispatch("BK.BasicEnv.Application.RemoteAPI")
Instrument = win32com.client.CastTo(q,
'I2250Instrument')
Connect = win32com.client.CastTo(q, 'I2250Connect')
Control = win32com.client.CastTo(q, 'I2250Control')
instrumentNames=Connect.GetInstrumentNames()
Connect.Connect (instrumentNames[0])
db=Control.ReadOutputInt16(instrumentNames[0],
"LACF(SPL)")
print "dBA value %.1f\n" % (db/100.0)
q.Disconnect()
Best regards
Mikael
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
More information about the Python-win32
mailing list