[python-win32] Callback RemQueryInterface gives E_NOINTERFACE
Jim Bell
Jim at JC-Bell.com
Sat Dec 14 22:28:41 CET 2013
I've been though all the demos and scoured the web, and am stumped. But
I think I'm close. I have a 3rd-party .dll/.tlb. I run makepy.py and it
works fine. I need to pass a callback interface, which they define,
into one of their functions. Here's where I'm stumped.
gencache.EnsureModule('{F8EF...}', 0, 1, 0) # via makepy -i -v
# IID defined in the 3rd-party library...
cbIID = IID('{188....}') # valid IID of ITheirCallBack
# My callback class...
class MyCallBack:
_public_methods_ = [ 'GotMsg' ]
_com_interfaces_ = [ cbIID ] # as defined above
def GotMsg(self, msg):
print 'GotMsg: %s' % str(msg) # Hey!
# This doesn't work: 'Library not registered'
win32com.universal.RegisterInterfaces('{188...}', 0, 1, 0, [
'ITheirCallBack'])
# Instantiate my callback...
cbRaw = MyCallBack() # Works fine.
# If I pass cbIID as param 2 here, I get 'No such interface supported'
cbCom = win32com.server.util.wrap(cbRaw)
cliObj = win32com.client.Dispatch('theirlib.Server.1') # Fine!
# Crux: we make the call,
# but Wireshark shows RemQueryInterface back to us,
# for ITheirCallBack/cbIID,
# and our machine returns E_NOINTERFACE
cliObj.InitServer(cbCom) # Doesn't crash, but fails.
More information about the python-win32
mailing list