私は UPnP Object Method IUPnPDeviceFinder
::を使用して[CreateAsyncFind][1]
おり、3 番目のパラメーターはコールバック関数です。
独自の COM オブジェクトを作成しようとしましたが、メソッドが関数をコールバックしません。これが私のコードです:
class Callback():
_public_methods_ = ['DeviceAdded','DeviceRemoved', 'SearchComplete']
_reg_progid_ = "UPnP.PythonCallback"
_reg_clsid_ = pythoncom.CreateGuid()
def DeviceAdded (device, UDN, calltype):
print (device, ": ", calltype, " UDN: ", UDN)
return
win32com.server.register.UseCommandLine(Callback)
callserver = Dispatch("UPnP.PythonCallback")
deviceType = "urn:schemas-upnp-org:device:MediaServer:1"
devices = finder.CreateAsyncFind(deviceType,0, callserver)
finder.StartAsyncFind(devices)
実際には、次のようなものが必要です。
def DeviceAdded (device, UDN, calltype):
print (device, ": ", calltype, " UDN: ", UDN)
return
deviceType = "urn:schemas-upnp-org:device:MediaServer:1"
devices = finder.CreateAsyncFind(deviceType,0, DeviceAdded)
finder.StartAsyncFind(devices)
Microsoft は VBScript の例を作成しました。それはまさに私が Python でやりたいことです (http://msdn.microsoft.com/en-us/library/windows/desktop/aa381078(v=VS.85).aspx) 関数をパラメーターとして渡すにはどうすればよいですかCOM オブジェクトで?