comtypes 1.4.9__zip → 1.4.11__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.9 → comtypes-1.4.11}/CHANGES.txt +41 -0
- {comtypes-1.4.9/comtypes.egg-info → comtypes-1.4.11}/PKG-INFO +4 -2
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/GUID.py +34 -13
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/__init__.py +25 -16
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/_comobject.py +92 -39
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/_memberspec.py +112 -78
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/_meta.py +2 -1
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/_post_coinit/_cominterface_meta_patcher.py +3 -6
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/_post_coinit/bstr.py +12 -5
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/_post_coinit/instancemethod.py +1 -2
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/_post_coinit/misc.py +59 -24
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/_post_coinit/unknwn.py +30 -25
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/_safearray.py +2 -2
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/_vtbl.py +52 -55
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/automation.py +19 -14
- comtypes-1.4.11/comtypes/client/__init__.py +42 -0
- comtypes-1.4.11/comtypes/client/_activeobj.py +46 -0
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/client/_code_cache.py +15 -24
- comtypes-1.4.11/comtypes/client/_create.py +147 -0
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/client/_events.py +140 -57
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/client/_generate.py +3 -5
- comtypes-1.4.11/comtypes/client/_managing.py +114 -0
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/client/dynamic.py +2 -3
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/client/lazybind.py +10 -11
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/connectionpoints.py +38 -3
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/errorinfo.py +72 -21
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/git.py +4 -3
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/hints.pyi +15 -2
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/hresult.py +16 -6
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/logutil.py +15 -3
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/messageloop.py +15 -13
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/persist.py +3 -5
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/safearray.py +8 -6
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/server/__init__.py +22 -4
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/server/automation.py +1 -2
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/server/connectionpoints.py +71 -70
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/server/inprocserver.py +14 -8
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/server/localserver.py +28 -16
- comtypes-1.4.11/comtypes/server/register.py +478 -0
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/shelllink.py +13 -7
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/stream.py +7 -4
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/TestComServer.py +6 -7
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/TestDispServer.py +4 -2
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/__init__.py +1 -1
- comtypes-1.4.11/comtypes/test/find_memleak.py +72 -0
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/runtests.py +1 -0
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/setup.py +2 -1
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_BSTR.py +7 -17
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_GUID.py +7 -7
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_QueryService.py +1 -0
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_agilent.py +4 -3
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_basic.py +18 -9
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_clear_cache.py +1 -1
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_client.py +2 -2
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_client_dynamic.py +2 -2
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_client_regenerate_modules.py +2 -2
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_collections.py +7 -4
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_comobject.py +22 -9
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_comserver.py +56 -3
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_dict.py +2 -1
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_dispifc_records.py +1 -1
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_dispifc_safearrays.py +1 -1
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_dyndispatch.py +5 -2
- comtypes-1.4.11/comtypes/test/test_errorinfo.py +115 -0
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_findgendir.py +1 -2
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_getactiveobj.py +4 -4
- comtypes-1.4.11/comtypes/test/test_hresult.py +48 -0
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_ie.py +19 -6
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_ienum.py +2 -2
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_imfattributes.py +13 -3
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_inout_args.py +10 -3
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_midl_safearray_create.py +6 -4
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_monikers.py +23 -9
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_msscript.py +2 -1
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_npsupport.py +4 -4
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_outparam.py +22 -6
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_persist.py +2 -4
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_recordinfo.py +1 -1
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_safearray.py +2 -1
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_sapi.py +4 -1
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_server_register.py +114 -125
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_shelllink.py +2 -3
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_storage.py +12 -6
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_stream.py +16 -5
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_subinterface.py +4 -2
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_typeannotator.py +1 -2
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_typeinfo.py +36 -7
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_urlhistory.py +7 -4
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_variant.py +5 -3
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_w_getopt.py +4 -4
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_word.py +1 -1
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/tools/codegenerator/codegenerator.py +167 -435
- comtypes-1.4.11/comtypes/tools/codegenerator/comments.py +79 -0
- comtypes-1.4.11/comtypes/tools/codegenerator/heads.py +192 -0
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/tools/codegenerator/helpers.py +3 -6
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/tools/codegenerator/namespaces.py +13 -5
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/tools/codegenerator/typeannotator.py +13 -3
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/tools/tlbparser.py +25 -25
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/tools/typedesc.py +3 -2
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/tools/typedesc_base.py +2 -2
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/typeinfo.py +163 -51
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/viewobject.py +2 -4
- {comtypes-1.4.9 → comtypes-1.4.11/comtypes.egg-info}/PKG-INFO +4 -2
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes.egg-info/SOURCES.txt +7 -0
- {comtypes-1.4.9 → comtypes-1.4.11}/pyproject.toml +10 -23
- comtypes-1.4.9/comtypes/client/__init__.py +0 -323
- comtypes-1.4.9/comtypes/server/register.py +0 -419
- comtypes-1.4.9/comtypes/test/find_memleak.py +0 -76
- {comtypes-1.4.9 → comtypes-1.4.11}/LICENSE.txt +0 -0
- {comtypes-1.4.9 → comtypes-1.4.11}/MANIFEST.in +0 -0
- {comtypes-1.4.9 → comtypes-1.4.11}/README.md +0 -0
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/_npsupport.py +0 -0
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/_post_coinit/__init__.py +0 -0
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/_tlib_version_checker.py +0 -0
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/clear_cache.py +0 -0
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/client/_constants.py +0 -0
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/patcher.py +0 -0
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/server/w_getopt.py +0 -0
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/TestComServer.idl +0 -0
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/TestComServer.tlb +0 -0
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/TestDispServer.idl +0 -0
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/TestDispServer.tlb +0 -0
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/mylib.idl +0 -0
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/mylib.tlb +0 -0
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/mytypelib.idl +0 -0
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_DISPPARAMS.py +0 -0
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_avmc.py +0 -0
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_casesensitivity.py +0 -0
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_createwrappers.py +0 -0
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_dispinterface.py +0 -0
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_excel.py +0 -0
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_jscript.js +0 -0
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_pump_events.py +0 -0
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_server.py +0 -0
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_showevents.py +0 -0
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_win32com_interop.py +0 -0
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/test_wmi.py +0 -0
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/test/urlhist.tlb +0 -0
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/tools/__init__.py +0 -0
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/tools/codegenerator/__init__.py +0 -0
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/tools/codegenerator/modulenamer.py +0 -0
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/tools/codegenerator/packing.py +0 -0
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes/util.py +0 -0
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes.egg-info/dependency_links.txt +0 -0
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes.egg-info/entry_points.txt +0 -0
- {comtypes-1.4.9 → comtypes-1.4.11}/comtypes.egg-info/top_level.txt +0 -0
- {comtypes-1.4.9 → comtypes-1.4.11}/setup.cfg +0 -0
- {comtypes-1.4.9 → comtypes-1.4.11}/setup.py +0 -0
|
@@ -1,6 +1,15 @@
|
|
|
1
|
-
import
|
|
2
|
-
from
|
|
3
|
-
from
|
|
1
|
+
from ctypes import POINTER, Structure, c_ulong
|
|
2
|
+
from typing import TYPE_CHECKING, Tuple
|
|
3
|
+
from typing import Union as _UnionT
|
|
4
|
+
|
|
5
|
+
from comtypes import COMMETHOD, GUID, HRESULT, IUnknown
|
|
6
|
+
|
|
7
|
+
if TYPE_CHECKING:
|
|
8
|
+
from ctypes import _CArgObject, _Pointer
|
|
9
|
+
|
|
10
|
+
from comtypes import hints # noqa # type: ignore
|
|
11
|
+
|
|
12
|
+
REFIID = _UnionT[_Pointer[GUID], _CArgObject]
|
|
4
13
|
|
|
5
14
|
_GUID = GUID
|
|
6
15
|
|
|
@@ -21,16 +30,35 @@ class IConnectionPointContainer(IUnknown):
|
|
|
21
30
|
_iid_ = GUID("{B196B284-BAB4-101A-B69C-00AA00341D07}")
|
|
22
31
|
_idlflags_ = []
|
|
23
32
|
|
|
33
|
+
if TYPE_CHECKING:
|
|
34
|
+
|
|
35
|
+
def EnumConnectionPoints(self) -> "IEnumConnectionPoints": ...
|
|
36
|
+
def FindConnectionPoint(self, riid: REFIID) -> "IConnectionPoint": ...
|
|
37
|
+
|
|
24
38
|
|
|
25
39
|
class IConnectionPoint(IUnknown):
|
|
26
40
|
_iid_ = GUID("{B196B286-BAB4-101A-B69C-00AA00341D07}")
|
|
27
41
|
_idlflags_ = []
|
|
28
42
|
|
|
43
|
+
if TYPE_CHECKING:
|
|
44
|
+
|
|
45
|
+
def GetConnectionPointContainer(self) -> IConnectionPointContainer: ...
|
|
46
|
+
def Advise(self, pUnkSink: IUnknown) -> int: ...
|
|
47
|
+
def Unadvise(self, dwCookie: int) -> hints.Hresult: ...
|
|
48
|
+
def EnumConnections(self) -> "IEnumConnections": ...
|
|
49
|
+
|
|
29
50
|
|
|
30
51
|
class IEnumConnections(IUnknown):
|
|
31
52
|
_iid_ = GUID("{B196B287-BAB4-101A-B69C-00AA00341D07}")
|
|
32
53
|
_idlflags_ = []
|
|
33
54
|
|
|
55
|
+
if TYPE_CHECKING:
|
|
56
|
+
|
|
57
|
+
def Next(self, cConnections: int) -> Tuple[tagCONNECTDATA, int]: ...
|
|
58
|
+
def Skip(self, cConnections: int) -> hints.Hresult: ...
|
|
59
|
+
def Reset(self) -> hints.Hresult: ...
|
|
60
|
+
def Clone(self) -> "IEnumConnections": ...
|
|
61
|
+
|
|
34
62
|
def __iter__(self):
|
|
35
63
|
return self
|
|
36
64
|
|
|
@@ -45,6 +73,13 @@ class IEnumConnectionPoints(IUnknown):
|
|
|
45
73
|
_iid_ = GUID("{B196B285-BAB4-101A-B69C-00AA00341D07}")
|
|
46
74
|
_idlflags_ = []
|
|
47
75
|
|
|
76
|
+
if TYPE_CHECKING:
|
|
77
|
+
|
|
78
|
+
def Next(self, cConnections: int) -> Tuple[IConnectionPoint, int]: ...
|
|
79
|
+
def Skip(self, cConnections: int) -> hints.Hresult: ...
|
|
80
|
+
def Reset(self) -> hints.Hresult: ...
|
|
81
|
+
def Clone(self) -> "IEnumConnectionPoints": ...
|
|
82
|
+
|
|
48
83
|
def __iter__(self):
|
|
49
84
|
return self
|
|
50
85
|
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import sys
|
|
2
|
-
from ctypes import
|
|
3
|
-
from ctypes.wintypes import DWORD
|
|
4
|
-
from
|
|
5
|
-
from
|
|
2
|
+
from ctypes import POINTER, OleDLL, byref, c_wchar_p
|
|
3
|
+
from ctypes.wintypes import DWORD, ULONG
|
|
4
|
+
from typing import TYPE_CHECKING, Optional
|
|
5
|
+
from typing import Union as _UnionT
|
|
6
|
+
|
|
7
|
+
from comtypes import BSTR, COMMETHOD, GUID, HRESULT, IUnknown
|
|
8
|
+
from comtypes.hresult import DISP_E_EXCEPTION, S_OK
|
|
9
|
+
|
|
10
|
+
if TYPE_CHECKING:
|
|
11
|
+
from comtypes import hints # type: ignore
|
|
6
12
|
|
|
7
13
|
LPCOLESTR = c_wchar_p
|
|
8
14
|
|
|
@@ -16,6 +22,13 @@ class ICreateErrorInfo(IUnknown):
|
|
|
16
22
|
COMMETHOD([], HRESULT, "SetHelpFile", (["in"], LPCOLESTR, "szHelpFile")),
|
|
17
23
|
COMMETHOD([], HRESULT, "SetHelpContext", (["in"], DWORD, "dwHelpContext")),
|
|
18
24
|
]
|
|
25
|
+
if TYPE_CHECKING:
|
|
26
|
+
|
|
27
|
+
def SetGUID(self, rguid: GUID) -> hints.Hresult: ...
|
|
28
|
+
def SetSource(self, szSource: str) -> hints.Hresult: ...
|
|
29
|
+
def SetDescription(self, szDescription: str) -> hints.Hresult: ...
|
|
30
|
+
def SetHelpFile(self, szHelpFile: str) -> hints.Hresult: ...
|
|
31
|
+
def SetHelpContext(self, dwHelpContext: int) -> hints.Hresult: ...
|
|
19
32
|
|
|
20
33
|
|
|
21
34
|
class IErrorInfo(IUnknown):
|
|
@@ -33,6 +46,13 @@ class IErrorInfo(IUnknown):
|
|
|
33
46
|
[], HRESULT, "GetHelpContext", (["out"], POINTER(DWORD), "pdwHelpContext")
|
|
34
47
|
),
|
|
35
48
|
]
|
|
49
|
+
if TYPE_CHECKING:
|
|
50
|
+
|
|
51
|
+
def GetGUID(self) -> GUID: ...
|
|
52
|
+
def GetSource(self) -> str: ...
|
|
53
|
+
def GetDescription(self) -> str: ...
|
|
54
|
+
def GetHelpFile(self) -> str: ...
|
|
55
|
+
def GetHelpContext(self) -> int: ...
|
|
36
56
|
|
|
37
57
|
|
|
38
58
|
class ISupportErrorInfo(IUnknown):
|
|
@@ -42,34 +62,57 @@ class ISupportErrorInfo(IUnknown):
|
|
|
42
62
|
[], HRESULT, "InterfaceSupportsErrorInfo", (["in"], POINTER(GUID), "riid")
|
|
43
63
|
)
|
|
44
64
|
]
|
|
65
|
+
if TYPE_CHECKING:
|
|
66
|
+
|
|
67
|
+
def InterfaceSupportsErrorInfo(self, riid: GUID) -> hints.Hresult: ...
|
|
45
68
|
|
|
46
69
|
|
|
47
70
|
################################################################
|
|
48
|
-
_oleaut32 =
|
|
71
|
+
_oleaut32 = OleDLL("oleaut32")
|
|
72
|
+
|
|
73
|
+
_CreateErrorInfo = _oleaut32.CreateErrorInfo
|
|
74
|
+
_CreateErrorInfo.argtypes = [POINTER(POINTER(ICreateErrorInfo))]
|
|
75
|
+
_CreateErrorInfo.restype = HRESULT
|
|
76
|
+
|
|
77
|
+
_GetErrorInfo = _oleaut32.GetErrorInfo
|
|
78
|
+
_GetErrorInfo.argtypes = [ULONG, POINTER(POINTER(IErrorInfo))]
|
|
79
|
+
_GetErrorInfo.restype = HRESULT
|
|
80
|
+
|
|
81
|
+
_SetErrorInfo = _oleaut32.SetErrorInfo
|
|
82
|
+
_SetErrorInfo.argtypes = [ULONG, POINTER(IErrorInfo)]
|
|
83
|
+
_SetErrorInfo.restype = HRESULT
|
|
49
84
|
|
|
50
85
|
|
|
51
|
-
def CreateErrorInfo():
|
|
86
|
+
def CreateErrorInfo() -> ICreateErrorInfo:
|
|
87
|
+
"""Creates an instance of a generic error object."""
|
|
52
88
|
cei = POINTER(ICreateErrorInfo)()
|
|
53
|
-
|
|
54
|
-
return cei
|
|
89
|
+
_CreateErrorInfo(byref(cei))
|
|
90
|
+
return cei # type: ignore
|
|
55
91
|
|
|
56
92
|
|
|
57
|
-
def GetErrorInfo():
|
|
93
|
+
def GetErrorInfo() -> Optional[IErrorInfo]:
|
|
58
94
|
"""Get the error information for the current thread."""
|
|
59
95
|
errinfo = POINTER(IErrorInfo)()
|
|
60
|
-
if S_OK ==
|
|
61
|
-
return errinfo
|
|
96
|
+
if S_OK == _GetErrorInfo(0, byref(errinfo)):
|
|
97
|
+
return errinfo # type: ignore
|
|
62
98
|
return None
|
|
63
99
|
|
|
64
100
|
|
|
65
|
-
def SetErrorInfo(errinfo):
|
|
101
|
+
def SetErrorInfo(errinfo: _UnionT[IErrorInfo, ICreateErrorInfo]) -> "hints.Hresult":
|
|
66
102
|
"""Set error information for the current thread."""
|
|
67
|
-
|
|
103
|
+
# ICreateErrorInfo can QueryInterface with IErrorInfo, so both types are
|
|
104
|
+
# accepted, thanks to the magic of from_param.
|
|
105
|
+
return _SetErrorInfo(0, errinfo)
|
|
68
106
|
|
|
69
107
|
|
|
70
108
|
def ReportError(
|
|
71
|
-
text
|
|
72
|
-
|
|
109
|
+
text: str,
|
|
110
|
+
iid: GUID,
|
|
111
|
+
clsid: _UnionT[None, str, GUID] = None,
|
|
112
|
+
helpfile: Optional[str] = None,
|
|
113
|
+
helpcontext: Optional[int] = 0,
|
|
114
|
+
hresult: int = DISP_E_EXCEPTION,
|
|
115
|
+
) -> int:
|
|
73
116
|
"""Report a COM error. Returns the passed in hresult value."""
|
|
74
117
|
ei = CreateErrorInfo()
|
|
75
118
|
ei.SetDescription(text)
|
|
@@ -86,21 +129,29 @@ def ReportError(
|
|
|
86
129
|
except WindowsError:
|
|
87
130
|
pass
|
|
88
131
|
else:
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
_oleaut32.SetErrorInfo(0, ei)
|
|
132
|
+
# progid for the class or application that created the error
|
|
133
|
+
ei.SetSource(progid)
|
|
134
|
+
SetErrorInfo(ei)
|
|
93
135
|
return hresult
|
|
94
136
|
|
|
95
137
|
|
|
96
138
|
def ReportException(
|
|
97
|
-
hresult
|
|
98
|
-
|
|
139
|
+
hresult: int,
|
|
140
|
+
iid: GUID,
|
|
141
|
+
clsid: _UnionT[None, str, GUID] = None,
|
|
142
|
+
helpfile: Optional[str] = None,
|
|
143
|
+
helpcontext: Optional[int] = None,
|
|
144
|
+
stacklevel: Optional[int] = None,
|
|
145
|
+
) -> int:
|
|
99
146
|
"""Report a COM exception. Returns the passed in hresult value."""
|
|
100
147
|
typ, value, tb = sys.exc_info()
|
|
101
148
|
if stacklevel is not None:
|
|
102
149
|
for _ in range(stacklevel):
|
|
150
|
+
if tb is None:
|
|
151
|
+
raise ValueError("'stacklevel' exceeds the available depth.")
|
|
103
152
|
tb = tb.tb_next
|
|
153
|
+
if tb is None:
|
|
154
|
+
raise ValueError("'stacklevel' is specified, but no error information.")
|
|
104
155
|
line = tb.tb_frame.f_lineno
|
|
105
156
|
name = tb.tb_frame.f_globals["__name__"]
|
|
106
157
|
text = f"{typ}: {value} ({name}, line {line:d})"
|
|
@@ -6,14 +6,15 @@ between different threading appartments.
|
|
|
6
6
|
|
|
7
7
|
from ctypes import *
|
|
8
8
|
from ctypes.wintypes import DWORD
|
|
9
|
+
|
|
9
10
|
from comtypes import (
|
|
10
|
-
|
|
11
|
-
STDMETHOD,
|
|
11
|
+
CLSCTX_INPROC_SERVER,
|
|
12
12
|
COMMETHOD,
|
|
13
13
|
GUID,
|
|
14
14
|
HRESULT,
|
|
15
|
+
STDMETHOD,
|
|
15
16
|
CoCreateInstance,
|
|
16
|
-
|
|
17
|
+
IUnknown,
|
|
17
18
|
)
|
|
18
19
|
|
|
19
20
|
|
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
# - utilities for type hints.
|
|
4
4
|
import ctypes
|
|
5
5
|
import sys
|
|
6
|
+
from ctypes import _CData, _CDataType
|
|
6
7
|
from typing import Any as Any, ClassVar, Generic, NoReturn, Protocol, TypeVar, overload
|
|
7
8
|
from typing import Optional, Union as _UnionT
|
|
8
|
-
from typing import Tuple as Tuple, Type
|
|
9
|
+
from typing import List, Tuple as Tuple, Type
|
|
9
10
|
from typing import Callable, Iterator, Sequence
|
|
10
11
|
|
|
11
12
|
if sys.version_info >= (3, 9):
|
|
@@ -20,8 +21,10 @@ else:
|
|
|
20
21
|
from typing_extensions import TypeGuard as TypeGuard
|
|
21
22
|
if sys.version_info >= (3, 11):
|
|
22
23
|
from typing import Self as Self
|
|
24
|
+
from typing import Unpack as Unpack
|
|
23
25
|
else:
|
|
24
26
|
from typing_extensions import Self as Self
|
|
27
|
+
from typing_extensions import Unpack as Unpack
|
|
25
28
|
|
|
26
29
|
import comtypes
|
|
27
30
|
from comtypes import IUnknown as IUnknown, COMObject as COMObject, GUID as GUID
|
|
@@ -41,7 +44,10 @@ Hresult: TypeAlias = int
|
|
|
41
44
|
arguments and with `HRESULT` as its return type in its COM method definition.
|
|
42
45
|
"""
|
|
43
46
|
|
|
44
|
-
|
|
47
|
+
LP_LP_Vtbl: TypeAlias = ctypes._Pointer[ctypes._Pointer[ctypes.Structure]]
|
|
48
|
+
"""A pointer to a pointer to a virtual function table."""
|
|
49
|
+
|
|
50
|
+
_CT = TypeVar("_CT", bound=_CData)
|
|
45
51
|
_T_IUnknown = TypeVar("_T_IUnknown", bound=IUnknown)
|
|
46
52
|
_T_Struct = TypeVar("_T_Struct", bound=ctypes.Structure)
|
|
47
53
|
|
|
@@ -285,3 +291,10 @@ def to_dunder_setitem(
|
|
|
285
291
|
) -> Callable[Concatenate[_T_Inst, _P_Set], Any]: ...
|
|
286
292
|
@overload
|
|
287
293
|
def to_dunder_setitem(item: Any) -> Callable[..., NoReturn]: ...
|
|
294
|
+
|
|
295
|
+
_PosParamFlagType: TypeAlias = Tuple[int, Optional[str]]
|
|
296
|
+
_OptParamFlagType: TypeAlias = Tuple[int, Optional[str], Any]
|
|
297
|
+
ParamFlagType: TypeAlias = _UnionT[_PosParamFlagType, _OptParamFlagType]
|
|
298
|
+
_PosArgSpecElmType: TypeAlias = Tuple[List[str], Type[_CDataType], str]
|
|
299
|
+
_OptArgSpecElmType: TypeAlias = Tuple[List[str], Type[_CDataType], str, Any]
|
|
300
|
+
ArgSpecElmType: TypeAlias = _UnionT[_PosArgSpecElmType, _OptArgSpecElmType]
|
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
#
|
|
4
4
|
# Note that the codes should be written in decimal notation!
|
|
5
5
|
|
|
6
|
+
from ctypes import c_long
|
|
7
|
+
|
|
6
8
|
S_OK = 0
|
|
7
9
|
S_FALSE = 1
|
|
8
10
|
|
|
@@ -53,13 +55,15 @@ DISP_E_UNKNOWNINTERFACE = -2147352575 # 0x80020001
|
|
|
53
55
|
RPC_E_CHANGED_MODE = -2147417850 # 0x80010106
|
|
54
56
|
RPC_E_SERVERFAULT = -2147417851 # 0x80010105
|
|
55
57
|
|
|
58
|
+
RPC_E_NO_SYNC = -2147417824 # 0x80010120
|
|
59
|
+
RPC_S_CALLPENDING = -2147417835 # 0x80010115
|
|
60
|
+
|
|
56
61
|
# 'macros' and constants to create your own HRESULT values:
|
|
57
62
|
|
|
58
63
|
|
|
59
|
-
def MAKE_HRESULT(sev, fac, code):
|
|
64
|
+
def MAKE_HRESULT(sev: int, fac: int, code: int) -> int:
|
|
65
|
+
"""Creates an HRESULT value from its component pieces."""
|
|
60
66
|
# A hresult is SIGNED in comtypes
|
|
61
|
-
from ctypes import c_long
|
|
62
|
-
|
|
63
67
|
return c_long((sev << 31 | fac << 16 | code)).value
|
|
64
68
|
|
|
65
69
|
|
|
@@ -70,12 +74,18 @@ FACILITY_ITF = 4
|
|
|
70
74
|
FACILITY_WIN32 = 7
|
|
71
75
|
|
|
72
76
|
|
|
73
|
-
def HRESULT_FROM_WIN32(x):
|
|
77
|
+
def HRESULT_FROM_WIN32(x: int) -> int:
|
|
78
|
+
"""Converts a system error code to an HRESULT value."""
|
|
74
79
|
# make signed
|
|
75
|
-
from ctypes import c_long
|
|
76
|
-
|
|
77
80
|
x = c_long(x).value
|
|
78
81
|
if x < 0:
|
|
79
82
|
return x
|
|
80
83
|
# 0x80000000 | FACILITY_WIN32 << 16 | x & 0xFFFF
|
|
81
84
|
return c_long(0x80070000 | (x & 0xFFFF)).value
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
# Win32 error codes are defined as unsigned 32-bit integers. However, to
|
|
88
|
+
# ensure compatibility with COM and other HRESULT-based APIs, Windows converts
|
|
89
|
+
# them into HRESULT values by setting the high bit, ensuring a consistent way
|
|
90
|
+
# to indicate failure across these APIs.
|
|
91
|
+
RPC_S_SERVER_UNAVAILABLE = -2147023174 # 0x800706BA (WIN32: 1722 0x6BA)
|
|
@@ -1,13 +1,25 @@
|
|
|
1
1
|
# logutil.py
|
|
2
|
-
import logging
|
|
2
|
+
import logging
|
|
3
|
+
from ctypes import WinDLL
|
|
4
|
+
from ctypes.wintypes import LPCSTR, LPCWSTR
|
|
5
|
+
|
|
6
|
+
_kernel32 = WinDLL("kernel32")
|
|
7
|
+
|
|
8
|
+
_OutputDebugStringA = _kernel32.OutputDebugStringA
|
|
9
|
+
_OutputDebugStringA.argtypes = [LPCSTR]
|
|
10
|
+
_OutputDebugStringA.restype = None
|
|
11
|
+
|
|
12
|
+
_OutputDebugStringW = _kernel32.OutputDebugStringW
|
|
13
|
+
_OutputDebugStringW.argtypes = [LPCWSTR]
|
|
14
|
+
_OutputDebugStringW.restype = None
|
|
3
15
|
|
|
4
16
|
|
|
5
17
|
class NTDebugHandler(logging.Handler):
|
|
6
18
|
def emit(
|
|
7
19
|
self,
|
|
8
20
|
record,
|
|
9
|
-
writeA=
|
|
10
|
-
writeW=
|
|
21
|
+
writeA=_OutputDebugStringA,
|
|
22
|
+
writeW=_OutputDebugStringW,
|
|
11
23
|
):
|
|
12
24
|
text = self.format(record)
|
|
13
25
|
if isinstance(text, str):
|
|
@@ -1,31 +1,33 @@
|
|
|
1
1
|
import ctypes
|
|
2
|
-
from ctypes import WinDLL,
|
|
2
|
+
from ctypes import WinDLL, WinError, byref
|
|
3
3
|
from ctypes.wintypes import MSG
|
|
4
|
+
from typing import TYPE_CHECKING, List, SupportsIndex
|
|
5
|
+
|
|
6
|
+
if TYPE_CHECKING:
|
|
7
|
+
from ctypes import _CArgObject
|
|
8
|
+
from typing import Any, Callable, Iterable
|
|
9
|
+
|
|
10
|
+
_FilterCallable = Callable[["_CArgObject"], Iterable[Any]] # type: ignore
|
|
4
11
|
|
|
5
12
|
_user32 = WinDLL("user32")
|
|
6
13
|
|
|
7
14
|
GetMessage = _user32.GetMessageA
|
|
8
|
-
GetMessage.argtypes = [
|
|
9
|
-
ctypes.c_void_p,
|
|
10
|
-
ctypes.c_void_p,
|
|
11
|
-
ctypes.c_uint,
|
|
12
|
-
ctypes.c_uint,
|
|
13
|
-
]
|
|
15
|
+
GetMessage.argtypes = [ctypes.c_void_p, ctypes.c_void_p, ctypes.c_uint, ctypes.c_uint]
|
|
14
16
|
TranslateMessage = _user32.TranslateMessage
|
|
15
17
|
DispatchMessage = _user32.DispatchMessageA
|
|
16
18
|
|
|
17
19
|
|
|
18
20
|
class _MessageLoop(object):
|
|
19
|
-
def __init__(self):
|
|
20
|
-
self._filters = []
|
|
21
|
+
def __init__(self) -> None:
|
|
22
|
+
self._filters: List["_FilterCallable"] = []
|
|
21
23
|
|
|
22
|
-
def insert_filter(self, obj, index
|
|
24
|
+
def insert_filter(self, obj: "_FilterCallable", index: SupportsIndex = -1) -> None:
|
|
23
25
|
self._filters.insert(index, obj)
|
|
24
26
|
|
|
25
|
-
def remove_filter(self, obj):
|
|
27
|
+
def remove_filter(self, obj: "_FilterCallable") -> None:
|
|
26
28
|
self._filters.remove(obj)
|
|
27
29
|
|
|
28
|
-
def run(self):
|
|
30
|
+
def run(self) -> None:
|
|
29
31
|
msg = MSG()
|
|
30
32
|
lpmsg = byref(msg)
|
|
31
33
|
while 1:
|
|
@@ -38,7 +40,7 @@ class _MessageLoop(object):
|
|
|
38
40
|
TranslateMessage(lpmsg)
|
|
39
41
|
DispatchMessage(lpmsg)
|
|
40
42
|
|
|
41
|
-
def filter_message(self, lpmsg):
|
|
43
|
+
def filter_message(self, lpmsg: "_CArgObject") -> bool:
|
|
42
44
|
return any(list(filter(lpmsg)) for filter in self._filters)
|
|
43
45
|
|
|
44
46
|
|
|
@@ -10,13 +10,11 @@ The 'DictPropertyBag' class is a class implementing the IPropertyBag
|
|
|
10
10
|
interface, useful in client code.
|
|
11
11
|
"""
|
|
12
12
|
|
|
13
|
-
from ctypes import c_int, c_ulong, c_ushort, c_wchar_p
|
|
14
|
-
from ctypes import
|
|
15
|
-
from ctypes.wintypes import WORD, DWORD, BOOL
|
|
13
|
+
from ctypes import POINTER, Structure, c_int, c_ulong, c_ushort, c_wchar_p
|
|
14
|
+
from ctypes.wintypes import BOOL, DWORD, WORD
|
|
16
15
|
from typing import TYPE_CHECKING
|
|
17
16
|
|
|
18
|
-
from comtypes import GUID,
|
|
19
|
-
from comtypes import IPersist
|
|
17
|
+
from comtypes import COMMETHOD, GUID, HRESULT, IPersist, IUnknown
|
|
20
18
|
from comtypes.automation import VARIANT, tagEXCEPINFO
|
|
21
19
|
|
|
22
20
|
if TYPE_CHECKING:
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import threading
|
|
2
1
|
import array
|
|
2
|
+
import threading
|
|
3
|
+
from ctypes import POINTER, Structure, byref, c_long, cast, memmove, pointer, sizeof
|
|
3
4
|
from typing import TYPE_CHECKING
|
|
5
|
+
|
|
4
6
|
import comtypes
|
|
5
|
-
from
|
|
6
|
-
from comtypes import _safearray, IUnknown, com_interface_registry
|
|
7
|
+
from comtypes import IUnknown, _safearray, com_interface_registry
|
|
7
8
|
from comtypes.patcher import Patch
|
|
8
9
|
|
|
9
10
|
if TYPE_CHECKING:
|
|
10
11
|
from typing import Type, TypeVar
|
|
12
|
+
|
|
11
13
|
from comtypes import hints # type: ignore
|
|
12
14
|
|
|
13
15
|
_CT = TypeVar("_CT", bound=comtypes._CData)
|
|
@@ -73,12 +75,12 @@ def _midlSAFEARRAY(itemtype: "Type[_CT]") -> "Type[hints.LP_SAFEARRAY[_CT]]":
|
|
|
73
75
|
def _make_safearray_type(itemtype):
|
|
74
76
|
# Create and return a subclass of tagSAFEARRAY
|
|
75
77
|
from comtypes.automation import (
|
|
76
|
-
|
|
78
|
+
VT_DISPATCH,
|
|
79
|
+
VT_HRESULT,
|
|
77
80
|
VT_RECORD,
|
|
78
81
|
VT_UNKNOWN,
|
|
79
82
|
IDispatch,
|
|
80
|
-
|
|
81
|
-
VT_HRESULT,
|
|
83
|
+
_ctype_to_vartype,
|
|
82
84
|
)
|
|
83
85
|
|
|
84
86
|
meta = type(_safearray.tagSAFEARRAY)
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import ctypes
|
|
2
|
-
from ctypes import HRESULT, POINTER, byref
|
|
2
|
+
from ctypes import HRESULT, POINTER, OleDLL, byref, c_void_p
|
|
3
|
+
from ctypes.wintypes import DWORD, LPVOID
|
|
3
4
|
from typing import TYPE_CHECKING, Any, Optional, Type
|
|
4
5
|
|
|
5
6
|
import comtypes
|
|
@@ -7,6 +8,7 @@ import comtypes.client
|
|
|
7
8
|
import comtypes.client.dynamic
|
|
8
9
|
from comtypes import GUID, STDMETHOD, IUnknown
|
|
9
10
|
from comtypes.automation import IDispatch
|
|
11
|
+
from comtypes.GUID import REFCLSID
|
|
10
12
|
|
|
11
13
|
if TYPE_CHECKING:
|
|
12
14
|
from ctypes import _Pointer
|
|
@@ -67,7 +69,23 @@ class IClassFactory(IUnknown):
|
|
|
67
69
|
ACTIVEOBJECT_STRONG = 0x0
|
|
68
70
|
ACTIVEOBJECT_WEAK = 0x1
|
|
69
71
|
|
|
70
|
-
|
|
72
|
+
_oleaut32 = OleDLL("oleaut32")
|
|
73
|
+
|
|
74
|
+
_RegisterActiveObject = _oleaut32.RegisterActiveObject
|
|
75
|
+
_RegisterActiveObject.argtypes = [
|
|
76
|
+
c_void_p,
|
|
77
|
+
REFCLSID,
|
|
78
|
+
DWORD,
|
|
79
|
+
POINTER(DWORD),
|
|
80
|
+
]
|
|
81
|
+
_RegisterActiveObject.restype = HRESULT
|
|
82
|
+
|
|
83
|
+
_RevokeActiveObject = _oleaut32.RevokeActiveObject
|
|
84
|
+
_RevokeActiveObject.argtypes = [
|
|
85
|
+
DWORD,
|
|
86
|
+
LPVOID,
|
|
87
|
+
]
|
|
88
|
+
_RevokeActiveObject.restype = HRESULT
|
|
71
89
|
|
|
72
90
|
|
|
73
91
|
def RegisterActiveObject(comobj: comtypes.COMObject, weak: bool = True) -> int:
|
|
@@ -78,9 +96,9 @@ def RegisterActiveObject(comobj: comtypes.COMObject, weak: bool = True) -> int:
|
|
|
78
96
|
else:
|
|
79
97
|
flags = ACTIVEOBJECT_STRONG
|
|
80
98
|
handle = ctypes.c_ulong()
|
|
81
|
-
|
|
99
|
+
_RegisterActiveObject(punk, byref(clsid), flags, byref(handle))
|
|
82
100
|
return handle.value
|
|
83
101
|
|
|
84
102
|
|
|
85
103
|
def RevokeActiveObject(handle: int) -> None:
|
|
86
|
-
|
|
104
|
+
_RevokeActiveObject(handle, None)
|