comtypes 1.4.5__zip → 1.4.7__zip
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {comtypes-1.4.5 → comtypes-1.4.7}/CHANGES.txt +30 -0
- {comtypes-1.4.5/comtypes.egg-info → comtypes-1.4.7}/PKG-INFO +28 -36
- {comtypes-1.4.5 → comtypes-1.4.7}/README.md +26 -34
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/GUID.py +24 -24
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/__init__.py +1 -1
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/_memberspec.py +4 -12
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/_post_coinit/bstr.py +13 -6
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/automation.py +21 -54
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/client/__init__.py +2 -9
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/client/_code_cache.py +2 -2
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/hints.pyi +8 -18
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/persist.py +19 -3
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/shelllink.py +72 -21
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/test/test_client.py +9 -0
- comtypes-1.4.7/comtypes/test/test_monikers.py +70 -0
- comtypes-1.4.7/comtypes/test/test_persist.py +40 -0
- comtypes-1.4.7/comtypes/test/test_recordinfo.py +79 -0
- comtypes-1.4.7/comtypes/test/test_shelllink.py +133 -0
- comtypes-1.4.7/comtypes/test/test_storage.py +127 -0
- comtypes-1.4.7/comtypes/test/test_typeannotator.py +127 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/tools/codegenerator/codegenerator.py +0 -1
- comtypes-1.4.7/comtypes/tools/codegenerator/modulenamer.py +23 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/tools/codegenerator/typeannotator.py +27 -22
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/tools/tlbparser.py +22 -24
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/tools/typedesc_base.py +2 -8
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/typeinfo.py +57 -56
- {comtypes-1.4.5 → comtypes-1.4.7/comtypes.egg-info}/PKG-INFO +28 -36
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes.egg-info/SOURCES.txt +7 -1
- {comtypes-1.4.5 → comtypes-1.4.7}/setup.cfg +1 -1
- comtypes-1.4.5/comtypes/tools/codegenerator/modulenamer.py +0 -24
- {comtypes-1.4.5 → comtypes-1.4.7}/LICENSE.txt +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/MANIFEST.in +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/_comobject.py +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/_idl_stuff.py +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/_meta.py +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/_npsupport.py +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/_post_coinit/__init__.py +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/_post_coinit/misc.py +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/_post_coinit/unknwn.py +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/_py_instance_method.py +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/_safearray.py +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/_tlib_version_checker.py +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/clear_cache.py +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/client/_constants.py +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/client/_events.py +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/client/_generate.py +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/client/dynamic.py +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/client/lazybind.py +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/connectionpoints.py +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/errorinfo.py +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/git.py +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/hresult.py +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/logutil.py +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/messageloop.py +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/patcher.py +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/safearray.py +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/server/__init__.py +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/server/automation.py +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/server/connectionpoints.py +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/server/inprocserver.py +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/server/localserver.py +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/server/register.py +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/server/w_getopt.py +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/stream.py +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/test/TestComServer.idl +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/test/TestComServer.py +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/test/TestComServer.tlb +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/test/TestDispServer.idl +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/test/TestDispServer.py +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/test/TestDispServer.tlb +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/test/__init__.py +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/test/find_memleak.py +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/test/mylib.idl +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/test/mylib.tlb +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/test/mytypelib.idl +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/test/runtests.py +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/test/setup.py +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/test/test_BSTR.py +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/test/test_DISPPARAMS.py +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/test/test_GUID.py +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/test/test_QueryService.py +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/test/test_agilent.py +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/test/test_avmc.py +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/test/test_basic.py +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/test/test_casesensitivity.py +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/test/test_clear_cache.py +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/test/test_client_dynamic.py +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/test/test_client_regenerate_modules.py +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/test/test_collections.py +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/test/test_comserver.py +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/test/test_createwrappers.py +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/test/test_dict.py +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/test/test_dispifc_records.py +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/test/test_dispifc_safearrays.py +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/test/test_dispinterface.py +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/test/test_dyndispatch.py +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/test/test_excel.py +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/test/test_findgendir.py +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/test/test_getactiveobj.py +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/test/test_ie.py +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/test/test_ienum.py +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/test/test_imfattributes.py +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/test/test_inout_args.py +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/test/test_jscript.js +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/test/test_midl_safearray_create.py +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/test/test_msscript.py +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/test/test_npsupport.py +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/test/test_outparam.py +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/test/test_propputref.py +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/test/test_pump_events.py +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/test/test_safearray.py +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/test/test_sapi.py +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/test/test_server.py +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/test/test_showevents.py +0 -0
- /comtypes-1.4.5/comtypes/test/test_istream.py → /comtypes-1.4.7/comtypes/test/test_stream.py +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/test/test_subinterface.py +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/test/test_typeinfo.py +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/test/test_urlhistory.py +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/test/test_variant.py +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/test/test_win32com_interop.py +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/test/test_wmi.py +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/test/test_word.py +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/test/urlhist.tlb +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/tools/__init__.py +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/tools/codegenerator/__init__.py +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/tools/codegenerator/helpers.py +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/tools/codegenerator/namespaces.py +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/tools/codegenerator/packing.py +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/tools/typedesc.py +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/util.py +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes/viewobject.py +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes.egg-info/dependency_links.txt +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes.egg-info/entry_points.txt +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/comtypes.egg-info/top_level.txt +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/pyproject.toml +0 -0
- {comtypes-1.4.5 → comtypes-1.4.7}/setup.py +0 -0
|
@@ -1,6 +1,36 @@
|
|
|
1
1
|
Comtypes CHANGELOG
|
|
2
2
|
==================
|
|
3
3
|
|
|
4
|
+
Release 1.4.7
|
|
5
|
+
--------------
|
|
6
|
+
* Improve ``_CArrayType`` alias import. By @junkmd.
|
|
7
|
+
* Rename ``_byref_type`` and ``_carg_obj`` to ``_CArgObject``. By @junkmd.
|
|
8
|
+
* Fix typos and make the wording more natural in ``README.md``. By @umarbutler.
|
|
9
|
+
* Modernize ``BSTR`` definition. By @junkmd.
|
|
10
|
+
* Modernize ``tagDEC`` definition. By @junkmd.
|
|
11
|
+
* Remove methods with mangling names in ``typeinfo``. By @junkmd.
|
|
12
|
+
* Rename ``test_istream`` to ``test_stream``. By @junkmd.
|
|
13
|
+
* Add ``test_msvidctl``. By @junkmd.
|
|
14
|
+
* Add ``test_storage``. By @junkmd.
|
|
15
|
+
* Add ``test_monikers``. By @junkmd.
|
|
16
|
+
* Add ``test_shelllink``. By @junkmd.
|
|
17
|
+
* Add ``test_persist``. By @junkmd.
|
|
18
|
+
* Modernize ``persist``. By @junkmd.
|
|
19
|
+
* Add type annotations to ``shelllink``. By @junkmd.
|
|
20
|
+
* Bump ``python_requires`` to ``>=3.8`` in ``setup.cfg``. By @junkmd.
|
|
21
|
+
|
|
22
|
+
Release 1.4.6
|
|
23
|
+
--------------
|
|
24
|
+
* Add tests and method annotations for ``IRecordInfo``. By @junkmd.
|
|
25
|
+
* Improve static typings in ``automation``. By @junkmd.
|
|
26
|
+
* Tidy up import part in some modules. By @junkmd.
|
|
27
|
+
* Refer to ``Any`` and ``Tuple`` from the ``hints`` stub instead of directly importing them in generated modules. By @junkmd.
|
|
28
|
+
* Modernize ``GUID.py``. By @junkmd.
|
|
29
|
+
* Improve ``codegenerator.modulenamer`` static typing. By @junkmd.
|
|
30
|
+
* Avoid using keywords in ``TYPE_CHECKING`` blocks. By @junkmd.
|
|
31
|
+
* Improve member defining parts of ``ParseInterface`` and ``ParseDispatch``. By @junkmd.
|
|
32
|
+
* Fix Annoying SyntaxWarning. By @v01d-gh.
|
|
33
|
+
|
|
4
34
|
Release 1.4.5
|
|
5
35
|
--------------
|
|
6
36
|
* Split ``__init__.py`` into some modules. By @junkmd.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: comtypes
|
|
3
|
-
Version: 1.4.
|
|
3
|
+
Version: 1.4.7
|
|
4
4
|
Summary: Pure Python COM package
|
|
5
5
|
Home-page: https://github.com/enthought/comtypes
|
|
6
6
|
Download-URL: https://github.com/enthought/comtypes/releases
|
|
@@ -13,7 +13,7 @@ Classifier: Operating System :: Microsoft :: Windows
|
|
|
13
13
|
Classifier: Programming Language :: Python
|
|
14
14
|
Classifier: Programming Language :: Python :: 3
|
|
15
15
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
16
|
-
Requires-Python: >=3.
|
|
16
|
+
Requires-Python: >=3.8
|
|
17
17
|
Description-Content-Type: text/markdown
|
|
18
18
|
License-File: LICENSE.txt
|
|
19
19
|
|
|
@@ -24,47 +24,40 @@ License-File: LICENSE.txt
|
|
|
24
24
|
[](https://github.com/enthought/comtypes/stargazers) [](https://github.com/enthought/comtypes/network/members)
|
|
25
25
|
[](https://tidelift.com/subscription/pkg/pypi-comtypes?utm_source=pypi-comtypes&utm_medium=readme)
|
|
26
26
|
|
|
27
|
-
## About
|
|
28
27
|
|
|
29
|
-
`comtypes` is a lightweight
|
|
28
|
+
`comtypes` is a lightweight pure Python [COM](https://learn.microsoft.com/en-us/windows/win32/com/component-object-model--com--portal) package based on the [`ctypes`](https://docs.python.org/library/ctypes.html) foreign function interface library.
|
|
30
29
|
|
|
31
|
-
`comtypes` allows to define, call, and implement custom and dispatch-based COM interfaces in pure
|
|
30
|
+
`comtypes` allows you to define, call, and implement custom and dispatch-based COM interfaces in pure Python.
|
|
32
31
|
|
|
33
|
-
|
|
32
|
+
`comtypes` requires Windows and Python 3.8 or later.
|
|
33
|
+
- Version [1.4.6](https://pypi.org/project/comtypes/1.4.6/) is the last version to support Python 3.7.
|
|
34
|
+
- Version [1.2.1](https://pypi.org/project/comtypes/1.2.1/) is the last version to support Python 2.7 and 3.3–3.6.
|
|
35
|
+
- `comtypes` does not work with Python 3.8.1 as reported in [GH-202](https://github.com/enthought/comtypes/issues/202). This bug has been fixed in Python >= 3.8.2.
|
|
36
|
+
- Certain `comtypes` functions may not work correctly in Python 3.8 and 3.9 as reported in [GH-212](https://github.com/enthought/comtypes/issues/212). This bug has been fixed in Python >= 3.10.10 and >= 3.11.2.
|
|
34
37
|
|
|
35
|
-
|
|
36
|
-
- [`comtypes==1.2.1`](https://pypi.org/project/comtypes/1.2.1/) is the last version supporting `Python` 2.7 and 3.3-3.6.
|
|
37
|
-
- In `Python` 3.7.6 and 3.8.1, `comtypes` would not work as reported in [GH-202](https://github.com/enthought/comtypes/issues/202).
|
|
38
|
-
This bug has been fixed in `Python` >= 3.7.7 and >= 3.8.2.
|
|
39
|
-
- In `Python` 3.8 and 3.9, some of `comtypes` functionalities may not work correctly as reported in [GH-212](https://github.com/enthought/comtypes/issues/212).
|
|
40
|
-
This bug has been fixed in `Python` >= 3.10.10 and >= 3.11.2.
|
|
41
|
-
|
|
42
|
-
## Where to get it
|
|
43
|
-
|
|
44
|
-
The source code is currently hosted on GitHub at:
|
|
45
|
-
https://github.com/enthought/comtypes
|
|
46
|
-
|
|
47
|
-
An installer for the latest released version is available at the [Python Package Index (PyPI)](https://pypi.org/project/comtypes).
|
|
38
|
+
## Installation
|
|
48
39
|
|
|
40
|
+
`comtypes` is available on [PyPI](https://pypi.org/project/comtypes) and can be installed with `pip`:
|
|
49
41
|
```sh
|
|
50
42
|
# PyPI
|
|
51
43
|
pip install comtypes
|
|
52
44
|
```
|
|
53
45
|
|
|
54
|
-
|
|
46
|
+
The source code is currently hosted [here](https://github.com/enthought/comtypes) on GitHub.
|
|
47
|
+
|
|
48
|
+
### Dependencies
|
|
55
49
|
|
|
56
|
-
`comtypes`
|
|
50
|
+
`comtypes` is a pure Python package — it has no additional required dependencies.
|
|
57
51
|
|
|
58
|
-
Optional
|
|
59
|
-
- to process arrays as `numpy`'s `ndarray
|
|
60
|
-
-
|
|
52
|
+
Optional functionalities can be enabled by installing:
|
|
53
|
+
- `numpy`, in order to process arrays as `numpy`'s `ndarray`.
|
|
54
|
+
- `mypy` or other static type checkers, in order to interpret type hints.
|
|
61
55
|
|
|
62
|
-
|
|
56
|
+
None of these packages, however, are required in order to run `comtypes`.
|
|
63
57
|
|
|
64
|
-
## Community
|
|
58
|
+
## Community
|
|
65
59
|
|
|
66
|
-
|
|
67
|
-
https://github.com/enthought/comtypes
|
|
60
|
+
The [GitHub repository](https://github.com/enthought/comtypes) is used for tracking issues, reporting bugs, and contributing to the codebase and documentation.
|
|
68
61
|
|
|
69
62
|
## For Enterprise
|
|
70
63
|
|
|
@@ -77,17 +70,17 @@ This project and the maintainers of thousands of other packages are working with
|
|
|
77
70
|
## Frequently Asked Questions
|
|
78
71
|
|
|
79
72
|
### Q: Why does this package not support platforms other than Windows?
|
|
80
|
-
**A:**
|
|
73
|
+
**A:** The [Microsoft Component Object Model (COM)](https://learn.microsoft.com/en-us/windows/win32/com/com-technical-overview) is a technology that is unique to Windows and is not supported on other platforms.
|
|
81
74
|
|
|
82
75
|
[The phrase _"COM is a platform-independent"_ in the MS documentation](https://learn.microsoft.com/en-us/windows/win32/com/component-object-model--com--portal) means that COM maintains compatibility across different versions of Windows, and does NOT imply that it is supported on Linux or Mac.
|
|
83
76
|
|
|
84
|
-
|
|
77
|
+
For as long as COM is not supported outside of Windows, there is no plan to port `comtypes` to other platforms.
|
|
85
78
|
|
|
86
79
|
### Q: Why does `cannot import name 'COMError' from '_ctypes'` error occur when using this package on platforms other than Windows?
|
|
87
|
-
**A:** The [`_ctypes`](https://github.com/python/cpython/blob/main/Modules/_ctypes/_ctypes.c) is part of the internal implementation of the [`ctypes`](https://github.com/python/cpython/blob/main/Lib/ctypes/) standard library that exists for Python on all platforms.
|
|
88
|
-
However, `COMError` and COM-related features are implemented
|
|
80
|
+
**A:** The [`_ctypes`](https://github.com/python/cpython/blob/main/Modules/_ctypes/_ctypes.c) is part of the internal implementation of the [`ctypes`](https://github.com/python/cpython/blob/main/Lib/ctypes/) standard library that exists for Python on all platforms.
|
|
81
|
+
However, `COMError` and COM-related features are only implemented in Python for Windows.
|
|
89
82
|
|
|
90
|
-
In cross-platform software development, care must be taken to ensure that
|
|
83
|
+
In cross-platform software development, care must be taken to ensure that codebases that depend on `comtypes` do not execute in environments other than Windows.
|
|
91
84
|
|
|
92
85
|
### Q: Despite a script that depends on `comtypes` having run successfully before, a error (`ImportError`, `NameError`, or `SyntaxError`) is raised now, and the same error occurs again and again.
|
|
93
86
|
|
|
@@ -102,7 +95,6 @@ After deleting these partial modules and running the script again, `comtypes.cli
|
|
|
102
95
|
|
|
103
96
|
However, if the script implementation does not use `comtypes.client.GetModule` or processes generated files, it may not be a solution.
|
|
104
97
|
|
|
105
|
-
## Documentation
|
|
98
|
+
## Documentation
|
|
106
99
|
|
|
107
|
-
The documentation is currently hosted on
|
|
108
|
-
https://pythonhosted.org/comtypes
|
|
100
|
+
The documentation is currently hosted [here](https://pythonhosted.org/comtypes) on PythonHosted.
|
|
@@ -5,47 +5,40 @@
|
|
|
5
5
|
[](https://github.com/enthought/comtypes/stargazers) [](https://github.com/enthought/comtypes/network/members)
|
|
6
6
|
[](https://tidelift.com/subscription/pkg/pypi-comtypes?utm_source=pypi-comtypes&utm_medium=readme)
|
|
7
7
|
|
|
8
|
-
## About
|
|
9
8
|
|
|
10
|
-
`comtypes` is a lightweight
|
|
9
|
+
`comtypes` is a lightweight pure Python [COM](https://learn.microsoft.com/en-us/windows/win32/com/component-object-model--com--portal) package based on the [`ctypes`](https://docs.python.org/library/ctypes.html) foreign function interface library.
|
|
11
10
|
|
|
12
|
-
`comtypes` allows to define, call, and implement custom and dispatch-based COM interfaces in pure
|
|
11
|
+
`comtypes` allows you to define, call, and implement custom and dispatch-based COM interfaces in pure Python.
|
|
13
12
|
|
|
14
|
-
|
|
13
|
+
`comtypes` requires Windows and Python 3.8 or later.
|
|
14
|
+
- Version [1.4.6](https://pypi.org/project/comtypes/1.4.6/) is the last version to support Python 3.7.
|
|
15
|
+
- Version [1.2.1](https://pypi.org/project/comtypes/1.2.1/) is the last version to support Python 2.7 and 3.3–3.6.
|
|
16
|
+
- `comtypes` does not work with Python 3.8.1 as reported in [GH-202](https://github.com/enthought/comtypes/issues/202). This bug has been fixed in Python >= 3.8.2.
|
|
17
|
+
- Certain `comtypes` functions may not work correctly in Python 3.8 and 3.9 as reported in [GH-212](https://github.com/enthought/comtypes/issues/212). This bug has been fixed in Python >= 3.10.10 and >= 3.11.2.
|
|
15
18
|
|
|
16
|
-
|
|
17
|
-
- [`comtypes==1.2.1`](https://pypi.org/project/comtypes/1.2.1/) is the last version supporting `Python` 2.7 and 3.3-3.6.
|
|
18
|
-
- In `Python` 3.7.6 and 3.8.1, `comtypes` would not work as reported in [GH-202](https://github.com/enthought/comtypes/issues/202).
|
|
19
|
-
This bug has been fixed in `Python` >= 3.7.7 and >= 3.8.2.
|
|
20
|
-
- In `Python` 3.8 and 3.9, some of `comtypes` functionalities may not work correctly as reported in [GH-212](https://github.com/enthought/comtypes/issues/212).
|
|
21
|
-
This bug has been fixed in `Python` >= 3.10.10 and >= 3.11.2.
|
|
22
|
-
|
|
23
|
-
## Where to get it
|
|
24
|
-
|
|
25
|
-
The source code is currently hosted on GitHub at:
|
|
26
|
-
https://github.com/enthought/comtypes
|
|
27
|
-
|
|
28
|
-
An installer for the latest released version is available at the [Python Package Index (PyPI)](https://pypi.org/project/comtypes).
|
|
19
|
+
## Installation
|
|
29
20
|
|
|
21
|
+
`comtypes` is available on [PyPI](https://pypi.org/project/comtypes) and can be installed with `pip`:
|
|
30
22
|
```sh
|
|
31
23
|
# PyPI
|
|
32
24
|
pip install comtypes
|
|
33
25
|
```
|
|
34
26
|
|
|
35
|
-
|
|
27
|
+
The source code is currently hosted [here](https://github.com/enthought/comtypes) on GitHub.
|
|
28
|
+
|
|
29
|
+
### Dependencies
|
|
36
30
|
|
|
37
|
-
`comtypes`
|
|
31
|
+
`comtypes` is a pure Python package — it has no additional required dependencies.
|
|
38
32
|
|
|
39
|
-
Optional
|
|
40
|
-
- to process arrays as `numpy`'s `ndarray
|
|
41
|
-
-
|
|
33
|
+
Optional functionalities can be enabled by installing:
|
|
34
|
+
- `numpy`, in order to process arrays as `numpy`'s `ndarray`.
|
|
35
|
+
- `mypy` or other static type checkers, in order to interpret type hints.
|
|
42
36
|
|
|
43
|
-
|
|
37
|
+
None of these packages, however, are required in order to run `comtypes`.
|
|
44
38
|
|
|
45
|
-
## Community
|
|
39
|
+
## Community
|
|
46
40
|
|
|
47
|
-
|
|
48
|
-
https://github.com/enthought/comtypes
|
|
41
|
+
The [GitHub repository](https://github.com/enthought/comtypes) is used for tracking issues, reporting bugs, and contributing to the codebase and documentation.
|
|
49
42
|
|
|
50
43
|
## For Enterprise
|
|
51
44
|
|
|
@@ -58,17 +51,17 @@ This project and the maintainers of thousands of other packages are working with
|
|
|
58
51
|
## Frequently Asked Questions
|
|
59
52
|
|
|
60
53
|
### Q: Why does this package not support platforms other than Windows?
|
|
61
|
-
**A:**
|
|
54
|
+
**A:** The [Microsoft Component Object Model (COM)](https://learn.microsoft.com/en-us/windows/win32/com/com-technical-overview) is a technology that is unique to Windows and is not supported on other platforms.
|
|
62
55
|
|
|
63
56
|
[The phrase _"COM is a platform-independent"_ in the MS documentation](https://learn.microsoft.com/en-us/windows/win32/com/component-object-model--com--portal) means that COM maintains compatibility across different versions of Windows, and does NOT imply that it is supported on Linux or Mac.
|
|
64
57
|
|
|
65
|
-
|
|
58
|
+
For as long as COM is not supported outside of Windows, there is no plan to port `comtypes` to other platforms.
|
|
66
59
|
|
|
67
60
|
### Q: Why does `cannot import name 'COMError' from '_ctypes'` error occur when using this package on platforms other than Windows?
|
|
68
|
-
**A:** The [`_ctypes`](https://github.com/python/cpython/blob/main/Modules/_ctypes/_ctypes.c) is part of the internal implementation of the [`ctypes`](https://github.com/python/cpython/blob/main/Lib/ctypes/) standard library that exists for Python on all platforms.
|
|
69
|
-
However, `COMError` and COM-related features are implemented
|
|
61
|
+
**A:** The [`_ctypes`](https://github.com/python/cpython/blob/main/Modules/_ctypes/_ctypes.c) is part of the internal implementation of the [`ctypes`](https://github.com/python/cpython/blob/main/Lib/ctypes/) standard library that exists for Python on all platforms.
|
|
62
|
+
However, `COMError` and COM-related features are only implemented in Python for Windows.
|
|
70
63
|
|
|
71
|
-
In cross-platform software development, care must be taken to ensure that
|
|
64
|
+
In cross-platform software development, care must be taken to ensure that codebases that depend on `comtypes` do not execute in environments other than Windows.
|
|
72
65
|
|
|
73
66
|
### Q: Despite a script that depends on `comtypes` having run successfully before, a error (`ImportError`, `NameError`, or `SyntaxError`) is raised now, and the same error occurs again and again.
|
|
74
67
|
|
|
@@ -83,7 +76,6 @@ After deleting these partial modules and running the script again, `comtypes.cli
|
|
|
83
76
|
|
|
84
77
|
However, if the script implementation does not use `comtypes.client.GetModule` or processes generated files, it may not be a solution.
|
|
85
78
|
|
|
86
|
-
## Documentation
|
|
79
|
+
## Documentation
|
|
87
80
|
|
|
88
|
-
The documentation is currently hosted on
|
|
89
|
-
https://pythonhosted.org/comtypes
|
|
81
|
+
The documentation is currently hosted [here](https://pythonhosted.org/comtypes) on PythonHosted.
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
from ctypes import
|
|
2
|
-
import
|
|
1
|
+
from ctypes import oledll, windll
|
|
2
|
+
from ctypes import byref, c_byte, c_ushort, c_ulong, c_wchar_p, Structure
|
|
3
|
+
from typing import Any, TYPE_CHECKING
|
|
3
4
|
|
|
5
|
+
if TYPE_CHECKING:
|
|
6
|
+
from comtypes import hints # type: ignore
|
|
4
7
|
|
|
5
|
-
|
|
8
|
+
|
|
9
|
+
def binary(obj: "GUID") -> bytes:
|
|
6
10
|
return bytes(obj)
|
|
7
11
|
|
|
8
12
|
|
|
@@ -31,37 +35,32 @@ class GUID(Structure):
|
|
|
31
35
|
_CLSIDFromString(str(name), byref(self))
|
|
32
36
|
|
|
33
37
|
def __repr__(self):
|
|
34
|
-
return 'GUID("
|
|
38
|
+
return f'GUID("{str(self)}")'
|
|
35
39
|
|
|
36
|
-
def
|
|
40
|
+
def __str__(self) -> str:
|
|
37
41
|
p = c_wchar_p()
|
|
38
42
|
_StringFromCLSID(byref(self), byref(p))
|
|
39
43
|
result = p.value
|
|
40
44
|
_CoTaskMemFree(p)
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
def __cmp__(self, other):
|
|
46
|
-
if isinstance(other, GUID):
|
|
47
|
-
return cmp(binary(self), binary(other))
|
|
48
|
-
return -1
|
|
45
|
+
# stringified `GUID_null` would be '{00000000-0000-0000-0000-000000000000}'
|
|
46
|
+
# Should we do `assert result is not None`?
|
|
47
|
+
return result # type: ignore
|
|
49
48
|
|
|
50
|
-
def __bool__(self):
|
|
49
|
+
def __bool__(self) -> bool:
|
|
51
50
|
return self != GUID_null
|
|
52
51
|
|
|
53
|
-
def __eq__(self, other):
|
|
52
|
+
def __eq__(self, other) -> bool:
|
|
54
53
|
return isinstance(other, GUID) and binary(self) == binary(other)
|
|
55
54
|
|
|
56
|
-
def __hash__(self):
|
|
55
|
+
def __hash__(self) -> int:
|
|
57
56
|
# We make GUID instances hashable, although they are mutable.
|
|
58
57
|
return hash(binary(self))
|
|
59
58
|
|
|
60
|
-
def copy(self):
|
|
59
|
+
def copy(self) -> "GUID":
|
|
61
60
|
return GUID(str(self))
|
|
62
61
|
|
|
63
62
|
@classmethod
|
|
64
|
-
def from_progid(cls, progid):
|
|
63
|
+
def from_progid(cls, progid: Any) -> "hints.Self":
|
|
65
64
|
"""Get guid from progid, ..."""
|
|
66
65
|
if hasattr(progid, "_reg_clsid_"):
|
|
67
66
|
progid = progid._reg_clsid_
|
|
@@ -74,19 +73,20 @@ class GUID(Structure):
|
|
|
74
73
|
_CLSIDFromProgID(str(progid), byref(inst))
|
|
75
74
|
return inst
|
|
76
75
|
else:
|
|
77
|
-
raise TypeError("Cannot construct guid from
|
|
76
|
+
raise TypeError(f"Cannot construct guid from {progid!r}")
|
|
78
77
|
|
|
79
|
-
def as_progid(self):
|
|
80
|
-
"Convert a GUID into a progid"
|
|
78
|
+
def as_progid(self) -> str:
|
|
79
|
+
"""Convert a GUID into a progid"""
|
|
81
80
|
progid = c_wchar_p()
|
|
82
81
|
_ProgIDFromCLSID(byref(self), byref(progid))
|
|
83
82
|
result = progid.value
|
|
84
83
|
_CoTaskMemFree(progid)
|
|
85
|
-
|
|
84
|
+
# Should we do `assert result is not None`?
|
|
85
|
+
return result # type: ignore
|
|
86
86
|
|
|
87
87
|
@classmethod
|
|
88
|
-
def create_new(cls):
|
|
89
|
-
"Create a brand new guid"
|
|
88
|
+
def create_new(cls) -> "hints.Self":
|
|
89
|
+
"""Create a brand new guid"""
|
|
90
90
|
guid = cls()
|
|
91
91
|
_CoCreateGuid(byref(guid))
|
|
92
92
|
return guid
|
|
@@ -1,16 +1,8 @@
|
|
|
1
1
|
import ctypes
|
|
2
|
-
from typing import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
Iterator,
|
|
7
|
-
List,
|
|
8
|
-
NamedTuple,
|
|
9
|
-
Optional,
|
|
10
|
-
Tuple,
|
|
11
|
-
Type,
|
|
12
|
-
Union as _UnionT,
|
|
13
|
-
)
|
|
2
|
+
from typing import Any, NamedTuple
|
|
3
|
+
from typing import Dict, List, Tuple, Type
|
|
4
|
+
from typing import Optional, Union as _UnionT
|
|
5
|
+
from typing import Callable, Iterator
|
|
14
6
|
|
|
15
7
|
from comtypes import _CData
|
|
16
8
|
import comtypes
|
|
@@ -1,26 +1,33 @@
|
|
|
1
1
|
from ctypes import _SimpleCData, windll
|
|
2
|
+
from typing import Any, Callable, TYPE_CHECKING
|
|
3
|
+
|
|
4
|
+
if TYPE_CHECKING:
|
|
5
|
+
from comtypes import hints # type: ignore
|
|
2
6
|
|
|
3
7
|
|
|
4
8
|
class BSTR(_SimpleCData):
|
|
5
|
-
"The windows BSTR data type"
|
|
9
|
+
"""The windows BSTR data type"""
|
|
10
|
+
|
|
6
11
|
_type_ = "X"
|
|
7
12
|
_needsfree = False
|
|
8
13
|
|
|
9
|
-
def __repr__(self):
|
|
10
|
-
return "
|
|
14
|
+
def __repr__(self) -> str:
|
|
15
|
+
return f"{self.__class__.__name__}({self.value!r})"
|
|
11
16
|
|
|
12
|
-
def __ctypes_from_outparam__(self):
|
|
17
|
+
def __ctypes_from_outparam__(self) -> Any:
|
|
13
18
|
self._needsfree = True
|
|
14
19
|
return self.value
|
|
15
20
|
|
|
16
|
-
def __del__(
|
|
21
|
+
def __del__(
|
|
22
|
+
self, _free: Callable[["BSTR"], Any] = windll.oleaut32.SysFreeString
|
|
23
|
+
) -> None:
|
|
17
24
|
# Free the string if self owns the memory
|
|
18
25
|
# or if instructed by __ctypes_from_outparam__.
|
|
19
26
|
if self._b_base_ is None or self._needsfree:
|
|
20
27
|
_free(self)
|
|
21
28
|
|
|
22
29
|
@classmethod
|
|
23
|
-
def from_param(cls, value):
|
|
30
|
+
def from_param(cls, value: Any) -> "hints.Self":
|
|
24
31
|
"""Convert into a foreign function call parameter."""
|
|
25
32
|
if isinstance(value, cls):
|
|
26
33
|
return value
|
|
@@ -4,30 +4,23 @@ import datetime
|
|
|
4
4
|
import decimal
|
|
5
5
|
import sys
|
|
6
6
|
from ctypes import *
|
|
7
|
-
from ctypes import _Pointer
|
|
7
|
+
from ctypes import _Pointer, Array as _CArrayType
|
|
8
8
|
from _ctypes import CopyComPointer
|
|
9
9
|
from ctypes.wintypes import DWORD, LONG, UINT, VARIANT_BOOL, WCHAR, WORD
|
|
10
|
-
from typing import
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
ClassVar,
|
|
14
|
-
List,
|
|
15
|
-
Optional,
|
|
16
|
-
TYPE_CHECKING,
|
|
17
|
-
Tuple,
|
|
18
|
-
Union as _UnionT,
|
|
19
|
-
)
|
|
20
|
-
|
|
21
|
-
from comtypes import BSTR, COMError, COMMETHOD, GUID, IID, IUnknown, STDMETHOD
|
|
10
|
+
from typing import Any, ClassVar, Dict, List, Optional, TYPE_CHECKING, Type
|
|
11
|
+
|
|
12
|
+
from comtypes import _CData, BSTR, COMError, COMMETHOD, GUID, IID, IUnknown, STDMETHOD
|
|
22
13
|
from comtypes.hresult import *
|
|
23
14
|
from comtypes._memberspec import _DispMemberSpec
|
|
24
15
|
import comtypes.patcher
|
|
25
16
|
import comtypes
|
|
26
17
|
|
|
27
18
|
if TYPE_CHECKING:
|
|
19
|
+
from ctypes import _CArgObject
|
|
28
20
|
from comtypes import hints # type: ignore
|
|
29
21
|
from comtypes import _safearray
|
|
30
22
|
else:
|
|
23
|
+
_CArgObject = type(byref(c_int()))
|
|
31
24
|
try:
|
|
32
25
|
from comtypes import _safearray
|
|
33
26
|
except (ImportError, AttributeError):
|
|
@@ -59,7 +52,6 @@ INVOKEKIND = tagINVOKEKIND
|
|
|
59
52
|
# helpers
|
|
60
53
|
IID_NULL = GUID()
|
|
61
54
|
riid_null = byref(IID_NULL)
|
|
62
|
-
_byref_type = type(byref(c_int()))
|
|
63
55
|
|
|
64
56
|
# 30. December 1899, midnight. For VT_DATE.
|
|
65
57
|
_com_null_date = datetime.datetime(1899, 12, 30, 0, 0, 0)
|
|
@@ -138,7 +130,7 @@ class tagDEC(Structure):
|
|
|
138
130
|
("Lo64", c_ulonglong),
|
|
139
131
|
]
|
|
140
132
|
|
|
141
|
-
def as_decimal(self):
|
|
133
|
+
def as_decimal(self) -> decimal.Decimal:
|
|
142
134
|
"""Convert a tagDEC struct to Decimal.
|
|
143
135
|
|
|
144
136
|
See http://msdn.microsoft.com/en-us/library/cc234586.aspx for the tagDEC
|
|
@@ -146,12 +138,8 @@ class tagDEC(Structure):
|
|
|
146
138
|
|
|
147
139
|
"""
|
|
148
140
|
digits = (self.Hi32 << 64) + self.Lo64
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
digits,
|
|
152
|
-
self.scale,
|
|
153
|
-
)
|
|
154
|
-
return decimal.Decimal(decimal_str)
|
|
141
|
+
sign = "-" if self.sign else ""
|
|
142
|
+
return decimal.Decimal(f"{sign}{digits}e-{self.scale}")
|
|
155
143
|
|
|
156
144
|
|
|
157
145
|
DECIMAL = tagDEC
|
|
@@ -391,7 +379,7 @@ class tagVARIANT(Structure):
|
|
|
391
379
|
elif isinstance(value, c_uint64):
|
|
392
380
|
self.vt = VT_UI8
|
|
393
381
|
self._.VT_UI8 = value
|
|
394
|
-
elif isinstance(value,
|
|
382
|
+
elif isinstance(value, _CArgObject):
|
|
395
383
|
ref = value._obj
|
|
396
384
|
self._.c_void_p = addressof(ref)
|
|
397
385
|
self.__keepref = value
|
|
@@ -618,9 +606,6 @@ v.vt = VT_ERROR
|
|
|
618
606
|
v._.VT_I4 = 0x80020004
|
|
619
607
|
del v
|
|
620
608
|
|
|
621
|
-
_carg_obj = type(byref(c_int()))
|
|
622
|
-
from ctypes import Array as _CArrayType
|
|
623
|
-
|
|
624
609
|
|
|
625
610
|
@comtypes.patcher.Patch(POINTER(VARIANT))
|
|
626
611
|
class _(object):
|
|
@@ -635,7 +620,7 @@ class _(object):
|
|
|
635
620
|
if isinstance(arg, POINTER(VARIANT)):
|
|
636
621
|
return arg
|
|
637
622
|
# accept byref(VARIANT) instance
|
|
638
|
-
if isinstance(arg,
|
|
623
|
+
if isinstance(arg, _CArgObject) and isinstance(arg._obj, VARIANT):
|
|
639
624
|
return arg
|
|
640
625
|
# accept VARIANT instance
|
|
641
626
|
if isinstance(arg, VARIANT):
|
|
@@ -649,7 +634,7 @@ class _(object):
|
|
|
649
634
|
def __setitem__(self, index, value):
|
|
650
635
|
# This is to support the same sematics as a pointer instance:
|
|
651
636
|
# variant[0] = value
|
|
652
|
-
self[index].value = value
|
|
637
|
+
self[index].value = value # type: ignore
|
|
653
638
|
|
|
654
639
|
|
|
655
640
|
################################################################
|
|
@@ -759,7 +744,7 @@ EXCEPINFO = tagEXCEPINFO
|
|
|
759
744
|
|
|
760
745
|
class tagDISPPARAMS(Structure):
|
|
761
746
|
if TYPE_CHECKING:
|
|
762
|
-
rgvarg:
|
|
747
|
+
rgvarg: _CArrayType[VARIANT]
|
|
763
748
|
rgdispidNamedArgs: _Pointer[DISPID]
|
|
764
749
|
cArgs: int
|
|
765
750
|
cNamedArgs: int
|
|
@@ -789,28 +774,8 @@ DISPID_DESTRUCTOR = -7
|
|
|
789
774
|
DISPID_COLLECT = -8
|
|
790
775
|
|
|
791
776
|
|
|
792
|
-
RawGetIDsOfNamesFunc = Callable[
|
|
793
|
-
[_byref_type, "Array[c_wchar_p]", int, int, "Array[DISPID]"], int
|
|
794
|
-
]
|
|
795
|
-
# fmt: off
|
|
796
|
-
RawInvokeFunc = Callable[
|
|
797
|
-
[
|
|
798
|
-
int, _byref_type, int, int, # dispIdMember, riid, lcid, wFlags
|
|
799
|
-
_UnionT[_byref_type, DISPPARAMS], # *pDispParams
|
|
800
|
-
_UnionT[_byref_type, VARIANT], # pVarResult
|
|
801
|
-
_UnionT[_byref_type, EXCEPINFO, None], # pExcepInfo
|
|
802
|
-
_UnionT[_byref_type, c_uint], # puArgErr
|
|
803
|
-
],
|
|
804
|
-
int,
|
|
805
|
-
]
|
|
806
|
-
# fmt: on
|
|
807
|
-
|
|
808
|
-
|
|
809
777
|
class IDispatch(IUnknown):
|
|
810
778
|
_disp_methods_: ClassVar[List[_DispMemberSpec]]
|
|
811
|
-
_GetTypeInfo: Callable[[int, int], IUnknown]
|
|
812
|
-
__com_GetIDsOfNames: RawGetIDsOfNamesFunc
|
|
813
|
-
__com_Invoke: RawInvokeFunc
|
|
814
779
|
|
|
815
780
|
_iid_ = GUID("{00020400-0000-0000-C000-000000000046}")
|
|
816
781
|
_methods_ = [
|
|
@@ -851,7 +816,7 @@ class IDispatch(IUnknown):
|
|
|
851
816
|
"""Return type information. Index 0 specifies typeinfo for IDispatch"""
|
|
852
817
|
import comtypes.typeinfo
|
|
853
818
|
|
|
854
|
-
result = self._GetTypeInfo(index, lcid)
|
|
819
|
+
result = self._GetTypeInfo(index, lcid) # type: ignore
|
|
855
820
|
return result.QueryInterface(comtypes.typeinfo.ITypeInfo)
|
|
856
821
|
|
|
857
822
|
def GetIDsOfNames(self, *names: str, **kw: Any) -> List[int]:
|
|
@@ -860,7 +825,7 @@ class IDispatch(IUnknown):
|
|
|
860
825
|
assert not kw
|
|
861
826
|
arr = (c_wchar_p * len(names))(*names)
|
|
862
827
|
ids = (DISPID * len(names))()
|
|
863
|
-
self.__com_GetIDsOfNames(riid_null, arr, len(names), lcid, ids)
|
|
828
|
+
self.__com_GetIDsOfNames(riid_null, arr, len(names), lcid, ids) # type: ignore
|
|
864
829
|
return ids[:]
|
|
865
830
|
|
|
866
831
|
def _invoke(self, memid: int, invkind: int, lcid: int, *args: Any) -> Any:
|
|
@@ -880,7 +845,9 @@ class IDispatch(IUnknown):
|
|
|
880
845
|
dp.rgdispidNamedArgs = pointer(DISPID(DISPID_PROPERTYPUT))
|
|
881
846
|
dp.rgvarg = array
|
|
882
847
|
|
|
883
|
-
self.__com_Invoke(
|
|
848
|
+
self.__com_Invoke( # type: ignore
|
|
849
|
+
memid, riid_null, lcid, invkind, dp, var, None, argerr
|
|
850
|
+
)
|
|
884
851
|
return var._get_value(dynamic=True)
|
|
885
852
|
|
|
886
853
|
def __make_dp(self, _invkind: int, *args: Any) -> DISPPARAMS:
|
|
@@ -916,7 +883,7 @@ class IDispatch(IUnknown):
|
|
|
916
883
|
excepinfo = EXCEPINFO()
|
|
917
884
|
argerr = c_uint()
|
|
918
885
|
try:
|
|
919
|
-
self.__com_Invoke(
|
|
886
|
+
self.__com_Invoke( # type: ignore
|
|
920
887
|
dispid,
|
|
921
888
|
riid_null,
|
|
922
889
|
_lcid,
|
|
@@ -980,7 +947,7 @@ _arraycode_to_vartype = {
|
|
|
980
947
|
"B": VT_UI1,
|
|
981
948
|
}
|
|
982
949
|
|
|
983
|
-
_ctype_to_vartype = {
|
|
950
|
+
_ctype_to_vartype: Dict[Type[_CData], int] = {
|
|
984
951
|
c_byte: VT_I1,
|
|
985
952
|
c_ubyte: VT_UI1,
|
|
986
953
|
c_short: VT_I2,
|
|
@@ -1016,7 +983,7 @@ _ctype_to_vartype = {
|
|
|
1016
983
|
# POINTER(IDispatch): VT_DISPATCH,
|
|
1017
984
|
}
|
|
1018
985
|
|
|
1019
|
-
_vartype_to_ctype = {}
|
|
986
|
+
_vartype_to_ctype: Dict[int, Type[_CData]] = {}
|
|
1020
987
|
for c, v in _ctype_to_vartype.items():
|
|
1021
988
|
_vartype_to_ctype[v] = c
|
|
1022
989
|
_vartype_to_ctype[VT_INT] = _vartype_to_ctype[VT_I4]
|
|
@@ -12,15 +12,8 @@ import ctypes
|
|
|
12
12
|
import logging
|
|
13
13
|
import os
|
|
14
14
|
import sys
|
|
15
|
-
from typing import
|
|
16
|
-
|
|
17
|
-
Optional,
|
|
18
|
-
overload,
|
|
19
|
-
Type,
|
|
20
|
-
TYPE_CHECKING,
|
|
21
|
-
TypeVar,
|
|
22
|
-
Union as _UnionT,
|
|
23
|
-
)
|
|
15
|
+
from typing import Any, overload, TypeVar, TYPE_CHECKING
|
|
16
|
+
from typing import Optional, Type, Union as _UnionT
|
|
24
17
|
|
|
25
18
|
import comtypes
|
|
26
19
|
from comtypes.hresult import *
|
|
@@ -34,10 +34,10 @@ def _find_gen_dir():
|
|
|
34
34
|
appended to comtypes.gen.__path__ .
|
|
35
35
|
|
|
36
36
|
For a Python script using comtypes, the additional directory is
|
|
37
|
-
'%APPDATA
|
|
37
|
+
'%APPDATA%\\<username>\\Python\\Python25\\comtypes_cache'.
|
|
38
38
|
|
|
39
39
|
For an executable frozen with py2exe, the additional directory is
|
|
40
|
-
'%TEMP
|
|
40
|
+
'%TEMP%\\comtypes_cache\\<imagebasename>-25'.
|
|
41
41
|
"""
|
|
42
42
|
_create_comtypes_gen_package()
|
|
43
43
|
from comtypes import gen
|