84840

Python win32com don't know name of module

Question:

I was looking for a python Zune(The windows media thing) api, when I looked at the COM browser in pythonwin. I found something called ZuneWmdu Type Library (1.0). I used makepy on that lib, it generated a file

9FE20C05-81CE-46D7-9C56-FD97A865BBB8x0x1x0.py

in

python 2.7.3\Lib\site-packages\win32com\gen_py

I have no idea what to pass into

win32com.client.gencache.EnsureDispatch('???')

I tried calling

win32com.client.gencache.EnsureDispatch('9FE20C0581CE46D79C56FD97A865BBB8')

Resulting in an exception (pywintypes.com_error)

(The x0x1x0 part of the .py file seemed unrelated)

I tried the same with

win32com.client.gencache.GetModuleForCLSID('9FE20C05-81CE-46D7-9C56-FD97A865BBB8') and win32com.client.gencache.GetModuleForProgID('9FE20C0581CE46D79C56FD97A865BBB8')

Both returning None. I'm stuck here, I need to either find what the library is called (for itunes, you'd call:

win32com.client.gencache.EnsureDispatch('iTunes Application')

for example) or how to call the module with the GUID

Or even someone to tell me that I'm doing something completely wrong.

Answer1:

The name of the CoClass can be found in the comments of the generated file (where they are based on the information from pythoncom.ProgIDFromCLSID).

I don't have Zune but, if, for instance I run

win32com.client.gencache.EnsureModule('{420B2830-E718-11CF-893D-00A0C9054228}', 0, 1, 0)

this will generate a file called 420B2830-E718-11CF-893D-00A0C9054228x0x1x0.py from which I can dig out the relevant names:

C:\Users\username\AppData\Local\Temp\gen_py\3.6>grep 'known by' *.py 420B2830-E718-11CF-893D-00A0C9054228x0x1x0.py:# This CoClass is known by the name 'Scripting.Dictionary' 420B2830-E718-11CF-893D-00A0C9054228x0x1x0.py:# This CoClass is known by the name 'Scripting.Encoder' 420B2830-E718-11CF-893D-00A0C9054228x0x1x0.py:# This CoClass is known by the name 'Scripting.FileSystemObject'

Recommend

  • Spring 4 CachingConnectionFactory with JMS 2.0 doesn't properly cache Producers
  • What is the type VoidTaskResult as it relates to async methods?
  • Sleep Lib “kernel32” gives 64-bit systems error
  • Woocommerce Progressive extra cost based on total number of items in the cart
  • Amazon MWS signature issue
  • ConfidentialClientApplication AcquireTokenSilentAsync always fails
  • Clearing Custom Tool file property in Visual Studio 2010
  • Install themeforest theme in wordpress.com [closed]
  • Object browser in vba7 does not show WebClient Object members [duplicate]
  • Convert longitude latitude coordinates (WGS) to grid with equidistant axes (in given area)
  • What is the correct way to get OpenCL to play nice with OpenGL in Qt5?
  • C++ how to read from unicode files by ignoring first character of each line
  • Scrapy and submitting a javascript form
  • How to wrap string in span before and after all newlines in PHP?
  • Passing Objects to fragment without argument
  • Get a list of who has what access to git repositories
  • PostgreSQL in Docker - pg_hba.conf to allow access from host to container
  • Reveal Icon Button - Bootstrap 3
  • How to detect beginning of line, or: “The name 'getCharPositionInLine' does not exist in t
  • ODBC connection to an .accdb file
  • Existing data serialized as hash produces error when upgrading to Rails 5
  • Repeatable job for Laravel json api
  • how to synchronize web site content while loading page
  • Creating and managing two independent random number sequences
  • Read specific column from Parquet without using Spark
  • Bazel failed to include a external static library .a
  • Greedy Algorithm in “C”
  • Could not resolve all files for configuration ':react-native-vector-icons:classpath'
  • Using loops in Jasmine (with injected service)
  • python socket.sendto
  • MayAVI install on Python 3.6 [duplicate]
  • Implementation of timeout in LDAP
  • Multiple canvases (pages) in Fabric.js
  • Pick Out Specific Number from Array? [duplicate]
  • Why do you need 2 Javascript files for cross-platform Cordova plugin?
  • SQL Server 2012 not showing unicode character in results
  • How to create subsets of a single set of elements with XSLT?
  • How to call jQuery function in HTML returned by AJAX