comtypes 1.4.3__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.3 → comtypes-1.4.5}/CHANGES.txt +18 -0
- {comtypes-1.4.3/comtypes.egg-info → comtypes-1.4.5}/PKG-INFO +2 -3
- {comtypes-1.4.3 → comtypes-1.4.5}/README.md +0 -1
- comtypes-1.4.5/comtypes/__init__.py +268 -0
- {comtypes-1.4.3 → 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.3 → comtypes-1.4.5}/comtypes/_safearray.py +3 -2
- comtypes-1.4.5/comtypes/_tlib_version_checker.py +18 -0
- {comtypes-1.4.3 → comtypes-1.4.5}/comtypes/automation.py +22 -6
- {comtypes-1.4.3 → comtypes-1.4.5}/comtypes/client/_generate.py +2 -1
- {comtypes-1.4.3 → comtypes-1.4.5}/comtypes/hints.pyi +34 -0
- {comtypes-1.4.3 → comtypes-1.4.5}/comtypes/safearray.py +11 -4
- comtypes-1.4.5/comtypes/stream.py +65 -0
- comtypes-1.4.5/comtypes/test/mylib.tlb +0 -0
- {comtypes-1.4.3 → comtypes-1.4.5}/comtypes/test/test_client.py +11 -0
- {comtypes-1.4.3 → 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.3 → comtypes-1.4.5}/comtypes/test/test_wmi.py +11 -18
- comtypes-1.4.5/comtypes/test/urlhist.tlb +0 -0
- {comtypes-1.4.3 → comtypes-1.4.5/comtypes.egg-info}/PKG-INFO +2 -3
- {comtypes-1.4.3 → comtypes-1.4.5}/comtypes.egg-info/SOURCES.txt +15 -0
- comtypes-1.4.5/pyproject.toml +3 -0
- comtypes-1.4.5/setup.cfg +52 -0
- comtypes-1.4.5/setup.py +117 -0
- comtypes-1.4.3/comtypes/__init__.py +0 -1229
- comtypes-1.4.3/setup.cfg +0 -4
- comtypes-1.4.3/setup.py +0 -173
- {comtypes-1.4.3 → comtypes-1.4.5}/LICENSE.txt +0 -0
- {comtypes-1.4.3 → comtypes-1.4.5}/MANIFEST.in +0 -0
- {comtypes-1.4.3 → comtypes-1.4.5}/comtypes/GUID.py +0 -0
- {comtypes-1.4.3 → comtypes-1.4.5}/comtypes/_memberspec.py +0 -0
- {comtypes-1.4.3 → comtypes-1.4.5}/comtypes/_meta.py +0 -0
- {comtypes-1.4.3 → comtypes-1.4.5}/comtypes/_npsupport.py +0 -0
- {comtypes-1.4.3 → comtypes-1.4.5}/comtypes/clear_cache.py +0 -0
- {comtypes-1.4.3 → comtypes-1.4.5}/comtypes/client/__init__.py +0 -0
- {comtypes-1.4.3 → comtypes-1.4.5}/comtypes/client/_code_cache.py +0 -0
- {comtypes-1.4.3 → comtypes-1.4.5}/comtypes/client/_constants.py +0 -0
- {comtypes-1.4.3 → comtypes-1.4.5}/comtypes/client/_events.py +0 -0
- {comtypes-1.4.3 → comtypes-1.4.5}/comtypes/client/dynamic.py +0 -0
- {comtypes-1.4.3 → comtypes-1.4.5}/comtypes/client/lazybind.py +0 -0
- {comtypes-1.4.3 → comtypes-1.4.5}/comtypes/connectionpoints.py +0 -0
- {comtypes-1.4.3 → comtypes-1.4.5}/comtypes/errorinfo.py +0 -0
- {comtypes-1.4.3 → comtypes-1.4.5}/comtypes/git.py +0 -0
- {comtypes-1.4.3 → comtypes-1.4.5}/comtypes/hresult.py +0 -0
- {comtypes-1.4.3 → comtypes-1.4.5}/comtypes/logutil.py +0 -0
- {comtypes-1.4.3 → comtypes-1.4.5}/comtypes/messageloop.py +0 -0
- {comtypes-1.4.3 → comtypes-1.4.5}/comtypes/patcher.py +0 -0
- {comtypes-1.4.3 → comtypes-1.4.5}/comtypes/persist.py +0 -0
- {comtypes-1.4.3 → comtypes-1.4.5}/comtypes/server/__init__.py +0 -0
- {comtypes-1.4.3 → comtypes-1.4.5}/comtypes/server/automation.py +0 -0
- {comtypes-1.4.3 → comtypes-1.4.5}/comtypes/server/connectionpoints.py +0 -0
- {comtypes-1.4.3 → comtypes-1.4.5}/comtypes/server/inprocserver.py +0 -0
- {comtypes-1.4.3 → comtypes-1.4.5}/comtypes/server/localserver.py +0 -0
- {comtypes-1.4.3 → comtypes-1.4.5}/comtypes/server/register.py +0 -0
- {comtypes-1.4.3 → comtypes-1.4.5}/comtypes/server/w_getopt.py +0 -0
- {comtypes-1.4.3 → comtypes-1.4.5}/comtypes/shelllink.py +0 -0
- {comtypes-1.4.3 → comtypes-1.4.5}/comtypes/test/TestComServer.idl +0 -0
- {comtypes-1.4.3 → comtypes-1.4.5}/comtypes/test/TestComServer.py +0 -0
- {comtypes-1.4.3 → comtypes-1.4.5}/comtypes/test/TestComServer.tlb +0 -0
- {comtypes-1.4.3 → comtypes-1.4.5}/comtypes/test/TestDispServer.idl +0 -0
- {comtypes-1.4.3 → comtypes-1.4.5}/comtypes/test/TestDispServer.py +0 -0
- {comtypes-1.4.3 → comtypes-1.4.5}/comtypes/test/TestDispServer.tlb +0 -0
- {comtypes-1.4.3 → comtypes-1.4.5}/comtypes/test/__init__.py +0 -0
- {comtypes-1.4.3 → comtypes-1.4.5}/comtypes/test/find_memleak.py +0 -0
- {comtypes-1.4.3 → comtypes-1.4.5}/comtypes/test/mylib.idl +0 -0
- {comtypes-1.4.3 → comtypes-1.4.5}/comtypes/test/mytypelib.idl +0 -0
- {comtypes-1.4.3 → comtypes-1.4.5}/comtypes/test/runtests.py +0 -0
- {comtypes-1.4.3 → comtypes-1.4.5}/comtypes/test/setup.py +0 -0
- {comtypes-1.4.3 → comtypes-1.4.5}/comtypes/test/test_BSTR.py +0 -0
- {comtypes-1.4.3 → comtypes-1.4.5}/comtypes/test/test_DISPPARAMS.py +0 -0
- {comtypes-1.4.3 → comtypes-1.4.5}/comtypes/test/test_GUID.py +0 -0
- {comtypes-1.4.3 → comtypes-1.4.5}/comtypes/test/test_QueryService.py +0 -0
- {comtypes-1.4.3 → comtypes-1.4.5}/comtypes/test/test_agilent.py +0 -0
- {comtypes-1.4.3 → comtypes-1.4.5}/comtypes/test/test_avmc.py +0 -0
- {comtypes-1.4.3 → comtypes-1.4.5}/comtypes/test/test_basic.py +0 -0
- {comtypes-1.4.3 → comtypes-1.4.5}/comtypes/test/test_casesensitivity.py +0 -0
- {comtypes-1.4.3 → comtypes-1.4.5}/comtypes/test/test_clear_cache.py +0 -0
- {comtypes-1.4.3 → comtypes-1.4.5}/comtypes/test/test_client_dynamic.py +0 -0
- {comtypes-1.4.3 → comtypes-1.4.5}/comtypes/test/test_client_regenerate_modules.py +0 -0
- {comtypes-1.4.3 → comtypes-1.4.5}/comtypes/test/test_collections.py +0 -0
- {comtypes-1.4.3 → comtypes-1.4.5}/comtypes/test/test_comserver.py +0 -0
- {comtypes-1.4.3 → comtypes-1.4.5}/comtypes/test/test_createwrappers.py +0 -0
- {comtypes-1.4.3 → comtypes-1.4.5}/comtypes/test/test_dict.py +0 -0
- {comtypes-1.4.3 → comtypes-1.4.5}/comtypes/test/test_dispinterface.py +0 -0
- {comtypes-1.4.3 → comtypes-1.4.5}/comtypes/test/test_dyndispatch.py +0 -0
- {comtypes-1.4.3 → comtypes-1.4.5}/comtypes/test/test_excel.py +0 -0
- {comtypes-1.4.3 → comtypes-1.4.5}/comtypes/test/test_findgendir.py +0 -0
- {comtypes-1.4.3 → comtypes-1.4.5}/comtypes/test/test_getactiveobj.py +0 -0
- {comtypes-1.4.3 → comtypes-1.4.5}/comtypes/test/test_ie.py +0 -0
- {comtypes-1.4.3 → comtypes-1.4.5}/comtypes/test/test_ienum.py +0 -0
- {comtypes-1.4.3 → comtypes-1.4.5}/comtypes/test/test_imfattributes.py +0 -0
- {comtypes-1.4.3 → comtypes-1.4.5}/comtypes/test/test_inout_args.py +0 -0
- {comtypes-1.4.3 → comtypes-1.4.5}/comtypes/test/test_jscript.js +0 -0
- {comtypes-1.4.3 → comtypes-1.4.5}/comtypes/test/test_msscript.py +0 -0
- {comtypes-1.4.3 → comtypes-1.4.5}/comtypes/test/test_npsupport.py +0 -0
- {comtypes-1.4.3 → comtypes-1.4.5}/comtypes/test/test_outparam.py +0 -0
- {comtypes-1.4.3 → comtypes-1.4.5}/comtypes/test/test_propputref.py +0 -0
- {comtypes-1.4.3 → comtypes-1.4.5}/comtypes/test/test_pump_events.py +0 -0
- {comtypes-1.4.3 → comtypes-1.4.5}/comtypes/test/test_safearray.py +0 -0
- {comtypes-1.4.3 → comtypes-1.4.5}/comtypes/test/test_sapi.py +0 -0
- {comtypes-1.4.3 → comtypes-1.4.5}/comtypes/test/test_server.py +0 -0
- {comtypes-1.4.3 → comtypes-1.4.5}/comtypes/test/test_showevents.py +0 -0
- {comtypes-1.4.3 → comtypes-1.4.5}/comtypes/test/test_subinterface.py +0 -0
- {comtypes-1.4.3 → comtypes-1.4.5}/comtypes/test/test_typeinfo.py +0 -0
- {comtypes-1.4.3 → comtypes-1.4.5}/comtypes/test/test_urlhistory.py +0 -0
- {comtypes-1.4.3 → comtypes-1.4.5}/comtypes/test/test_variant.py +0 -0
- {comtypes-1.4.3 → comtypes-1.4.5}/comtypes/test/test_win32com_interop.py +0 -0
- {comtypes-1.4.3 → comtypes-1.4.5}/comtypes/test/test_word.py +0 -0
- {comtypes-1.4.3 → comtypes-1.4.5}/comtypes/tools/__init__.py +0 -0
- {comtypes-1.4.3 → comtypes-1.4.5}/comtypes/tools/codegenerator/__init__.py +0 -0
- {comtypes-1.4.3 → comtypes-1.4.5}/comtypes/tools/codegenerator/codegenerator.py +0 -0
- {comtypes-1.4.3 → comtypes-1.4.5}/comtypes/tools/codegenerator/helpers.py +0 -0
- {comtypes-1.4.3 → comtypes-1.4.5}/comtypes/tools/codegenerator/modulenamer.py +0 -0
- {comtypes-1.4.3 → comtypes-1.4.5}/comtypes/tools/codegenerator/namespaces.py +0 -0
- {comtypes-1.4.3 → comtypes-1.4.5}/comtypes/tools/codegenerator/packing.py +0 -0
- {comtypes-1.4.3 → comtypes-1.4.5}/comtypes/tools/codegenerator/typeannotator.py +0 -0
- {comtypes-1.4.3 → comtypes-1.4.5}/comtypes/tools/tlbparser.py +0 -0
- {comtypes-1.4.3 → comtypes-1.4.5}/comtypes/tools/typedesc.py +0 -0
- {comtypes-1.4.3 → comtypes-1.4.5}/comtypes/tools/typedesc_base.py +0 -0
- {comtypes-1.4.3 → comtypes-1.4.5}/comtypes/typeinfo.py +0 -0
- {comtypes-1.4.3 → comtypes-1.4.5}/comtypes/util.py +0 -0
- {comtypes-1.4.3 → comtypes-1.4.5}/comtypes/viewobject.py +0 -0
- {comtypes-1.4.3 → comtypes-1.4.5}/comtypes.egg-info/dependency_links.txt +0 -0
- {comtypes-1.4.3 → comtypes-1.4.5}/comtypes.egg-info/entry_points.txt +0 -0
- {comtypes-1.4.3 → comtypes-1.4.5}/comtypes.egg-info/top_level.txt +0 -0
|
@@ -0,0 +1,385 @@
|
|
|
1
|
+
from ctypes import c_ulong, c_ushort, c_void_p, c_wchar_p, HRESULT, Structure
|
|
2
|
+
from ctypes import byref, cast, _Pointer, POINTER, pointer
|
|
3
|
+
|
|
4
|
+
# fmt: off
|
|
5
|
+
from typing import ( # noqa
|
|
6
|
+
Any, overload, TYPE_CHECKING, TypeVar,
|
|
7
|
+
# instead of `builtins`. see PEP585
|
|
8
|
+
Type,
|
|
9
|
+
# instead of `collections.abc`. see PEP585
|
|
10
|
+
Callable,
|
|
11
|
+
# instead of `A | B` and `None | A`. see PEP604
|
|
12
|
+
Optional,
|
|
13
|
+
)
|
|
14
|
+
# fmt: on
|
|
15
|
+
if TYPE_CHECKING:
|
|
16
|
+
from comtypes import hints as hints # noqa # type: ignore
|
|
17
|
+
|
|
18
|
+
from comtypes import GUID
|
|
19
|
+
from comtypes._idl_stuff import COMMETHOD # noqa
|
|
20
|
+
from comtypes import CLSCTX_SERVER, CLSCTX_LOCAL_SERVER, CLSCTX_REMOTE_SERVER
|
|
21
|
+
from comtypes import _ole32, oledll, DWORD
|
|
22
|
+
from comtypes._post_coinit.unknwn import IUnknown
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def _is_object(obj):
|
|
26
|
+
"""This function determines if the argument is a COM object. It
|
|
27
|
+
is used in several places to determine whether propputref or
|
|
28
|
+
propput setters have to be used."""
|
|
29
|
+
from comtypes.automation import VARIANT
|
|
30
|
+
|
|
31
|
+
# A COM pointer is an 'Object'
|
|
32
|
+
if isinstance(obj, POINTER(IUnknown)):
|
|
33
|
+
return True
|
|
34
|
+
# A COM pointer in a VARIANT is an 'Object', too
|
|
35
|
+
elif isinstance(obj, VARIANT) and isinstance(obj.value, POINTER(IUnknown)):
|
|
36
|
+
return True
|
|
37
|
+
# It may be a dynamic dispatch object.
|
|
38
|
+
return hasattr(obj, "_comobj")
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
_T_IUnknown = TypeVar("_T_IUnknown", bound=IUnknown)
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
################################################################
|
|
45
|
+
# IPersist is a trivial interface, which allows to ask an object about
|
|
46
|
+
# its clsid.
|
|
47
|
+
class IPersist(IUnknown):
|
|
48
|
+
_iid_ = GUID("{0000010C-0000-0000-C000-000000000046}")
|
|
49
|
+
_idlflags_ = []
|
|
50
|
+
_methods_ = [
|
|
51
|
+
COMMETHOD([], HRESULT, "GetClassID", (["out"], POINTER(GUID), "pClassID")),
|
|
52
|
+
]
|
|
53
|
+
if TYPE_CHECKING:
|
|
54
|
+
# Should this be "normal" method that calls `self._GetClassID`?
|
|
55
|
+
def GetClassID(self) -> GUID:
|
|
56
|
+
"""Returns the CLSID that uniquely represents an object class that
|
|
57
|
+
defines the code that can manipulate the object's data.
|
|
58
|
+
"""
|
|
59
|
+
...
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
class IServiceProvider(IUnknown):
|
|
63
|
+
_iid_ = GUID("{6D5140C1-7436-11CE-8034-00AA006009FA}")
|
|
64
|
+
_QueryService: Callable[[Any, Any, Any], int]
|
|
65
|
+
|
|
66
|
+
# Overridden QueryService to make it nicer to use (passing it an
|
|
67
|
+
# interface and it returns a pointer to that interface)
|
|
68
|
+
def QueryService(
|
|
69
|
+
self, serviceIID: GUID, interface: Type[_T_IUnknown]
|
|
70
|
+
) -> _T_IUnknown:
|
|
71
|
+
p = POINTER(interface)()
|
|
72
|
+
self._QueryService(byref(serviceIID), byref(interface._iid_), byref(p))
|
|
73
|
+
return p # type: ignore
|
|
74
|
+
|
|
75
|
+
_methods_ = [
|
|
76
|
+
COMMETHOD(
|
|
77
|
+
[],
|
|
78
|
+
HRESULT,
|
|
79
|
+
"QueryService",
|
|
80
|
+
(["in"], POINTER(GUID), "guidService"),
|
|
81
|
+
(["in"], POINTER(GUID), "riid"),
|
|
82
|
+
(["in"], POINTER(c_void_p), "ppvObject"),
|
|
83
|
+
)
|
|
84
|
+
]
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
################################################################
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
@overload
|
|
91
|
+
def CoGetObject(displayname: str, interface: None) -> IUnknown:
|
|
92
|
+
...
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
@overload
|
|
96
|
+
def CoGetObject(displayname: str, interface: Type[_T_IUnknown]) -> _T_IUnknown:
|
|
97
|
+
...
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
def CoGetObject(displayname: str, interface: Optional[Type[IUnknown]]) -> IUnknown:
|
|
101
|
+
"""Convert a displayname to a moniker, then bind and return the object
|
|
102
|
+
identified by the moniker."""
|
|
103
|
+
if interface is None:
|
|
104
|
+
interface = IUnknown
|
|
105
|
+
punk = POINTER(interface)()
|
|
106
|
+
# Do we need a way to specify the BIND_OPTS parameter?
|
|
107
|
+
_ole32.CoGetObject(str(displayname), None, byref(interface._iid_), byref(punk))
|
|
108
|
+
return punk # type: ignore
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
_pUnkOuter = Type["_Pointer[IUnknown]"]
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
@overload
|
|
115
|
+
def CoCreateInstance(
|
|
116
|
+
clsid: GUID,
|
|
117
|
+
interface: None = None,
|
|
118
|
+
clsctx: Optional[int] = None,
|
|
119
|
+
punkouter: Optional[_pUnkOuter] = None,
|
|
120
|
+
) -> IUnknown:
|
|
121
|
+
...
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
@overload
|
|
125
|
+
def CoCreateInstance(
|
|
126
|
+
clsid: GUID,
|
|
127
|
+
interface: Type[_T_IUnknown],
|
|
128
|
+
clsctx: Optional[int] = None,
|
|
129
|
+
punkouter: Optional[_pUnkOuter] = None,
|
|
130
|
+
) -> _T_IUnknown:
|
|
131
|
+
...
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
def CoCreateInstance(
|
|
135
|
+
clsid: GUID,
|
|
136
|
+
interface: Optional[Type[IUnknown]] = None,
|
|
137
|
+
clsctx: Optional[int] = None,
|
|
138
|
+
punkouter: Optional[_pUnkOuter] = None,
|
|
139
|
+
) -> IUnknown:
|
|
140
|
+
"""The basic windows api to create a COM class object and return a
|
|
141
|
+
pointer to an interface.
|
|
142
|
+
"""
|
|
143
|
+
if clsctx is None:
|
|
144
|
+
clsctx = CLSCTX_SERVER
|
|
145
|
+
if interface is None:
|
|
146
|
+
interface = IUnknown
|
|
147
|
+
p = POINTER(interface)()
|
|
148
|
+
iid = interface._iid_
|
|
149
|
+
_ole32.CoCreateInstance(byref(clsid), punkouter, clsctx, byref(iid), byref(p))
|
|
150
|
+
return p # type: ignore
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
if TYPE_CHECKING:
|
|
154
|
+
|
|
155
|
+
@overload
|
|
156
|
+
def CoGetClassObject(clsid, clsctx=None, pServerInfo=None, interface=None):
|
|
157
|
+
# type: (GUID, Optional[int], Optional[COSERVERINFO], None) -> hints.IClassFactory
|
|
158
|
+
pass
|
|
159
|
+
|
|
160
|
+
@overload
|
|
161
|
+
def CoGetClassObject(clsid, clsctx=None, pServerInfo=None, interface=None):
|
|
162
|
+
# type: (GUID, Optional[int], Optional[COSERVERINFO], Type[_T_IUnknown]) -> _T_IUnknown
|
|
163
|
+
pass
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
def CoGetClassObject(clsid, clsctx=None, pServerInfo=None, interface=None):
|
|
167
|
+
# type: (GUID, Optional[int], Optional[COSERVERINFO], Optional[Type[IUnknown]]) -> IUnknown
|
|
168
|
+
if clsctx is None:
|
|
169
|
+
clsctx = CLSCTX_SERVER
|
|
170
|
+
if interface is None:
|
|
171
|
+
import comtypes.server
|
|
172
|
+
|
|
173
|
+
interface = comtypes.server.IClassFactory
|
|
174
|
+
p = POINTER(interface)()
|
|
175
|
+
_CoGetClassObject(clsid, clsctx, pServerInfo, interface._iid_, byref(p))
|
|
176
|
+
return p # type: ignore
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
@overload
|
|
180
|
+
def GetActiveObject(clsid: GUID, interface: None = None) -> IUnknown:
|
|
181
|
+
...
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
@overload
|
|
185
|
+
def GetActiveObject(clsid: GUID, interface: Type[_T_IUnknown]) -> _T_IUnknown:
|
|
186
|
+
...
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
def GetActiveObject(
|
|
190
|
+
clsid: GUID, interface: Optional[Type[IUnknown]] = None
|
|
191
|
+
) -> IUnknown:
|
|
192
|
+
"""Retrieves a pointer to a running object"""
|
|
193
|
+
p = POINTER(IUnknown)()
|
|
194
|
+
oledll.oleaut32.GetActiveObject(byref(clsid), None, byref(p))
|
|
195
|
+
if interface is not None:
|
|
196
|
+
p = p.QueryInterface(interface) # type: ignore
|
|
197
|
+
return p # type: ignore
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
class MULTI_QI(Structure):
|
|
201
|
+
_fields_ = [("pIID", POINTER(GUID)), ("pItf", POINTER(c_void_p)), ("hr", HRESULT)]
|
|
202
|
+
if TYPE_CHECKING:
|
|
203
|
+
pIID: GUID
|
|
204
|
+
pItf: _Pointer[c_void_p]
|
|
205
|
+
hr: HRESULT
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
class _COAUTHIDENTITY(Structure):
|
|
209
|
+
_fields_ = [
|
|
210
|
+
("User", POINTER(c_ushort)),
|
|
211
|
+
("UserLength", c_ulong),
|
|
212
|
+
("Domain", POINTER(c_ushort)),
|
|
213
|
+
("DomainLength", c_ulong),
|
|
214
|
+
("Password", POINTER(c_ushort)),
|
|
215
|
+
("PasswordLength", c_ulong),
|
|
216
|
+
("Flags", c_ulong),
|
|
217
|
+
]
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
COAUTHIDENTITY = _COAUTHIDENTITY
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
class _COAUTHINFO(Structure):
|
|
224
|
+
_fields_ = [
|
|
225
|
+
("dwAuthnSvc", c_ulong),
|
|
226
|
+
("dwAuthzSvc", c_ulong),
|
|
227
|
+
("pwszServerPrincName", c_wchar_p),
|
|
228
|
+
("dwAuthnLevel", c_ulong),
|
|
229
|
+
("dwImpersonationLevel", c_ulong),
|
|
230
|
+
("pAuthIdentityData", POINTER(_COAUTHIDENTITY)),
|
|
231
|
+
("dwCapabilities", c_ulong),
|
|
232
|
+
]
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
COAUTHINFO = _COAUTHINFO
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
class _COSERVERINFO(Structure):
|
|
239
|
+
_fields_ = [
|
|
240
|
+
("dwReserved1", c_ulong),
|
|
241
|
+
("pwszName", c_wchar_p),
|
|
242
|
+
("pAuthInfo", POINTER(_COAUTHINFO)),
|
|
243
|
+
("dwReserved2", c_ulong),
|
|
244
|
+
]
|
|
245
|
+
if TYPE_CHECKING:
|
|
246
|
+
dwReserved1: int
|
|
247
|
+
pwszName: Optional[str]
|
|
248
|
+
pAuthInfo: _COAUTHINFO
|
|
249
|
+
dwReserved2: int
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
COSERVERINFO = _COSERVERINFO
|
|
253
|
+
_CoGetClassObject = _ole32.CoGetClassObject
|
|
254
|
+
_CoGetClassObject.argtypes = [
|
|
255
|
+
POINTER(GUID),
|
|
256
|
+
DWORD,
|
|
257
|
+
POINTER(COSERVERINFO),
|
|
258
|
+
POINTER(GUID),
|
|
259
|
+
POINTER(c_void_p),
|
|
260
|
+
]
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
class tagBIND_OPTS(Structure):
|
|
264
|
+
_fields_ = [
|
|
265
|
+
("cbStruct", c_ulong),
|
|
266
|
+
("grfFlags", c_ulong),
|
|
267
|
+
("grfMode", c_ulong),
|
|
268
|
+
("dwTickCountDeadline", c_ulong),
|
|
269
|
+
]
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
# XXX Add __init__ which sets cbStruct?
|
|
273
|
+
BIND_OPTS = tagBIND_OPTS
|
|
274
|
+
|
|
275
|
+
|
|
276
|
+
class tagBIND_OPTS2(Structure):
|
|
277
|
+
_fields_ = [
|
|
278
|
+
("cbStruct", c_ulong),
|
|
279
|
+
("grfFlags", c_ulong),
|
|
280
|
+
("grfMode", c_ulong),
|
|
281
|
+
("dwTickCountDeadline", c_ulong),
|
|
282
|
+
("dwTrackFlags", c_ulong),
|
|
283
|
+
("dwClassContext", c_ulong),
|
|
284
|
+
("locale", c_ulong),
|
|
285
|
+
("pServerInfo", POINTER(_COSERVERINFO)),
|
|
286
|
+
]
|
|
287
|
+
|
|
288
|
+
|
|
289
|
+
# XXX Add __init__ which sets cbStruct?
|
|
290
|
+
BINDOPTS2 = tagBIND_OPTS2
|
|
291
|
+
|
|
292
|
+
|
|
293
|
+
# Structures for security setups
|
|
294
|
+
#########################################
|
|
295
|
+
class _SEC_WINNT_AUTH_IDENTITY(Structure):
|
|
296
|
+
_fields_ = [
|
|
297
|
+
("User", POINTER(c_ushort)),
|
|
298
|
+
("UserLength", c_ulong),
|
|
299
|
+
("Domain", POINTER(c_ushort)),
|
|
300
|
+
("DomainLength", c_ulong),
|
|
301
|
+
("Password", POINTER(c_ushort)),
|
|
302
|
+
("PasswordLength", c_ulong),
|
|
303
|
+
("Flags", c_ulong),
|
|
304
|
+
]
|
|
305
|
+
|
|
306
|
+
|
|
307
|
+
SEC_WINNT_AUTH_IDENTITY = _SEC_WINNT_AUTH_IDENTITY
|
|
308
|
+
|
|
309
|
+
|
|
310
|
+
class _SOLE_AUTHENTICATION_INFO(Structure):
|
|
311
|
+
_fields_ = [
|
|
312
|
+
("dwAuthnSvc", c_ulong),
|
|
313
|
+
("dwAuthzSvc", c_ulong),
|
|
314
|
+
("pAuthInfo", POINTER(_SEC_WINNT_AUTH_IDENTITY)),
|
|
315
|
+
]
|
|
316
|
+
|
|
317
|
+
|
|
318
|
+
SOLE_AUTHENTICATION_INFO = _SOLE_AUTHENTICATION_INFO
|
|
319
|
+
|
|
320
|
+
|
|
321
|
+
class _SOLE_AUTHENTICATION_LIST(Structure):
|
|
322
|
+
_fields_ = [
|
|
323
|
+
("cAuthInfo", c_ulong),
|
|
324
|
+
("pAuthInfo", POINTER(_SOLE_AUTHENTICATION_INFO)),
|
|
325
|
+
]
|
|
326
|
+
|
|
327
|
+
|
|
328
|
+
SOLE_AUTHENTICATION_LIST = _SOLE_AUTHENTICATION_LIST
|
|
329
|
+
|
|
330
|
+
|
|
331
|
+
@overload
|
|
332
|
+
def CoCreateInstanceEx(
|
|
333
|
+
clsid: GUID,
|
|
334
|
+
interface: None = None,
|
|
335
|
+
clsctx: Optional[int] = None,
|
|
336
|
+
machine: Optional[str] = None,
|
|
337
|
+
pServerInfo: Optional[COSERVERINFO] = None,
|
|
338
|
+
) -> IUnknown:
|
|
339
|
+
...
|
|
340
|
+
|
|
341
|
+
|
|
342
|
+
@overload
|
|
343
|
+
def CoCreateInstanceEx(
|
|
344
|
+
clsid: GUID,
|
|
345
|
+
interface: Type[_T_IUnknown],
|
|
346
|
+
clsctx: Optional[int] = None,
|
|
347
|
+
machine: Optional[str] = None,
|
|
348
|
+
pServerInfo: Optional[COSERVERINFO] = None,
|
|
349
|
+
) -> _T_IUnknown:
|
|
350
|
+
...
|
|
351
|
+
|
|
352
|
+
|
|
353
|
+
def CoCreateInstanceEx(
|
|
354
|
+
clsid: GUID,
|
|
355
|
+
interface: Optional[Type[IUnknown]] = None,
|
|
356
|
+
clsctx: Optional[int] = None,
|
|
357
|
+
machine: Optional[str] = None,
|
|
358
|
+
pServerInfo: Optional[COSERVERINFO] = None,
|
|
359
|
+
) -> IUnknown:
|
|
360
|
+
"""The basic windows api to create a COM class object and return a
|
|
361
|
+
pointer to an interface, possibly on another machine.
|
|
362
|
+
|
|
363
|
+
Passing both "machine" and "pServerInfo" results in a ValueError.
|
|
364
|
+
|
|
365
|
+
"""
|
|
366
|
+
if clsctx is None:
|
|
367
|
+
clsctx = CLSCTX_LOCAL_SERVER | CLSCTX_REMOTE_SERVER
|
|
368
|
+
|
|
369
|
+
if pServerInfo is not None:
|
|
370
|
+
if machine is not None:
|
|
371
|
+
msg = "Can not specify both machine name and server info"
|
|
372
|
+
raise ValueError(msg)
|
|
373
|
+
elif machine is not None:
|
|
374
|
+
serverinfo = COSERVERINFO()
|
|
375
|
+
serverinfo.pwszName = machine
|
|
376
|
+
pServerInfo = byref(serverinfo) # type: ignore
|
|
377
|
+
|
|
378
|
+
if interface is None:
|
|
379
|
+
interface = IUnknown
|
|
380
|
+
multiqi = MULTI_QI()
|
|
381
|
+
multiqi.pIID = pointer(interface._iid_) # type: ignore
|
|
382
|
+
_ole32.CoCreateInstanceEx(
|
|
383
|
+
byref(clsid), None, clsctx, pServerInfo, 1, byref(multiqi)
|
|
384
|
+
)
|
|
385
|
+
return cast(multiqi.pItf, POINTER(interface)) # type: ignore
|