O'Reilly logo

Python Programming On Win32 by Mark Hammond, Andy Robinson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Testing a Remote Object Using DCOM-Specific Calls

You may have noticed that the DCOM configuration dialog states “Client applications may override your selection.” So when you configure DCOM, you really just provide default values for non-DCOM-aware programs. In fact, if you want to make your client code DCOM-aware, it isn’t necessary to configure DCOM on the local machine at all; your client code provides the information needed.

To demonstrate this, let’s restore the DCOM configuration on the local machine to the defaults. Restart the DCOM configuration tool and again select the Python.Interpreter object. Select the Location tab and restore the settings to how you first found them. The dialog should look similar to Figure 12.8.

Back to the default DCOM configuration for the object
Figure 12.8. Back to the default DCOM configuration for the object

Select the OK button to apply the changes.

First, let’s check that the object is indeed restored correctly. Execute the same lines of code used previously, but because the DCOM configuration has been restored, the object should be local:

>>> i=win32com.client.Dispatch("Python.Interpreter", clsctx=clsctx)
>>> i.Exec("import win32api")
>>> i.Eval("win32api.GetComputerName()")
'BOBCAT'
>>>

As expected, the local machine name is now being used, and you should be able to locate a pythonw.exe process running on the local computer.

The win32com.client.DispatchEx() function allows you to override the DCOM ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required