-
Notifications
You must be signed in to change notification settings - Fork 0
COM objects
Windows stores COM object information in the Windows Registry. When a particular COM object needs to be created the class details are located in the registry and then implemented. The word class as it is used by Windows and its registry is not the same as a typical class declared in Python, but the implementation is nearly the same. Classes are registered with a unique class ID (CLSID), in the form of a globally unique identifier (128-bit GUID), and a program ID (ProgID), which is a short string that names the object, and is not necessarily unique. Here are some examples:
CLSID: {0000002F-0000-0000-C000-000000000046}
ProgID: 'Application.PowerPoint'
Python programs use the win32com.client.Dispatch() method to create COM objects from a ProgID or CLSID. This is how you would create a PowerPoint COM Object:
import win32com.client
pt = win32com.client.Dispatch("PowerPoint.Application")Python programs that need to use COM interfaces use client-side COM, while Python programs that implement COM interfaces use server-side COM. An example of implementing a COM interface would be creating and registering a COM server object in Python, and using a language such as Visual Basic to access the Python objects (like a VBA add-in that can use Python classes).