ivan_pozdeev ivan_pozdeev - 1 year ago 99
Python Question

Instantiate COM object that doesn't have ProgID by class/interface name

docs for client-side COM show this basic way to instantiate COM objects:

obj = win32com.client.Dispatch("<ProgID>")

I'm trying to work with
akin to Manipulating the zone identifier to specify where a file was download from – The Old New Thing - MSDN blogs. That class, as the registry at
shows, doesn't have a corresponding

I see that there's an underlying
function that accepts a
to instantiate and an
to apparently query from it.

But this is inconvenient because I have to use unintelligible GUIDs instead of human-readable names.

The question is:

  • Is there a stock way in
    /underlying WinAPI to look up the aforementioned GUIDs by names? (do not suggest searching the registry by hand)

  • Or maybe some other way to instantiate that object with names?

What I tried and failed:
win32com.client.IDispatch(<class/interface name>)
pythoncom.IID(<class/interface name>)
. Also looked through the Net, MSDN and PyWin32 docs, of course.

Answer Source

There is no, and can't be any, "stock mechanism" to instantiate a class/query an interface by its name because their names aren't guaranteed to be unique, unlike GUIDs.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download