comtypes 1.4.8__zip → 1.4.10__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.8 → comtypes-1.4.10}/CHANGES.txt +40 -0
- {comtypes-1.4.8/comtypes.egg-info → comtypes-1.4.10}/PKG-INFO +4 -3
- {comtypes-1.4.8 → comtypes-1.4.10}/README.md +1 -1
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/GUID.py +38 -16
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/__init__.py +36 -16
- comtypes-1.4.10/comtypes/_comobject.py +562 -0
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/_memberspec.py +93 -13
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/_meta.py +1 -0
- comtypes-1.4.10/comtypes/_post_coinit/_cominterface_meta_patcher.py +152 -0
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/_post_coinit/bstr.py +12 -5
- comtypes-1.4.8/comtypes/_py_instance_method.py → comtypes-1.4.10/comtypes/_post_coinit/instancemethod.py +1 -2
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/_post_coinit/misc.py +60 -25
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/_post_coinit/unknwn.py +26 -176
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/_safearray.py +3 -4
- comtypes-1.4.10/comtypes/_vtbl.py +448 -0
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/automation.py +46 -49
- comtypes-1.4.10/comtypes/client/__init__.py +42 -0
- comtypes-1.4.10/comtypes/client/_activeobj.py +46 -0
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/client/_code_cache.py +10 -5
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/client/_constants.py +1 -1
- comtypes-1.4.10/comtypes/client/_create.py +147 -0
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/client/_events.py +58 -13
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/client/_generate.py +7 -11
- comtypes-1.4.10/comtypes/client/_managing.py +114 -0
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/client/dynamic.py +2 -3
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/client/lazybind.py +12 -13
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/connectionpoints.py +2 -1
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/errorinfo.py +22 -9
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/git.py +5 -5
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/hints.pyi +7 -15
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/logutil.py +15 -3
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/messageloop.py +1 -1
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/persist.py +3 -5
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/safearray.py +17 -5
- comtypes-1.4.10/comtypes/server/__init__.py +104 -0
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/server/automation.py +1 -2
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/server/connectionpoints.py +5 -5
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/server/inprocserver.py +25 -17
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/server/localserver.py +49 -19
- comtypes-1.4.10/comtypes/server/register.py +478 -0
- comtypes-1.4.10/comtypes/server/w_getopt.py +48 -0
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/shelllink.py +16 -33
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/stream.py +7 -4
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/TestComServer.py +6 -7
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/TestDispServer.py +4 -2
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/__init__.py +10 -12
- comtypes-1.4.10/comtypes/test/find_memleak.py +72 -0
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/runtests.py +1 -0
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/setup.py +2 -1
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_BSTR.py +10 -23
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_GUID.py +1 -0
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_QueryService.py +1 -0
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_agilent.py +4 -3
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_avmc.py +1 -1
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_basic.py +12 -6
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_casesensitivity.py +3 -5
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_clear_cache.py +1 -1
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_client.py +2 -2
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_client_dynamic.py +2 -2
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_client_regenerate_modules.py +2 -2
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_collections.py +4 -4
- comtypes-1.4.10/comtypes/test/test_comobject.py +146 -0
- comtypes-1.4.10/comtypes/test/test_comserver.py +349 -0
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_createwrappers.py +2 -4
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_dispifc_records.py +1 -1
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_dispifc_safearrays.py +1 -1
- comtypes-1.4.10/comtypes/test/test_dispinterface.py +153 -0
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_dyndispatch.py +1 -0
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_excel.py +22 -12
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_findgendir.py +1 -2
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_getactiveobj.py +4 -4
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_ie.py +19 -9
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_ienum.py +2 -2
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_imfattributes.py +13 -3
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_inout_args.py +8 -5
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_midl_safearray_create.py +14 -4
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_monikers.py +23 -9
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_msscript.py +2 -1
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_npsupport.py +4 -4
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_outparam.py +37 -14
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_persist.py +2 -4
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_recordinfo.py +1 -1
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_safearray.py +1 -90
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_sapi.py +4 -1
- comtypes-1.4.10/comtypes/test/test_server.py +350 -0
- comtypes-1.4.10/comtypes/test/test_server_register.py +524 -0
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_shelllink.py +2 -3
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_showevents.py +7 -17
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_storage.py +12 -6
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_stream.py +16 -5
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_subinterface.py +4 -2
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_typeannotator.py +1 -2
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_typeinfo.py +19 -7
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_urlhistory.py +7 -4
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_variant.py +3 -19
- comtypes-1.4.10/comtypes/test/test_w_getopt.py +29 -0
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_win32com_interop.py +80 -36
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_wmi.py +0 -3
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_word.py +1 -1
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/tools/codegenerator/codegenerator.py +166 -440
- comtypes-1.4.10/comtypes/tools/codegenerator/comments.py +79 -0
- comtypes-1.4.10/comtypes/tools/codegenerator/heads.py +192 -0
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/tools/codegenerator/helpers.py +11 -14
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/tools/codegenerator/namespaces.py +13 -5
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/tools/codegenerator/packing.py +4 -4
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/tools/codegenerator/typeannotator.py +19 -9
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/tools/tlbparser.py +22 -23
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/tools/typedesc.py +4 -8
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/tools/typedesc_base.py +2 -2
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/typeinfo.py +159 -63
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/viewobject.py +3 -9
- {comtypes-1.4.8 → comtypes-1.4.10/comtypes.egg-info}/PKG-INFO +4 -3
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes.egg-info/SOURCES.txt +11 -3
- {comtypes-1.4.8 → comtypes-1.4.10}/pyproject.toml +12 -19
- comtypes-1.4.8/comtypes/_comobject.py +0 -833
- comtypes-1.4.8/comtypes/_idl_stuff.py +0 -67
- comtypes-1.4.8/comtypes/client/__init__.py +0 -323
- comtypes-1.4.8/comtypes/server/__init__.py +0 -70
- comtypes-1.4.8/comtypes/server/register.py +0 -431
- comtypes-1.4.8/comtypes/server/w_getopt.py +0 -75
- comtypes-1.4.8/comtypes/test/find_memleak.py +0 -76
- comtypes-1.4.8/comtypes/test/test_comserver.py +0 -239
- comtypes-1.4.8/comtypes/test/test_dispinterface.py +0 -137
- comtypes-1.4.8/comtypes/test/test_propputref.py +0 -40
- comtypes-1.4.8/comtypes/test/test_server.py +0 -354
- {comtypes-1.4.8 → comtypes-1.4.10}/LICENSE.txt +0 -0
- {comtypes-1.4.8 → comtypes-1.4.10}/MANIFEST.in +0 -0
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/_npsupport.py +0 -0
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/_post_coinit/__init__.py +0 -0
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/_tlib_version_checker.py +0 -0
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/clear_cache.py +0 -0
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/hresult.py +0 -0
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/patcher.py +0 -0
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/TestComServer.idl +0 -0
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/TestComServer.tlb +0 -0
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/TestDispServer.idl +0 -0
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/TestDispServer.tlb +0 -0
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/mylib.idl +0 -0
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/mylib.tlb +0 -0
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/mytypelib.idl +0 -0
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_DISPPARAMS.py +0 -0
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_dict.py +0 -0
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_jscript.js +0 -0
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_pump_events.py +0 -0
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/urlhist.tlb +0 -0
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/tools/__init__.py +0 -0
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/tools/codegenerator/__init__.py +0 -0
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/tools/codegenerator/modulenamer.py +0 -0
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/util.py +0 -0
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes.egg-info/dependency_links.txt +0 -0
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes.egg-info/entry_points.txt +0 -0
- {comtypes-1.4.8 → comtypes-1.4.10}/comtypes.egg-info/top_level.txt +0 -0
- {comtypes-1.4.8 → comtypes-1.4.10}/setup.cfg +0 -0
- {comtypes-1.4.8 → comtypes-1.4.10}/setup.py +0 -0
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import unittest as ut
|
|
2
|
-
from ctypes import
|
|
2
|
+
from ctypes import POINTER, Structure, WinDLL, byref, c_long, c_uint, c_ulong
|
|
3
|
+
from ctypes.wintypes import BOOL, HWND, LPLONG, UINT
|
|
3
4
|
|
|
4
|
-
import comtypes.test
|
|
5
5
|
from comtypes.client import CreateObject, GetEvents
|
|
6
6
|
|
|
7
|
-
comtypes.test.requires("ui")
|
|
8
|
-
|
|
9
7
|
|
|
10
8
|
def setUpModule():
|
|
11
9
|
raise ut.SkipTest(
|
|
@@ -61,14 +59,26 @@ class MSG(Structure):
|
|
|
61
59
|
|
|
62
60
|
|
|
63
61
|
def PumpWaitingMessages():
|
|
64
|
-
|
|
62
|
+
_user32 = WinDLL("user32")
|
|
63
|
+
|
|
64
|
+
_PeekMessageA = _user32.PeekMessageA
|
|
65
|
+
_PeekMessageA.argtypes = [POINTER(MSG), HWND, UINT, UINT, UINT]
|
|
66
|
+
_PeekMessageA.restype = BOOL
|
|
67
|
+
|
|
68
|
+
_TranslateMessage = _user32.TranslateMessage
|
|
69
|
+
_TranslateMessage.argtypes = [POINTER(MSG)]
|
|
70
|
+
_TranslateMessage.restype = BOOL
|
|
71
|
+
|
|
72
|
+
LRESULT = LPLONG
|
|
73
|
+
_DispatchMessageA = _user32.DispatchMessageA
|
|
74
|
+
_DispatchMessageA.argtypes = [POINTER(MSG)]
|
|
75
|
+
_DispatchMessageA.restype = LRESULT
|
|
65
76
|
|
|
66
|
-
user32 = windll.user32
|
|
67
77
|
msg = MSG()
|
|
68
78
|
PM_REMOVE = 0x0001
|
|
69
|
-
while
|
|
70
|
-
|
|
71
|
-
|
|
79
|
+
while _PeekMessageA(byref(msg), 0, 0, 0, PM_REMOVE):
|
|
80
|
+
_TranslateMessage(byref(msg))
|
|
81
|
+
_DispatchMessageA(byref(msg))
|
|
72
82
|
|
|
73
83
|
|
|
74
84
|
class Test(ut.TestCase):
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import contextlib
|
|
2
2
|
import unittest as ut
|
|
3
|
+
from ctypes import HRESULT, POINTER, WinDLL, c_uint32, pointer
|
|
3
4
|
|
|
4
|
-
from ctypes import POINTER, pointer, windll
|
|
5
|
-
from comtypes import GUID
|
|
6
5
|
import comtypes.client
|
|
6
|
+
from comtypes import GUID
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
class Test_IMFAttributes(ut.TestCase):
|
|
@@ -12,8 +12,18 @@ class Test_IMFAttributes(ut.TestCase):
|
|
|
12
12
|
comtypes.client.GetModule("msvidctl.dll")
|
|
13
13
|
from comtypes.gen import MSVidCtlLib
|
|
14
14
|
|
|
15
|
+
_mfplat = WinDLL("mfplat")
|
|
16
|
+
|
|
17
|
+
UINT32 = c_uint32
|
|
18
|
+
_MFCreateAttributes = _mfplat.MFCreateAttributes
|
|
19
|
+
_MFCreateAttributes.argtypes = [
|
|
20
|
+
POINTER(POINTER(MSVidCtlLib.IMFAttributes)),
|
|
21
|
+
UINT32,
|
|
22
|
+
]
|
|
23
|
+
_MFCreateAttributes.restype = HRESULT
|
|
24
|
+
|
|
15
25
|
imf_attrs = POINTER(MSVidCtlLib.IMFAttributes)()
|
|
16
|
-
hres =
|
|
26
|
+
hres = _MFCreateAttributes(pointer(imf_attrs), 2)
|
|
17
27
|
self.assertEqual(hres, 0)
|
|
18
28
|
|
|
19
29
|
MF_TRANSCODE_ADJUST_PROFILE = GUID("{9c37c21b-060f-487c-a690-80d7f50d1c72}")
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
from typing import Any, Callable, List, NamedTuple, Tuple, Type
|
|
2
|
-
from ctypes import POINTER, pointer, Structure, HRESULT, c_ulong, c_wchar_p, c_int
|
|
3
1
|
import unittest as ut
|
|
2
|
+
from ctypes import HRESULT, POINTER, Structure, c_int, c_ulong, c_wchar_p, pointer
|
|
3
|
+
from typing import TYPE_CHECKING, Any, Callable, List, NamedTuple, Tuple, Type
|
|
4
4
|
from unittest.mock import MagicMock
|
|
5
5
|
|
|
6
6
|
import comtypes
|
|
7
|
-
from comtypes
|
|
8
|
-
from comtypes._memberspec import _fix_inout_args
|
|
7
|
+
from comtypes import IUnknown
|
|
8
|
+
from comtypes._memberspec import _fix_inout_args
|
|
9
|
+
|
|
10
|
+
if TYPE_CHECKING:
|
|
11
|
+
from comtypes._memberspec import _ArgSpecElmType
|
|
9
12
|
|
|
10
13
|
WSTRING = c_wchar_p
|
|
11
14
|
|
|
@@ -256,7 +259,7 @@ class Test_ArgsKwargsCombinations(ut.TestCase):
|
|
|
256
259
|
|
|
257
260
|
|
|
258
261
|
class PermutedArgspecTestingParams(NamedTuple):
|
|
259
|
-
argspec: Tuple[_ArgSpecElmType, _ArgSpecElmType, _ArgSpecElmType, _ArgSpecElmType]
|
|
262
|
+
argspec: "Tuple[_ArgSpecElmType, _ArgSpecElmType, _ArgSpecElmType, _ArgSpecElmType]"
|
|
260
263
|
args: Tuple[Any, Any, Any]
|
|
261
264
|
orig_ret_val: Tuple[Any, Any, Any]
|
|
262
265
|
fixed_ret_val: List[Any]
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
# coding: utf-8
|
|
2
2
|
|
|
3
|
-
from ctypes import c_int, pointer, POINTER
|
|
4
3
|
import unittest
|
|
4
|
+
from ctypes import HRESULT, POINTER, c_int, pointer
|
|
5
5
|
|
|
6
6
|
import comtypes
|
|
7
7
|
import comtypes.safearray
|
|
8
|
+
import comtypes.typeinfo
|
|
8
9
|
from comtypes import CLSCTX_INPROC_SERVER, CLSCTX_LOCAL_SERVER
|
|
9
10
|
from comtypes.client import CreateObject, GetModule
|
|
10
|
-
import comtypes.typeinfo
|
|
11
11
|
|
|
12
12
|
GetModule("UIAutomationCore.dll")
|
|
13
13
|
from comtypes.gen.UIAutomationClient import CUIAutomation, IUIAutomation
|
|
@@ -16,8 +16,10 @@ ComtypesCppTestSrvLib_GUID = "{07D2AEE5-1DF8-4D2C-953A-554ADFD25F99}"
|
|
|
16
16
|
|
|
17
17
|
try:
|
|
18
18
|
GetModule((ComtypesCppTestSrvLib_GUID, 1, 0, 0))
|
|
19
|
-
from comtypes.gen.ComtypesCppTestSrvLib import
|
|
20
|
-
|
|
19
|
+
from comtypes.gen.ComtypesCppTestSrvLib import (
|
|
20
|
+
IDispSafearrayParamTest,
|
|
21
|
+
StructRecordParamTest,
|
|
22
|
+
)
|
|
21
23
|
|
|
22
24
|
IMPORT_FAILED = False
|
|
23
25
|
except (ImportError, OSError):
|
|
@@ -82,6 +84,14 @@ class Test_midlSAFEARRAY_create(unittest.TestCase):
|
|
|
82
84
|
self.assertEqual(unpacked.answer, 42)
|
|
83
85
|
self.assertEqual(unpacked.needs_clarification, True)
|
|
84
86
|
|
|
87
|
+
def test_HRESULT(self):
|
|
88
|
+
hr = HRESULT(1)
|
|
89
|
+
sa_type = comtypes.safearray._midlSAFEARRAY(HRESULT)
|
|
90
|
+
with self.assertRaises(TypeError):
|
|
91
|
+
sa_type.create([hr], extra=None)
|
|
92
|
+
with self.assertRaises(TypeError):
|
|
93
|
+
sa_type.create([hr])
|
|
94
|
+
|
|
85
95
|
def test_ctype(self):
|
|
86
96
|
extra = None
|
|
87
97
|
cdata = c_int(1)
|
|
@@ -1,39 +1,53 @@
|
|
|
1
|
-
from _ctypes import COMError
|
|
2
|
-
from ctypes import byref, POINTER
|
|
3
1
|
import contextlib
|
|
4
2
|
import unittest
|
|
3
|
+
from _ctypes import COMError
|
|
4
|
+
from ctypes import HRESULT, POINTER, OleDLL, byref, c_wchar_p
|
|
5
|
+
from ctypes.wintypes import DWORD
|
|
5
6
|
|
|
6
|
-
import
|
|
7
|
-
from comtypes.client import
|
|
8
|
-
from comtypes import hresult, GUID
|
|
7
|
+
from comtypes import GUID, hresult
|
|
8
|
+
from comtypes.client import CreateObject, GetModule
|
|
9
9
|
|
|
10
10
|
with contextlib.redirect_stdout(None): # supress warnings
|
|
11
11
|
GetModule("msvidctl.dll")
|
|
12
12
|
from comtypes.gen import MSVidCtlLib as msvidctl
|
|
13
13
|
from comtypes.gen.MSVidCtlLib import IBindCtx, IMoniker, IRunningObjectTable
|
|
14
14
|
|
|
15
|
-
|
|
16
15
|
MKSYS_ITEMMONIKER = 4
|
|
17
16
|
ROTFLAGS_ALLOWANYCLIENT = 1
|
|
17
|
+
LPOLESTR = LPCOLESTR = c_wchar_p
|
|
18
|
+
|
|
19
|
+
_ole32 = OleDLL("ole32")
|
|
20
|
+
|
|
21
|
+
_CreateItemMoniker = _ole32.CreateItemMoniker
|
|
22
|
+
_CreateItemMoniker.argtypes = [LPCOLESTR, LPCOLESTR, POINTER(POINTER(IMoniker))]
|
|
23
|
+
_CreateItemMoniker.restype = HRESULT
|
|
24
|
+
|
|
25
|
+
_CreateBindCtx = _ole32.CreateBindCtx
|
|
26
|
+
_CreateBindCtx.argtypes = [DWORD, POINTER(POINTER(IBindCtx))]
|
|
27
|
+
_CreateBindCtx.restype = HRESULT
|
|
28
|
+
|
|
29
|
+
_GetRunningObjectTable = _ole32.GetRunningObjectTable
|
|
30
|
+
_GetRunningObjectTable.argtypes = [DWORD, POINTER(POINTER(IRunningObjectTable))]
|
|
31
|
+
_GetRunningObjectTable.restype = HRESULT
|
|
18
32
|
|
|
19
33
|
|
|
20
34
|
def _create_item_moniker(delim: str, item: str) -> IMoniker:
|
|
21
35
|
mon = POINTER(IMoniker)()
|
|
22
|
-
|
|
36
|
+
_CreateItemMoniker(delim, item, byref(mon))
|
|
23
37
|
return mon # type: ignore
|
|
24
38
|
|
|
25
39
|
|
|
26
40
|
def _create_bctx() -> IBindCtx:
|
|
27
41
|
bctx = POINTER(IBindCtx)()
|
|
28
42
|
# The first parameter is reserved and must be 0.
|
|
29
|
-
|
|
43
|
+
_CreateBindCtx(0, byref(bctx))
|
|
30
44
|
return bctx # type: ignore
|
|
31
45
|
|
|
32
46
|
|
|
33
47
|
def _create_rot() -> IRunningObjectTable:
|
|
34
48
|
rot = POINTER(IRunningObjectTable)()
|
|
35
49
|
# The first parameter is reserved and must be 0.
|
|
36
|
-
|
|
50
|
+
_GetRunningObjectTable(0, byref(rot))
|
|
37
51
|
return rot # type: ignore
|
|
38
52
|
|
|
39
53
|
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import unittest
|
|
2
2
|
from ctypes import POINTER
|
|
3
|
+
|
|
4
|
+
from comtypes import GUID
|
|
3
5
|
from comtypes.automation import IDispatch
|
|
4
6
|
from comtypes.client import CreateObject
|
|
5
|
-
from comtypes import GUID
|
|
6
7
|
|
|
7
8
|
##from test import test_support
|
|
8
9
|
##from comtypes.unittests import support
|
|
@@ -3,7 +3,7 @@ import functools
|
|
|
3
3
|
import importlib
|
|
4
4
|
import inspect
|
|
5
5
|
import unittest
|
|
6
|
-
from ctypes import
|
|
6
|
+
from ctypes import POINTER, c_double, c_long, pointer
|
|
7
7
|
from decimal import Decimal
|
|
8
8
|
|
|
9
9
|
import comtypes._npsupport
|
|
@@ -11,13 +11,13 @@ from comtypes import IUnknown
|
|
|
11
11
|
from comtypes._safearray import SafeArrayGetVartype
|
|
12
12
|
from comtypes.automation import (
|
|
13
13
|
BSTR,
|
|
14
|
+
VARIANT,
|
|
15
|
+
VARIANT_BOOL,
|
|
14
16
|
VT_BSTR,
|
|
15
17
|
VT_DATE,
|
|
16
18
|
VT_I4,
|
|
17
|
-
_midlSAFEARRAY,
|
|
18
|
-
VARIANT,
|
|
19
19
|
VT_VARIANT,
|
|
20
|
-
|
|
20
|
+
_midlSAFEARRAY,
|
|
21
21
|
)
|
|
22
22
|
from comtypes.safearray import safearray_as_ndarray
|
|
23
23
|
|
|
@@ -1,18 +1,28 @@
|
|
|
1
|
-
import sys
|
|
2
1
|
import unittest
|
|
3
|
-
from ctypes import
|
|
2
|
+
from ctypes import (
|
|
3
|
+
HRESULT,
|
|
4
|
+
POINTER,
|
|
5
|
+
OleDLL,
|
|
6
|
+
WinDLL,
|
|
7
|
+
byref,
|
|
8
|
+
c_int,
|
|
9
|
+
c_size_t,
|
|
10
|
+
c_ulong,
|
|
11
|
+
c_void_p,
|
|
12
|
+
c_wchar,
|
|
13
|
+
c_wchar_p,
|
|
14
|
+
cast,
|
|
15
|
+
memmove,
|
|
16
|
+
sizeof,
|
|
17
|
+
wstring_at,
|
|
18
|
+
)
|
|
19
|
+
from ctypes.wintypes import DWORD, LPVOID
|
|
4
20
|
from unittest.mock import patch
|
|
5
21
|
|
|
6
|
-
import
|
|
22
|
+
from comtypes import COMMETHOD, GUID, IUnknown
|
|
23
|
+
from comtypes.GUID import _CoTaskMemFree
|
|
7
24
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
from comtypes import IUnknown, GUID, COMMETHOD
|
|
11
|
-
|
|
12
|
-
if sys.version_info >= (3, 0):
|
|
13
|
-
text_type = str
|
|
14
|
-
else:
|
|
15
|
-
text_type = unicode
|
|
25
|
+
text_type = str
|
|
16
26
|
|
|
17
27
|
|
|
18
28
|
class IMalloc(IUnknown):
|
|
@@ -27,8 +37,21 @@ class IMalloc(IUnknown):
|
|
|
27
37
|
]
|
|
28
38
|
|
|
29
39
|
|
|
40
|
+
_ole32 = OleDLL("ole32")
|
|
41
|
+
|
|
42
|
+
_CoGetMalloc = _ole32.CoGetMalloc
|
|
43
|
+
_CoGetMalloc.argtypes = [DWORD, POINTER(POINTER(IMalloc))]
|
|
44
|
+
_CoGetMalloc.restype = HRESULT
|
|
45
|
+
|
|
46
|
+
_ole32_nohresult = WinDLL("ole32")
|
|
47
|
+
|
|
48
|
+
SIZE_T = c_size_t
|
|
49
|
+
_CoTaskMemAlloc = _ole32_nohresult.CoTaskMemAlloc
|
|
50
|
+
_CoTaskMemAlloc.argtypes = [SIZE_T]
|
|
51
|
+
_CoTaskMemAlloc.restype = LPVOID
|
|
52
|
+
|
|
30
53
|
malloc = POINTER(IMalloc)()
|
|
31
|
-
|
|
54
|
+
_CoGetMalloc(1, byref(malloc))
|
|
32
55
|
assert bool(malloc)
|
|
33
56
|
|
|
34
57
|
|
|
@@ -38,14 +61,14 @@ def from_outparm(self):
|
|
|
38
61
|
result = wstring_at(self)
|
|
39
62
|
if not malloc.DidAlloc(self):
|
|
40
63
|
raise ValueError("memory was NOT allocated by CoTaskMemAlloc")
|
|
41
|
-
|
|
64
|
+
_CoTaskMemFree(self)
|
|
42
65
|
return result
|
|
43
66
|
|
|
44
67
|
|
|
45
68
|
def comstring(text, typ=c_wchar_p):
|
|
46
69
|
text = text_type(text)
|
|
47
70
|
size = (len(text) + 1) * sizeof(c_wchar)
|
|
48
|
-
mem =
|
|
71
|
+
mem = _CoTaskMemAlloc(size)
|
|
49
72
|
print("malloc'd 0x%x, %d bytes" % (mem, size))
|
|
50
73
|
ptr = cast(mem, typ)
|
|
51
74
|
memmove(mem, text, size)
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
from pathlib import Path
|
|
2
1
|
import tempfile
|
|
3
2
|
import unittest as ut
|
|
3
|
+
from pathlib import Path
|
|
4
4
|
|
|
5
|
-
from comtypes import CoCreateInstance,
|
|
6
|
-
from comtypes import persist
|
|
7
|
-
|
|
5
|
+
from comtypes import GUID, CoCreateInstance, IPersist, persist
|
|
8
6
|
|
|
9
7
|
CLSID_ShellLink = GUID("{00021401-0000-0000-C000-000000000046}")
|
|
10
8
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# coding: utf-8
|
|
2
2
|
|
|
3
3
|
import unittest
|
|
4
|
+
from ctypes import byref, pointer, sizeof
|
|
4
5
|
|
|
5
6
|
from comtypes import typeinfo
|
|
6
7
|
from comtypes.client import GetModule
|
|
7
|
-
from ctypes import byref, pointer, sizeof
|
|
8
8
|
|
|
9
9
|
ComtypesCppTestSrvLib_GUID = "{07D2AEE5-1DF8-4D2C-953A-554ADFD25F99}"
|
|
10
10
|
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import array
|
|
2
2
|
import datetime
|
|
3
3
|
import unittest
|
|
4
|
-
from ctypes import POINTER,
|
|
5
|
-
from ctypes.wintypes import BOOL
|
|
4
|
+
from ctypes import POINTER, c_long
|
|
6
5
|
from decimal import Decimal
|
|
7
6
|
|
|
8
7
|
from comtypes import BSTR, IUnknown
|
|
@@ -19,7 +18,6 @@ from comtypes.automation import (
|
|
|
19
18
|
_midlSAFEARRAY,
|
|
20
19
|
)
|
|
21
20
|
from comtypes.safearray import safearray_as_ndarray
|
|
22
|
-
from comtypes.test import is_resource_enabled
|
|
23
21
|
from comtypes.test.find_memleak import find_memleak
|
|
24
22
|
|
|
25
23
|
|
|
@@ -223,93 +221,6 @@ class SafeArrayTestCase(unittest.TestCase):
|
|
|
223
221
|
del sa
|
|
224
222
|
self.assertEqual((a, b), (com_refcnt(plib), com_refcnt(punk)))
|
|
225
223
|
|
|
226
|
-
@unittest.skip(
|
|
227
|
-
"This fails with a 'library not registered' error. Need to figure out how to "
|
|
228
|
-
"register TestComServerLib (without admin if possible)."
|
|
229
|
-
)
|
|
230
|
-
def test_UDT(self):
|
|
231
|
-
from comtypes.gen.TestComServerLib import MYCOLOR
|
|
232
|
-
|
|
233
|
-
t = _midlSAFEARRAY(MYCOLOR)
|
|
234
|
-
self.assertTrue(t is _midlSAFEARRAY(MYCOLOR))
|
|
235
|
-
|
|
236
|
-
sa = t.from_param([MYCOLOR(0, 0, 0), MYCOLOR(1, 2, 3)])
|
|
237
|
-
|
|
238
|
-
self.assertEqual(
|
|
239
|
-
[(x.red, x.green, x.blue) for x in sa[0]],
|
|
240
|
-
[(0.0, 0.0, 0.0), (1.0, 2.0, 3.0)],
|
|
241
|
-
)
|
|
242
|
-
|
|
243
|
-
def doit():
|
|
244
|
-
t.from_param([MYCOLOR(0, 0, 0), MYCOLOR(1, 2, 3)])
|
|
245
|
-
|
|
246
|
-
bytes = find_memleak(doit)
|
|
247
|
-
self.assertFalse(bytes, "Leaks %d bytes" % bytes)
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
if is_resource_enabled("pythoncom"):
|
|
251
|
-
try:
|
|
252
|
-
import pythoncom
|
|
253
|
-
except ImportError:
|
|
254
|
-
# pywin32 not installed...
|
|
255
|
-
pass
|
|
256
|
-
else:
|
|
257
|
-
# pywin32 is available. The pythoncom dll contains two handy
|
|
258
|
-
# exported functions that allow to create a VARIANT from a Python
|
|
259
|
-
# object, also a function that unpacks a VARIANT into a Python
|
|
260
|
-
# object.
|
|
261
|
-
#
|
|
262
|
-
# This allows us to create und unpack SAFEARRAY instances
|
|
263
|
-
# contained in VARIANTs, and check for consistency with the
|
|
264
|
-
# comtypes code.
|
|
265
|
-
|
|
266
|
-
_dll = PyDLL(pythoncom.__file__)
|
|
267
|
-
|
|
268
|
-
# c:/sf/pywin32/com/win32com/src/oleargs.cpp 213
|
|
269
|
-
# PyObject *PyCom_PyObjectFromVariant(const VARIANT *var)
|
|
270
|
-
unpack = _dll.PyCom_PyObjectFromVariant
|
|
271
|
-
unpack.restype = py_object
|
|
272
|
-
unpack.argtypes = (POINTER(VARIANT),)
|
|
273
|
-
|
|
274
|
-
# c:/sf/pywin32/com/win32com/src/oleargs.cpp 54
|
|
275
|
-
# BOOL PyCom_VariantFromPyObject(PyObject *obj, VARIANT *var)
|
|
276
|
-
_pack = _dll.PyCom_VariantFromPyObject
|
|
277
|
-
_pack.argtypes = py_object, POINTER(VARIANT)
|
|
278
|
-
_pack.restype = BOOL
|
|
279
|
-
|
|
280
|
-
def pack(obj):
|
|
281
|
-
var = VARIANT()
|
|
282
|
-
_pack(obj, byref(var))
|
|
283
|
-
return var
|
|
284
|
-
|
|
285
|
-
class PyWinTest(unittest.TestCase):
|
|
286
|
-
def test_1dim(self):
|
|
287
|
-
data = (1, 2, 3)
|
|
288
|
-
variant = pack(data)
|
|
289
|
-
self.assertEqual(variant.value, data)
|
|
290
|
-
self.assertEqual(unpack(variant), data)
|
|
291
|
-
|
|
292
|
-
def test_2dim(self):
|
|
293
|
-
data = ((1, 2, 3), (4, 5, 6), (7, 8, 9))
|
|
294
|
-
variant = pack(data)
|
|
295
|
-
self.assertEqual(variant.value, data)
|
|
296
|
-
self.assertEqual(unpack(variant), data)
|
|
297
|
-
|
|
298
|
-
def test_3dim(self):
|
|
299
|
-
data = (((1, 2), (3, 4), (5, 6)), ((7, 8), (9, 10), (11, 12)))
|
|
300
|
-
variant = pack(data)
|
|
301
|
-
self.assertEqual(variant.value, data)
|
|
302
|
-
self.assertEqual(unpack(variant), data)
|
|
303
|
-
|
|
304
|
-
def test_4dim(self):
|
|
305
|
-
data = (
|
|
306
|
-
(((1, 2), (3, 4)), ((5, 6), (7, 8))),
|
|
307
|
-
(((9, 10), (11, 12)), ((13, 14), (15, 16))),
|
|
308
|
-
)
|
|
309
|
-
variant = pack(data)
|
|
310
|
-
self.assertEqual(variant.value, data)
|
|
311
|
-
self.assertEqual(unpack(variant), data)
|
|
312
|
-
|
|
313
224
|
|
|
314
225
|
if __name__ == "__main__":
|
|
315
226
|
unittest.main()
|