comtypes 1.4.4__zip → 1.4.5__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.4 → comtypes-1.4.5}/CHANGES.txt +12 -0
- {comtypes-1.4.4/comtypes.egg-info → comtypes-1.4.5}/PKG-INFO +1 -1
- comtypes-1.4.5/comtypes/__init__.py +268 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/_comobject.py +2 -1
- comtypes-1.4.5/comtypes/_idl_stuff.py +67 -0
- comtypes-1.4.5/comtypes/_post_coinit/__init__.py +15 -0
- comtypes-1.4.5/comtypes/_post_coinit/bstr.py +30 -0
- comtypes-1.4.5/comtypes/_post_coinit/misc.py +385 -0
- comtypes-1.4.5/comtypes/_post_coinit/unknwn.py +537 -0
- comtypes-1.4.5/comtypes/_py_instance_method.py +13 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/_safearray.py +3 -2
- comtypes-1.4.5/comtypes/_tlib_version_checker.py +18 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/automation.py +22 -6
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/client/_generate.py +2 -1
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/hints.pyi +34 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/safearray.py +11 -4
- comtypes-1.4.5/comtypes/stream.py +65 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/test/test_client.py +11 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/test/test_dispifc_records.py +1 -1
- comtypes-1.4.5/comtypes/test/test_dispifc_safearrays.py +89 -0
- comtypes-1.4.5/comtypes/test/test_istream.py +53 -0
- comtypes-1.4.5/comtypes/test/test_midl_safearray_create.py +100 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/test/test_wmi.py +11 -18
- {comtypes-1.4.4 → comtypes-1.4.5/comtypes.egg-info}/PKG-INFO +1 -1
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes.egg-info/SOURCES.txt +11 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/setup.cfg +1 -0
- comtypes-1.4.4/comtypes/__init__.py +0 -1229
- {comtypes-1.4.4 → comtypes-1.4.5}/LICENSE.txt +0 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/MANIFEST.in +0 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/README.md +0 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/GUID.py +0 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/_memberspec.py +0 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/_meta.py +0 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/_npsupport.py +0 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/clear_cache.py +0 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/client/__init__.py +0 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/client/_code_cache.py +0 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/client/_constants.py +0 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/client/_events.py +0 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/client/dynamic.py +0 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/client/lazybind.py +0 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/connectionpoints.py +0 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/errorinfo.py +0 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/git.py +0 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/hresult.py +0 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/logutil.py +0 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/messageloop.py +0 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/patcher.py +0 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/persist.py +0 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/server/__init__.py +0 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/server/automation.py +0 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/server/connectionpoints.py +0 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/server/inprocserver.py +0 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/server/localserver.py +0 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/server/register.py +0 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/server/w_getopt.py +0 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/shelllink.py +0 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/test/TestComServer.idl +0 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/test/TestComServer.py +0 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/test/TestComServer.tlb +0 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/test/TestDispServer.idl +0 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/test/TestDispServer.py +0 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/test/TestDispServer.tlb +0 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/test/__init__.py +0 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/test/find_memleak.py +0 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/test/mylib.idl +0 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/test/mylib.tlb +0 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/test/mytypelib.idl +0 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/test/runtests.py +0 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/test/setup.py +0 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/test/test_BSTR.py +0 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/test/test_DISPPARAMS.py +0 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/test/test_GUID.py +0 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/test/test_QueryService.py +0 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/test/test_agilent.py +0 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/test/test_avmc.py +0 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/test/test_basic.py +0 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/test/test_casesensitivity.py +0 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/test/test_clear_cache.py +0 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/test/test_client_dynamic.py +0 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/test/test_client_regenerate_modules.py +0 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/test/test_collections.py +0 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/test/test_comserver.py +0 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/test/test_createwrappers.py +0 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/test/test_dict.py +0 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/test/test_dispinterface.py +0 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/test/test_dyndispatch.py +0 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/test/test_excel.py +0 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/test/test_findgendir.py +0 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/test/test_getactiveobj.py +0 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/test/test_ie.py +0 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/test/test_ienum.py +0 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/test/test_imfattributes.py +0 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/test/test_inout_args.py +0 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/test/test_jscript.js +0 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/test/test_msscript.py +0 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/test/test_npsupport.py +0 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/test/test_outparam.py +0 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/test/test_propputref.py +0 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/test/test_pump_events.py +0 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/test/test_safearray.py +0 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/test/test_sapi.py +0 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/test/test_server.py +0 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/test/test_showevents.py +0 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/test/test_subinterface.py +0 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/test/test_typeinfo.py +0 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/test/test_urlhistory.py +0 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/test/test_variant.py +0 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/test/test_win32com_interop.py +0 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/test/test_word.py +0 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/test/urlhist.tlb +0 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/tools/__init__.py +0 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/tools/codegenerator/__init__.py +0 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/tools/codegenerator/codegenerator.py +0 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/tools/codegenerator/helpers.py +0 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/tools/codegenerator/modulenamer.py +0 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/tools/codegenerator/namespaces.py +0 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/tools/codegenerator/packing.py +0 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/tools/codegenerator/typeannotator.py +0 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/tools/tlbparser.py +0 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/tools/typedesc.py +0 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/tools/typedesc_base.py +0 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/typeinfo.py +0 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/util.py +0 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes/viewobject.py +0 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes.egg-info/dependency_links.txt +0 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes.egg-info/entry_points.txt +0 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/comtypes.egg-info/top_level.txt +0 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/pyproject.toml +0 -0
- {comtypes-1.4.4 → comtypes-1.4.5}/setup.py +0 -0
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
Comtypes CHANGELOG
|
|
2
2
|
==================
|
|
3
3
|
|
|
4
|
+
Release 1.4.5
|
|
5
|
+
--------------
|
|
6
|
+
* Split ``__init__.py`` into some modules. By @junkmd.
|
|
7
|
+
* Fix importing ``_DispMemberSpec`` in ``automation``. By @junkmd.
|
|
8
|
+
* Fix importing ``_encode_idl`` in ``_comobject``. By @junkmd.
|
|
9
|
+
* Change the name of the component that implements the interface for record parameter testing. By @geppi.
|
|
10
|
+
* Implement ``SAFEARRAY`` pointers and ``SAFEARRAY``s as method parameters of a Dispatch Interface. By @geppi.
|
|
11
|
+
* Change the default value of the ``extra`` parameter in the ``create`` method of ``tagSAFEARRAY`` subtypes. By @geppi.
|
|
12
|
+
* Implement static import for ``ISequentialStream``. By @jonschz.
|
|
13
|
+
* Modernize ``test_wmi``. By @junkmd.
|
|
14
|
+
* Add static typing for ``_midlSAFEARRAY``. By @junkmd.
|
|
15
|
+
|
|
4
16
|
Release 1.4.4
|
|
5
17
|
--------------
|
|
6
18
|
* Stop mentioning the last version supporting Windows CE in ``README.md``. By @forderud.
|
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
# comtypes version numbers follow semver (http://semver.org/) and PEP 440
|
|
2
|
+
__version__ = "1.4.5"
|
|
3
|
+
|
|
4
|
+
try:
|
|
5
|
+
from _ctypes import COMError # noqa
|
|
6
|
+
except ImportError as e:
|
|
7
|
+
msg = "\n".join(
|
|
8
|
+
(
|
|
9
|
+
"COM technology not available (maybe it's the wrong platform).",
|
|
10
|
+
"Note that COM is only supported on Windows.",
|
|
11
|
+
"For more details, please check: "
|
|
12
|
+
"https://learn.microsoft.com/en-us/windows/win32/com",
|
|
13
|
+
)
|
|
14
|
+
)
|
|
15
|
+
raise ImportError(msg) from e
|
|
16
|
+
|
|
17
|
+
import atexit
|
|
18
|
+
|
|
19
|
+
# HACK: Workaround for projects that depend on this package
|
|
20
|
+
# There should be several projects around the world that depend on this package
|
|
21
|
+
# and indirectly reference the symbols of `ctypes` from `comtypes`.
|
|
22
|
+
# If we remove the wildcard import from `ctypes`, they might break. So it is
|
|
23
|
+
# left in the following line.
|
|
24
|
+
from ctypes import * # noqa
|
|
25
|
+
from ctypes import HRESULT # noqa
|
|
26
|
+
from ctypes import _Pointer, _SimpleCData # noqa
|
|
27
|
+
from ctypes import c_int, c_ulong, oledll, windll
|
|
28
|
+
import logging
|
|
29
|
+
import sys
|
|
30
|
+
from typing import TYPE_CHECKING
|
|
31
|
+
|
|
32
|
+
if TYPE_CHECKING:
|
|
33
|
+
from ctypes import _CData # only in `typeshed`, private in runtime
|
|
34
|
+
from comtypes import hints as hints # noqa # type: ignore
|
|
35
|
+
else:
|
|
36
|
+
_CData = _SimpleCData.__mro__[:-1][-1]
|
|
37
|
+
|
|
38
|
+
from comtypes.GUID import GUID
|
|
39
|
+
from comtypes import patcher # noqa
|
|
40
|
+
from comtypes._npsupport import interop as npsupport # noqa
|
|
41
|
+
from comtypes._tlib_version_checker import _check_version # noqa
|
|
42
|
+
from comtypes._py_instance_method import instancemethod # noqa
|
|
43
|
+
from comtypes._idl_stuff import defaultvalue, helpstring, dispid # noqa
|
|
44
|
+
from comtypes._idl_stuff import STDMETHOD, DISPMETHOD, DISPPROPERTY, COMMETHOD # noqa
|
|
45
|
+
|
|
46
|
+
_all_slice = slice(None, None, None)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
class NullHandler(logging.Handler):
|
|
50
|
+
"""A Handler that does nothing."""
|
|
51
|
+
|
|
52
|
+
def emit(self, record):
|
|
53
|
+
pass
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
logger = logging.getLogger(__name__)
|
|
57
|
+
|
|
58
|
+
# Add a NULL handler to the comtypes logger. This prevents getting a
|
|
59
|
+
# message like this:
|
|
60
|
+
# No handlers could be found for logger "comtypes"
|
|
61
|
+
# when logging is not configured and logger.error() is called.
|
|
62
|
+
logger.addHandler(NullHandler())
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
class ReturnHRESULT(Exception):
|
|
66
|
+
"""ReturnHRESULT(hresult, text)
|
|
67
|
+
|
|
68
|
+
Return a hresult code from a COM method implementation
|
|
69
|
+
without logging an error.
|
|
70
|
+
"""
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
# class IDLWarning(UserWarning):
|
|
74
|
+
# "Warn about questionable type information"
|
|
75
|
+
|
|
76
|
+
_GUID = GUID
|
|
77
|
+
IID = GUID
|
|
78
|
+
DWORD = c_ulong
|
|
79
|
+
|
|
80
|
+
wireHWND = c_ulong
|
|
81
|
+
|
|
82
|
+
################################################################
|
|
83
|
+
# About COM apartments:
|
|
84
|
+
# http://blogs.msdn.com/larryosterman/archive/2004/04/28/122240.aspx
|
|
85
|
+
################################################################
|
|
86
|
+
|
|
87
|
+
################################################################
|
|
88
|
+
# constants for object creation
|
|
89
|
+
CLSCTX_INPROC_SERVER = 1
|
|
90
|
+
CLSCTX_INPROC_HANDLER = 2
|
|
91
|
+
CLSCTX_LOCAL_SERVER = 4
|
|
92
|
+
|
|
93
|
+
CLSCTX_INPROC = 3
|
|
94
|
+
CLSCTX_SERVER = 5
|
|
95
|
+
CLSCTX_ALL = 7
|
|
96
|
+
|
|
97
|
+
CLSCTX_INPROC_SERVER16 = 8
|
|
98
|
+
CLSCTX_REMOTE_SERVER = 16
|
|
99
|
+
CLSCTX_INPROC_HANDLER16 = 32
|
|
100
|
+
CLSCTX_RESERVED1 = 64
|
|
101
|
+
CLSCTX_RESERVED2 = 128
|
|
102
|
+
CLSCTX_RESERVED3 = 256
|
|
103
|
+
CLSCTX_RESERVED4 = 512
|
|
104
|
+
CLSCTX_NO_CODE_DOWNLOAD = 1024
|
|
105
|
+
CLSCTX_RESERVED5 = 2048
|
|
106
|
+
CLSCTX_NO_CUSTOM_MARSHAL = 4096
|
|
107
|
+
CLSCTX_ENABLE_CODE_DOWNLOAD = 8192
|
|
108
|
+
CLSCTX_NO_FAILURE_LOG = 16384
|
|
109
|
+
CLSCTX_DISABLE_AAA = 32768
|
|
110
|
+
CLSCTX_ENABLE_AAA = 65536
|
|
111
|
+
CLSCTX_FROM_DEFAULT_CONTEXT = 131072
|
|
112
|
+
|
|
113
|
+
tagCLSCTX = c_int # enum
|
|
114
|
+
CLSCTX = tagCLSCTX
|
|
115
|
+
|
|
116
|
+
# Constants for security setups
|
|
117
|
+
SEC_WINNT_AUTH_IDENTITY_UNICODE = 0x2
|
|
118
|
+
RPC_C_AUTHN_WINNT = 10
|
|
119
|
+
RPC_C_AUTHZ_NONE = 0
|
|
120
|
+
RPC_C_AUTHN_LEVEL_CONNECT = 2
|
|
121
|
+
RPC_C_IMP_LEVEL_IMPERSONATE = 3
|
|
122
|
+
EOAC_NONE = 0
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
################################################################
|
|
126
|
+
# Initialization and shutdown
|
|
127
|
+
_ole32 = oledll.ole32
|
|
128
|
+
_ole32_nohresult = windll.ole32 # use this for functions that don't return a HRESULT
|
|
129
|
+
|
|
130
|
+
COINIT_MULTITHREADED = 0x0
|
|
131
|
+
COINIT_APARTMENTTHREADED = 0x2
|
|
132
|
+
COINIT_DISABLE_OLE1DDE = 0x4
|
|
133
|
+
COINIT_SPEED_OVER_MEMORY = 0x8
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
def CoInitialize():
|
|
137
|
+
return CoInitializeEx(COINIT_APARTMENTTHREADED)
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
def CoInitializeEx(flags=None):
|
|
141
|
+
if flags is None:
|
|
142
|
+
flags = getattr(sys, "coinit_flags", COINIT_APARTMENTTHREADED)
|
|
143
|
+
logger.debug("CoInitializeEx(None, %s)", flags)
|
|
144
|
+
_ole32.CoInitializeEx(None, flags)
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
# COM is initialized automatically for the thread that imports this
|
|
148
|
+
# module for the first time. sys.coinit_flags is passed as parameter
|
|
149
|
+
# to CoInitializeEx, if defined, otherwise COINIT_APARTMENTTHREADED
|
|
150
|
+
# (COINIT_MULTITHREADED on Windows CE) is used.
|
|
151
|
+
#
|
|
152
|
+
# A shutdown function is registered with atexit, so that
|
|
153
|
+
# CoUninitialize is called when Python is shut down.
|
|
154
|
+
CoInitializeEx()
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
# We need to have CoUninitialize for multithreaded model where we have
|
|
158
|
+
# to initialize and uninitialize COM for every new thread (except main)
|
|
159
|
+
# in which we are using COM
|
|
160
|
+
def CoUninitialize():
|
|
161
|
+
logger.debug("CoUninitialize()")
|
|
162
|
+
_ole32_nohresult.CoUninitialize()
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
################################################################
|
|
166
|
+
# global registries.
|
|
167
|
+
|
|
168
|
+
# allows to find interface classes by guid strings (iid)
|
|
169
|
+
com_interface_registry = {}
|
|
170
|
+
|
|
171
|
+
# allows to find coclasses by guid strings (clsid)
|
|
172
|
+
com_coclass_registry = {}
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
################################################################
|
|
176
|
+
# IUnknown, the root of all evil...
|
|
177
|
+
from comtypes._post_coinit import _shutdown
|
|
178
|
+
from comtypes._post_coinit.unknwn import IUnknown # noqa
|
|
179
|
+
|
|
180
|
+
atexit.register(_shutdown)
|
|
181
|
+
|
|
182
|
+
################################################################
|
|
183
|
+
|
|
184
|
+
from comtypes._post_coinit.bstr import BSTR # noqa
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
################################################################
|
|
188
|
+
# IPersist is a trivial interface, which allows to ask an object about
|
|
189
|
+
# its clsid.
|
|
190
|
+
from comtypes._post_coinit.misc import IPersist, IServiceProvider # noqa
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
################################################################
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
from comtypes._post_coinit.misc import ( # noqa
|
|
197
|
+
_is_object,
|
|
198
|
+
CoGetObject,
|
|
199
|
+
CoCreateInstance,
|
|
200
|
+
CoGetClassObject,
|
|
201
|
+
GetActiveObject,
|
|
202
|
+
MULTI_QI,
|
|
203
|
+
_COAUTHIDENTITY,
|
|
204
|
+
COAUTHIDENTITY,
|
|
205
|
+
_COAUTHINFO,
|
|
206
|
+
COAUTHINFO,
|
|
207
|
+
_COSERVERINFO,
|
|
208
|
+
COSERVERINFO,
|
|
209
|
+
_CoGetClassObject,
|
|
210
|
+
tagBIND_OPTS,
|
|
211
|
+
BIND_OPTS,
|
|
212
|
+
tagBIND_OPTS2,
|
|
213
|
+
BINDOPTS2,
|
|
214
|
+
_SEC_WINNT_AUTH_IDENTITY,
|
|
215
|
+
SEC_WINNT_AUTH_IDENTITY,
|
|
216
|
+
_SOLE_AUTHENTICATION_INFO,
|
|
217
|
+
SOLE_AUTHENTICATION_INFO,
|
|
218
|
+
_SOLE_AUTHENTICATION_LIST,
|
|
219
|
+
SOLE_AUTHENTICATION_LIST,
|
|
220
|
+
CoCreateInstanceEx,
|
|
221
|
+
)
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
################################################################
|
|
225
|
+
from comtypes._comobject import COMObject
|
|
226
|
+
|
|
227
|
+
# What's a coclass?
|
|
228
|
+
# a POINTER to a coclass is allowed as parameter in a function declaration:
|
|
229
|
+
# http://msdn.microsoft.com/library/en-us/midl/midl/oleautomation.asp
|
|
230
|
+
|
|
231
|
+
from comtypes._meta import _coclass_meta
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
class CoClass(COMObject, metaclass=_coclass_meta):
|
|
235
|
+
pass
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
################################################################
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
# fmt: off
|
|
242
|
+
__known_symbols__ = [
|
|
243
|
+
"BIND_OPTS", "tagBIND_OPTS", "BINDOPTS2", "tagBIND_OPTS2", "BSTR",
|
|
244
|
+
"_check_version", "CLSCTX", "tagCLSCTX", "CLSCTX_ALL",
|
|
245
|
+
"CLSCTX_DISABLE_AAA", "CLSCTX_ENABLE_AAA", "CLSCTX_ENABLE_CODE_DOWNLOAD",
|
|
246
|
+
"CLSCTX_FROM_DEFAULT_CONTEXT", "CLSCTX_INPROC", "CLSCTX_INPROC_HANDLER",
|
|
247
|
+
"CLSCTX_INPROC_HANDLER16", "CLSCTX_INPROC_SERVER",
|
|
248
|
+
"CLSCTX_INPROC_SERVER16", "CLSCTX_LOCAL_SERVER", "CLSCTX_NO_CODE_DOWNLOAD",
|
|
249
|
+
"CLSCTX_NO_CUSTOM_MARSHAL", "CLSCTX_NO_FAILURE_LOG",
|
|
250
|
+
"CLSCTX_REMOTE_SERVER", "CLSCTX_RESERVED1", "CLSCTX_RESERVED2",
|
|
251
|
+
"CLSCTX_RESERVED3", "CLSCTX_RESERVED4", "CLSCTX_RESERVED5",
|
|
252
|
+
"CLSCTX_SERVER", "_COAUTHIDENTITY", "COAUTHIDENTITY", "_COAUTHINFO",
|
|
253
|
+
"COAUTHINFO", "CoClass", "CoCreateInstance", "CoCreateInstanceEx",
|
|
254
|
+
"_CoGetClassObject", "CoGetClassObject", "CoGetObject",
|
|
255
|
+
"COINIT_APARTMENTTHREADED", "COINIT_DISABLE_OLE1DDE",
|
|
256
|
+
"COINIT_MULTITHREADED", "COINIT_SPEED_OVER_MEMORY", "CoInitialize",
|
|
257
|
+
"CoInitializeEx", "COMError", "COMMETHOD", "COMObject", "_COSERVERINFO",
|
|
258
|
+
"COSERVERINFO", "CoUninitialize", "dispid", "DISPMETHOD", "DISPPROPERTY",
|
|
259
|
+
"DWORD", "EOAC_NONE", "GetActiveObject", "_GUID", "GUID", "helpstring",
|
|
260
|
+
"IID", "IPersist", "IServiceProvider", "IUnknown", "MULTI_QI",
|
|
261
|
+
"ReturnHRESULT", "RPC_C_AUTHN_LEVEL_CONNECT", "RPC_C_AUTHN_WINNT",
|
|
262
|
+
"RPC_C_AUTHZ_NONE", "RPC_C_IMP_LEVEL_IMPERSONATE",
|
|
263
|
+
"_SEC_WINNT_AUTH_IDENTITY", "SEC_WINNT_AUTH_IDENTITY",
|
|
264
|
+
"SEC_WINNT_AUTH_IDENTITY_UNICODE", "_SOLE_AUTHENTICATION_INFO",
|
|
265
|
+
"SOLE_AUTHENTICATION_INFO", "_SOLE_AUTHENTICATION_LIST",
|
|
266
|
+
"SOLE_AUTHENTICATION_LIST", "STDMETHOD", "wireHWND",
|
|
267
|
+
]
|
|
268
|
+
# fmt: on
|
|
@@ -16,7 +16,8 @@ import os
|
|
|
16
16
|
import queue
|
|
17
17
|
import sys
|
|
18
18
|
|
|
19
|
-
from comtypes import COMError, ReturnHRESULT, instancemethod
|
|
19
|
+
from comtypes import COMError, ReturnHRESULT, instancemethod
|
|
20
|
+
from comtypes._memberspec import _encode_idl
|
|
20
21
|
from comtypes.errorinfo import ISupportErrorInfo, ReportException, ReportError
|
|
21
22
|
from comtypes import IPersist
|
|
22
23
|
from comtypes.hresult import (
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
from comtypes._memberspec import _ComMemberSpec, _DispMemberSpec, _resolve_argspec
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class helpstring(str):
|
|
5
|
+
"Specifies the helpstring for a COM method or property."
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class defaultvalue(object):
|
|
9
|
+
"Specifies the default value for parameters marked optional."
|
|
10
|
+
|
|
11
|
+
def __init__(self, value):
|
|
12
|
+
self.value = value
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class dispid(int):
|
|
16
|
+
"Specifies the DISPID of a method or property."
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
# XXX STDMETHOD, COMMETHOD, DISPMETHOD, and DISPPROPERTY should return
|
|
20
|
+
# instances with more methods or properties, and should not behave as an unpackable.
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def STDMETHOD(restype, name, argtypes=()) -> _ComMemberSpec:
|
|
24
|
+
"Specifies a COM method slot without idlflags"
|
|
25
|
+
return _ComMemberSpec(restype, name, argtypes, None, (), None)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def DISPMETHOD(idlflags, restype, name, *argspec) -> _DispMemberSpec:
|
|
29
|
+
"Specifies a method of a dispinterface"
|
|
30
|
+
return _DispMemberSpec("DISPMETHOD", name, tuple(idlflags), restype, argspec)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def DISPPROPERTY(idlflags, proptype, name) -> _DispMemberSpec:
|
|
34
|
+
"Specifies a property of a dispinterface"
|
|
35
|
+
return _DispMemberSpec("DISPPROPERTY", name, tuple(idlflags), proptype, ())
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
# tuple(idlflags) is for the method itself: (dispid, 'readonly')
|
|
39
|
+
|
|
40
|
+
# sample generated code:
|
|
41
|
+
# DISPPROPERTY([5, 'readonly'], OLE_YSIZE_HIMETRIC, 'Height'),
|
|
42
|
+
# DISPMETHOD(
|
|
43
|
+
# [6], None, 'Render', ([], c_int, 'hdc'), ([], c_int, 'x'), ([], c_int, 'y')
|
|
44
|
+
# )
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def COMMETHOD(idlflags, restype, methodname, *argspec) -> _ComMemberSpec:
|
|
48
|
+
"""Specifies a COM method slot with idlflags.
|
|
49
|
+
|
|
50
|
+
XXX should explain the sematics of the arguments.
|
|
51
|
+
"""
|
|
52
|
+
# collect all helpstring instances
|
|
53
|
+
# We should suppress docstrings when Python is started with -OO
|
|
54
|
+
# join them together(does this make sense?) and replace by None if empty.
|
|
55
|
+
helptext = "".join(t for t in idlflags if isinstance(t, helpstring)) or None
|
|
56
|
+
paramflags, argtypes = _resolve_argspec(argspec)
|
|
57
|
+
if "propget" in idlflags:
|
|
58
|
+
name = "_get_%s" % methodname
|
|
59
|
+
elif "propput" in idlflags:
|
|
60
|
+
name = "_set_%s" % methodname
|
|
61
|
+
elif "propputref" in idlflags:
|
|
62
|
+
name = "_setref_%s" % methodname
|
|
63
|
+
else:
|
|
64
|
+
name = methodname
|
|
65
|
+
return _ComMemberSpec(
|
|
66
|
+
restype, name, argtypes, paramflags, tuple(idlflags), helptext
|
|
67
|
+
)
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"""comtypes._post_coinit
|
|
2
|
+
|
|
3
|
+
This subpackage contains symbols that should be imported into `comtypes/__init__.py`
|
|
4
|
+
after `CoInitializeEx` is defined and called, and symbols that can be defined in
|
|
5
|
+
any order during the initialization of the `comtypes` package.
|
|
6
|
+
|
|
7
|
+
These were previously defined in `comtypes/__init__.py`, but due to the codebase
|
|
8
|
+
of the file becoming bloated, reducing the ease of changes and increasing
|
|
9
|
+
cognitive load, they have been moved here.
|
|
10
|
+
|
|
11
|
+
This subpackage is called simultaneously with the initialization of `comtypes`.
|
|
12
|
+
So it is necessary to maintain minimal settings to keep the lightweight action
|
|
13
|
+
when the package is initialized.
|
|
14
|
+
"""
|
|
15
|
+
from comtypes._post_coinit.unknwn import _shutdown # noqa
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
from ctypes import _SimpleCData, windll
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class BSTR(_SimpleCData):
|
|
5
|
+
"The windows BSTR data type"
|
|
6
|
+
_type_ = "X"
|
|
7
|
+
_needsfree = False
|
|
8
|
+
|
|
9
|
+
def __repr__(self):
|
|
10
|
+
return "%s(%r)" % (self.__class__.__name__, self.value)
|
|
11
|
+
|
|
12
|
+
def __ctypes_from_outparam__(self):
|
|
13
|
+
self._needsfree = True
|
|
14
|
+
return self.value
|
|
15
|
+
|
|
16
|
+
def __del__(self, _free=windll.oleaut32.SysFreeString):
|
|
17
|
+
# Free the string if self owns the memory
|
|
18
|
+
# or if instructed by __ctypes_from_outparam__.
|
|
19
|
+
if self._b_base_ is None or self._needsfree:
|
|
20
|
+
_free(self)
|
|
21
|
+
|
|
22
|
+
@classmethod
|
|
23
|
+
def from_param(cls, value):
|
|
24
|
+
"""Convert into a foreign function call parameter."""
|
|
25
|
+
if isinstance(value, cls):
|
|
26
|
+
return value
|
|
27
|
+
# Although the builtin SimpleCData.from_param call does the
|
|
28
|
+
# right thing, it doesn't ensure that SysFreeString is called
|
|
29
|
+
# on destruction.
|
|
30
|
+
return cls(value)
|