comtypes 1.4.9__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.9 → comtypes-1.4.10}/CHANGES.txt +19 -0
- {comtypes-1.4.9/comtypes.egg-info → comtypes-1.4.10}/PKG-INFO +3 -2
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/GUID.py +34 -13
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/__init__.py +22 -13
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/_comobject.py +69 -14
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/_memberspec.py +14 -6
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/_meta.py +1 -0
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/_post_coinit/_cominterface_meta_patcher.py +0 -1
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/_post_coinit/bstr.py +12 -5
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/_post_coinit/instancemethod.py +1 -2
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/_post_coinit/misc.py +59 -24
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/_post_coinit/unknwn.py +2 -6
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/_safearray.py +2 -2
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/automation.py +10 -4
- comtypes-1.4.10/comtypes/client/__init__.py +42 -0
- comtypes-1.4.10/comtypes/client/_activeobj.py +46 -0
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/client/_code_cache.py +6 -1
- comtypes-1.4.10/comtypes/client/_create.py +147 -0
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/client/_events.py +57 -12
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/client/_generate.py +3 -3
- comtypes-1.4.10/comtypes/client/_managing.py +114 -0
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/client/dynamic.py +2 -3
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/client/lazybind.py +10 -11
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/connectionpoints.py +2 -1
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/errorinfo.py +20 -7
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/git.py +4 -3
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/logutil.py +15 -3
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/messageloop.py +1 -1
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/persist.py +3 -5
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/safearray.py +8 -6
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/server/__init__.py +22 -4
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/server/automation.py +1 -2
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/server/connectionpoints.py +5 -5
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/server/inprocserver.py +6 -3
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/server/localserver.py +23 -5
- comtypes-1.4.10/comtypes/server/register.py +478 -0
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/shelllink.py +13 -7
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/stream.py +7 -4
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/test/TestComServer.py +6 -7
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/test/TestDispServer.py +4 -2
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/test/__init__.py +1 -1
- comtypes-1.4.10/comtypes/test/find_memleak.py +72 -0
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/test/runtests.py +1 -0
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/test/setup.py +2 -1
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/test/test_BSTR.py +7 -17
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/test/test_GUID.py +1 -0
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/test/test_QueryService.py +1 -0
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/test/test_agilent.py +4 -3
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/test/test_basic.py +12 -6
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/test/test_clear_cache.py +1 -1
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/test/test_client.py +2 -2
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/test/test_client_dynamic.py +2 -2
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/test/test_client_regenerate_modules.py +2 -2
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/test/test_collections.py +1 -1
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/test/test_comobject.py +4 -4
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/test/test_comserver.py +31 -1
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/test/test_dispifc_records.py +1 -1
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/test/test_dispifc_safearrays.py +1 -1
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/test/test_dyndispatch.py +1 -0
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/test/test_findgendir.py +1 -2
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/test/test_getactiveobj.py +4 -4
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/test/test_ie.py +19 -6
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/test/test_ienum.py +2 -2
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/test/test_imfattributes.py +13 -3
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/test/test_inout_args.py +1 -1
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/test/test_midl_safearray_create.py +6 -4
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/test/test_monikers.py +23 -9
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/test/test_msscript.py +2 -1
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/test/test_npsupport.py +4 -4
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/test/test_outparam.py +22 -6
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/test/test_persist.py +2 -4
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/test/test_recordinfo.py +1 -1
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/test/test_sapi.py +4 -1
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/test/test_server_register.py +113 -125
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/test/test_shelllink.py +2 -3
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/test/test_storage.py +12 -6
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/test/test_stream.py +16 -5
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/test/test_subinterface.py +4 -2
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/test/test_typeannotator.py +1 -2
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/test/test_typeinfo.py +19 -7
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/test/test_urlhistory.py +7 -4
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/test/test_variant.py +3 -2
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/test/test_word.py +1 -1
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/tools/codegenerator/codegenerator.py +167 -435
- 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.9 → comtypes-1.4.10}/comtypes/tools/codegenerator/helpers.py +3 -6
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/tools/codegenerator/namespaces.py +13 -5
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/tools/codegenerator/typeannotator.py +13 -3
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/tools/tlbparser.py +22 -23
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/tools/typedesc.py +3 -2
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/tools/typedesc_base.py +2 -2
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/typeinfo.py +149 -42
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/viewobject.py +2 -4
- {comtypes-1.4.9 → comtypes-1.4.10/comtypes.egg-info}/PKG-INFO +3 -2
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes.egg-info/SOURCES.txt +5 -0
- {comtypes-1.4.9 → comtypes-1.4.10}/pyproject.toml +11 -19
- 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.10}/LICENSE.txt +0 -0
- {comtypes-1.4.9 → comtypes-1.4.10}/MANIFEST.in +0 -0
- {comtypes-1.4.9 → comtypes-1.4.10}/README.md +0 -0
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/_npsupport.py +0 -0
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/_post_coinit/__init__.py +0 -0
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/_tlib_version_checker.py +0 -0
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/_vtbl.py +0 -0
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/clear_cache.py +0 -0
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/client/_constants.py +0 -0
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/hints.pyi +0 -0
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/hresult.py +0 -0
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/patcher.py +0 -0
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/server/w_getopt.py +0 -0
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/test/TestComServer.idl +0 -0
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/test/TestComServer.tlb +0 -0
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/test/TestDispServer.idl +0 -0
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/test/TestDispServer.tlb +0 -0
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/test/mylib.idl +0 -0
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/test/mylib.tlb +0 -0
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/test/mytypelib.idl +0 -0
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/test/test_DISPPARAMS.py +0 -0
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/test/test_avmc.py +0 -0
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/test/test_casesensitivity.py +0 -0
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/test/test_createwrappers.py +0 -0
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/test/test_dict.py +0 -0
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/test/test_dispinterface.py +0 -0
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/test/test_excel.py +0 -0
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/test/test_jscript.js +0 -0
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/test/test_pump_events.py +0 -0
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/test/test_safearray.py +0 -0
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/test/test_server.py +0 -0
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/test/test_showevents.py +0 -0
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/test/test_w_getopt.py +0 -0
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/test/test_win32com_interop.py +0 -0
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/test/test_wmi.py +0 -0
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/test/urlhist.tlb +0 -0
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/tools/__init__.py +0 -0
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/tools/codegenerator/__init__.py +0 -0
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/tools/codegenerator/modulenamer.py +0 -0
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/tools/codegenerator/packing.py +0 -0
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes/util.py +0 -0
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes.egg-info/dependency_links.txt +0 -0
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes.egg-info/entry_points.txt +0 -0
- {comtypes-1.4.9 → comtypes-1.4.10}/comtypes.egg-info/top_level.txt +0 -0
- {comtypes-1.4.9 → comtypes-1.4.10}/setup.cfg +0 -0
- {comtypes-1.4.9 → comtypes-1.4.10}/setup.py +0 -0
|
@@ -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,23 +1,26 @@
|
|
|
1
1
|
import unittest
|
|
2
2
|
from ctypes import (
|
|
3
|
+
HRESULT,
|
|
3
4
|
POINTER,
|
|
5
|
+
OleDLL,
|
|
6
|
+
WinDLL,
|
|
4
7
|
byref,
|
|
5
8
|
c_int,
|
|
9
|
+
c_size_t,
|
|
6
10
|
c_ulong,
|
|
7
11
|
c_void_p,
|
|
8
12
|
c_wchar,
|
|
9
13
|
c_wchar_p,
|
|
10
14
|
cast,
|
|
11
15
|
memmove,
|
|
12
|
-
oledll,
|
|
13
16
|
sizeof,
|
|
14
|
-
windll,
|
|
15
17
|
wstring_at,
|
|
16
18
|
)
|
|
19
|
+
from ctypes.wintypes import DWORD, LPVOID
|
|
17
20
|
from unittest.mock import patch
|
|
18
21
|
|
|
19
22
|
from comtypes import COMMETHOD, GUID, IUnknown
|
|
20
|
-
|
|
23
|
+
from comtypes.GUID import _CoTaskMemFree
|
|
21
24
|
|
|
22
25
|
text_type = str
|
|
23
26
|
|
|
@@ -34,8 +37,21 @@ class IMalloc(IUnknown):
|
|
|
34
37
|
]
|
|
35
38
|
|
|
36
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
|
+
|
|
37
53
|
malloc = POINTER(IMalloc)()
|
|
38
|
-
|
|
54
|
+
_CoGetMalloc(1, byref(malloc))
|
|
39
55
|
assert bool(malloc)
|
|
40
56
|
|
|
41
57
|
|
|
@@ -45,14 +61,14 @@ def from_outparm(self):
|
|
|
45
61
|
result = wstring_at(self)
|
|
46
62
|
if not malloc.DidAlloc(self):
|
|
47
63
|
raise ValueError("memory was NOT allocated by CoTaskMemAlloc")
|
|
48
|
-
|
|
64
|
+
_CoTaskMemFree(self)
|
|
49
65
|
return result
|
|
50
66
|
|
|
51
67
|
|
|
52
68
|
def comstring(text, typ=c_wchar_p):
|
|
53
69
|
text = text_type(text)
|
|
54
70
|
size = (len(text) + 1) * sizeof(c_wchar)
|
|
55
|
-
mem =
|
|
71
|
+
mem = _CoTaskMemAlloc(size)
|
|
56
72
|
print("malloc'd 0x%x, %d bytes" % (mem, size))
|
|
57
73
|
ptr = cast(mem, typ)
|
|
58
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,5 +1,4 @@
|
|
|
1
1
|
import _ctypes
|
|
2
|
-
import ctypes
|
|
3
2
|
import os
|
|
4
3
|
import sys
|
|
5
4
|
import unittest as ut
|
|
@@ -10,17 +9,71 @@ import comtypes
|
|
|
10
9
|
import comtypes.server.inprocserver
|
|
11
10
|
from comtypes import GUID
|
|
12
11
|
from comtypes.server import register
|
|
13
|
-
from comtypes.server.register import
|
|
12
|
+
from comtypes.server.register import (
|
|
13
|
+
FrozenRegistryEntries,
|
|
14
|
+
InterpRegistryEntries,
|
|
15
|
+
Registrar,
|
|
16
|
+
_delete_key,
|
|
17
|
+
_get_serverdll,
|
|
18
|
+
)
|
|
14
19
|
|
|
15
20
|
HKCR = winreg.HKEY_CLASSES_ROOT
|
|
16
21
|
MULTI_SZ = winreg.REG_MULTI_SZ
|
|
17
22
|
SZ = winreg.REG_SZ
|
|
18
23
|
|
|
24
|
+
ERROR_ACCESS_DENIED = 5
|
|
25
|
+
ERROR_FILE_NOT_FOUND = 2
|
|
19
26
|
|
|
27
|
+
|
|
28
|
+
@mock.patch.object(register, "SHDeleteKey")
|
|
29
|
+
@mock.patch.object(register, "winreg")
|
|
30
|
+
class Test_delete_key(ut.TestCase):
|
|
31
|
+
def test_calls_sh_deletekey_if_forced(self, _winreg, _sh_deletekey):
|
|
32
|
+
_delete_key(123, "subkey", force=True)
|
|
33
|
+
_winreg.DeleteKey.assert_not_called()
|
|
34
|
+
_sh_deletekey.assert_called_once_with(123, "subkey")
|
|
35
|
+
|
|
36
|
+
def test_calls_winreg_deletekey_if_not_forced(self, _winreg, _sh_deletekey):
|
|
37
|
+
_delete_key(123, "subkey", force=False)
|
|
38
|
+
_winreg.DeleteKey.assert_called_once_with(123, "subkey")
|
|
39
|
+
_sh_deletekey.assert_not_called()
|
|
40
|
+
|
|
41
|
+
def test_ignores_error_on_sh_deletekey(self, _winreg, _sh_deletekey):
|
|
42
|
+
err = OSError(ERROR_FILE_NOT_FOUND, "msg", "filename", ERROR_FILE_NOT_FOUND)
|
|
43
|
+
_sh_deletekey.side_effect = err
|
|
44
|
+
_delete_key(123, "subkey", force=True)
|
|
45
|
+
_winreg.DeleteKey.assert_not_called()
|
|
46
|
+
_sh_deletekey.assert_called_once_with(123, "subkey")
|
|
47
|
+
|
|
48
|
+
def test_ignores_error_on_winreg_deletekey(self, _winreg, _sh_deletekey):
|
|
49
|
+
err = OSError(ERROR_FILE_NOT_FOUND, "msg", "filename", ERROR_FILE_NOT_FOUND)
|
|
50
|
+
_winreg.DeleteKey.side_effect = err
|
|
51
|
+
_delete_key(123, "subkey", force=False)
|
|
52
|
+
_winreg.DeleteKey.assert_called_once_with(123, "subkey")
|
|
53
|
+
_sh_deletekey.assert_not_called()
|
|
54
|
+
|
|
55
|
+
def test_not_ignores_winerror_on_sh_deletekey(self, _winreg, _sh_deletekey):
|
|
56
|
+
err = OSError(ERROR_ACCESS_DENIED, "msg", "filename", ERROR_ACCESS_DENIED)
|
|
57
|
+
_sh_deletekey.side_effect = err
|
|
58
|
+
with self.assertRaises(OSError) as e:
|
|
59
|
+
_delete_key(123, "subkey", force=True)
|
|
60
|
+
self.assertEqual(e.exception.winerror, ERROR_ACCESS_DENIED)
|
|
61
|
+
_winreg.DeleteKey.assert_not_called()
|
|
62
|
+
_sh_deletekey.assert_called_once_with(123, "subkey")
|
|
63
|
+
|
|
64
|
+
def test_not_ignores_winerror_on_winreg_deletekey(self, _winreg, _sh_deletekey):
|
|
65
|
+
err = OSError(ERROR_ACCESS_DENIED, "msg", "filename", ERROR_ACCESS_DENIED)
|
|
66
|
+
_winreg.DeleteKey.side_effect = err
|
|
67
|
+
with self.assertRaises(OSError) as e:
|
|
68
|
+
_delete_key(123, "subkey", force=False)
|
|
69
|
+
self.assertEqual(e.exception.winerror, ERROR_ACCESS_DENIED)
|
|
70
|
+
_winreg.DeleteKey.assert_called_once_with(123, "subkey")
|
|
71
|
+
_sh_deletekey.assert_not_called()
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
@mock.patch.object(register, "winreg")
|
|
20
75
|
class Test_Registrar_nodebug(ut.TestCase):
|
|
21
|
-
@mock.patch.object(register, "winreg")
|
|
22
76
|
def test_calls_openkey_and_deletekey(self, _winreg):
|
|
23
|
-
_winreg.HKEY_CLASSES_ROOT = HKCR
|
|
24
77
|
hkey = mock.Mock(spec=winreg.HKEYType)
|
|
25
78
|
_winreg.OpenKey.return_value = hkey
|
|
26
79
|
reg_clsid = GUID.create_new()
|
|
@@ -33,10 +86,7 @@ class Test_Registrar_nodebug(ut.TestCase):
|
|
|
33
86
|
_winreg.OpenKey.assert_called_once_with(HKCR, rf"CLSID\{reg_clsid}")
|
|
34
87
|
_winreg.DeleteKey.assert_called_once_with(hkey, "Logging")
|
|
35
88
|
|
|
36
|
-
@mock.patch.object(register, "winreg")
|
|
37
89
|
def test_ignores_winerror(self, _winreg):
|
|
38
|
-
_winreg.HKEY_CLASSES_ROOT = HKCR
|
|
39
|
-
ERROR_FILE_NOT_FOUND = 2
|
|
40
90
|
err = OSError(ERROR_FILE_NOT_FOUND, "msg", "filename", ERROR_FILE_NOT_FOUND)
|
|
41
91
|
_winreg.OpenKey.side_effect = err
|
|
42
92
|
reg_clsid = GUID.create_new()
|
|
@@ -49,12 +99,9 @@ class Test_Registrar_nodebug(ut.TestCase):
|
|
|
49
99
|
_winreg.OpenKey.assert_called_once_with(HKCR, rf"CLSID\{reg_clsid}")
|
|
50
100
|
_winreg.DeleteKey.assert_not_called()
|
|
51
101
|
|
|
52
|
-
@mock.patch.object(register, "winreg")
|
|
53
102
|
def test_not_ignores_winerror(self, _winreg):
|
|
54
|
-
_winreg.HKEY_CLASSES_ROOT = HKCR
|
|
55
103
|
hkey = mock.Mock(spec=winreg.HKEYType)
|
|
56
104
|
_winreg.OpenKey.return_value = hkey
|
|
57
|
-
ERROR_ACCESS_DENIED = 5
|
|
58
105
|
err = OSError(ERROR_ACCESS_DENIED, "msg", "filename", ERROR_ACCESS_DENIED)
|
|
59
106
|
_winreg.OpenKey.return_value = hkey
|
|
60
107
|
_winreg.DeleteKey.side_effect = err
|
|
@@ -71,10 +118,9 @@ class Test_Registrar_nodebug(ut.TestCase):
|
|
|
71
118
|
_winreg.DeleteKey.assert_called_once_with(hkey, "Logging")
|
|
72
119
|
|
|
73
120
|
|
|
121
|
+
@mock.patch.object(register, "winreg")
|
|
74
122
|
class Test_Registrar_debug(ut.TestCase):
|
|
75
|
-
@mock.patch.object(register, "winreg")
|
|
76
123
|
def test_calls_createkey_and_sets_format(self, _winreg):
|
|
77
|
-
_winreg.HKEY_CLASSES_ROOT = HKCR
|
|
78
124
|
_winreg.REG_MULTI_SZ = MULTI_SZ
|
|
79
125
|
_winreg.REG_SZ = SZ
|
|
80
126
|
hkey = mock.Mock(spec=winreg.HKEYType)
|
|
@@ -97,9 +143,7 @@ class Test_Registrar_debug(ut.TestCase):
|
|
|
97
143
|
],
|
|
98
144
|
)
|
|
99
145
|
|
|
100
|
-
@mock.patch.object(register, "winreg")
|
|
101
146
|
def test_calls_createkey_and_deletes_format(self, _winreg):
|
|
102
|
-
_winreg.HKEY_CLASSES_ROOT = HKCR
|
|
103
147
|
_winreg.REG_MULTI_SZ = MULTI_SZ
|
|
104
148
|
hkey = mock.Mock(spec=winreg.HKEYType)
|
|
105
149
|
_winreg.CreateKey.return_value = hkey
|
|
@@ -117,13 +161,10 @@ class Test_Registrar_debug(ut.TestCase):
|
|
|
117
161
|
)
|
|
118
162
|
_winreg.DeleteValue.assert_called_once_with(hkey, "format")
|
|
119
163
|
|
|
120
|
-
@mock.patch.object(register, "winreg")
|
|
121
164
|
def test_calls_createkey_and_ignores_errors_on_deleting(self, _winreg):
|
|
122
|
-
_winreg.HKEY_CLASSES_ROOT = HKCR
|
|
123
165
|
_winreg.REG_MULTI_SZ = MULTI_SZ
|
|
124
166
|
hkey = mock.Mock(spec=winreg.HKEYType)
|
|
125
167
|
_winreg.CreateKey.return_value = hkey
|
|
126
|
-
ERROR_FILE_NOT_FOUND = 2
|
|
127
168
|
err = OSError(ERROR_FILE_NOT_FOUND, "msg", "filename", ERROR_FILE_NOT_FOUND)
|
|
128
169
|
_winreg.DeleteValue.side_effect = err
|
|
129
170
|
levels = ["lv=DEBUG"]
|
|
@@ -140,13 +181,10 @@ class Test_Registrar_debug(ut.TestCase):
|
|
|
140
181
|
)
|
|
141
182
|
_winreg.DeleteValue.assert_called_once_with(hkey, "format")
|
|
142
183
|
|
|
143
|
-
@mock.patch.object(register, "winreg")
|
|
144
184
|
def test_calls_createkey_and_not_ignores_errors_on_deleting(self, _winreg):
|
|
145
|
-
_winreg.HKEY_CLASSES_ROOT = HKCR
|
|
146
185
|
_winreg.REG_MULTI_SZ = MULTI_SZ
|
|
147
186
|
hkey = mock.Mock(spec=winreg.HKEYType)
|
|
148
187
|
_winreg.CreateKey.return_value = hkey
|
|
149
|
-
ERROR_ACCESS_DENIED = 5
|
|
150
188
|
err = OSError(ERROR_ACCESS_DENIED, "msg", "filename", ERROR_ACCESS_DENIED)
|
|
151
189
|
_winreg.DeleteValue.side_effect = err
|
|
152
190
|
levels = ["lv=DEBUG"]
|
|
@@ -191,24 +229,17 @@ class Test_Registrar_unregister(ut.TestCase):
|
|
|
191
229
|
|
|
192
230
|
|
|
193
231
|
class Test_get_serverdll(ut.TestCase):
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
self.assertEqual(handle, hModule)
|
|
206
|
-
buf_type = type(ctypes.create_string_buffer(260))
|
|
207
|
-
self.assertIsInstance(lpFilename, buf_type)
|
|
208
|
-
self.assertEqual(260, nSize)
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
class Test_NonFrozen_RegistryEntries(ut.TestCase):
|
|
232
|
+
@mock.patch.object(register, "GetModuleFileName")
|
|
233
|
+
def test_frozen(self, GetModuleFileName):
|
|
234
|
+
handle, dll_path = 1234, r"path\to\frozen.dll"
|
|
235
|
+
GetModuleFileName.return_value = dll_path
|
|
236
|
+
self.assertEqual(dll_path, _get_serverdll(handle))
|
|
237
|
+
(((hmodule, maxsize), _),) = GetModuleFileName.call_args_list
|
|
238
|
+
self.assertEqual(handle, hmodule)
|
|
239
|
+
self.assertEqual(260, maxsize)
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
class Test_InterpRegistryEntries(ut.TestCase):
|
|
212
243
|
def test_reg_clsid(self):
|
|
213
244
|
reg_clsid = GUID.create_new()
|
|
214
245
|
|
|
@@ -216,7 +247,7 @@ class Test_NonFrozen_RegistryEntries(ut.TestCase):
|
|
|
216
247
|
_reg_clsid_ = reg_clsid
|
|
217
248
|
|
|
218
249
|
expected = [(HKCR, rf"CLSID\{reg_clsid}", "", "")]
|
|
219
|
-
self.assertEqual(expected, list(
|
|
250
|
+
self.assertEqual(expected, list(InterpRegistryEntries(Cls)))
|
|
220
251
|
|
|
221
252
|
def test_reg_desc(self):
|
|
222
253
|
reg_clsid = GUID.create_new()
|
|
@@ -227,7 +258,7 @@ class Test_NonFrozen_RegistryEntries(ut.TestCase):
|
|
|
227
258
|
_reg_desc_ = reg_desc
|
|
228
259
|
|
|
229
260
|
expected = [(HKCR, rf"CLSID\{reg_clsid}", "", reg_desc)]
|
|
230
|
-
self.assertEqual(expected, list(
|
|
261
|
+
self.assertEqual(expected, list(InterpRegistryEntries(Cls)))
|
|
231
262
|
|
|
232
263
|
def test_reg_novers_progid(self):
|
|
233
264
|
reg_clsid = GUID.create_new()
|
|
@@ -238,7 +269,7 @@ class Test_NonFrozen_RegistryEntries(ut.TestCase):
|
|
|
238
269
|
_reg_novers_progid_ = reg_novers_progid
|
|
239
270
|
|
|
240
271
|
expected = [(HKCR, rf"CLSID\{reg_clsid}", "", "Lib Server")]
|
|
241
|
-
self.assertEqual(expected, list(
|
|
272
|
+
self.assertEqual(expected, list(InterpRegistryEntries(Cls)))
|
|
242
273
|
|
|
243
274
|
def test_progid(self):
|
|
244
275
|
reg_clsid = GUID.create_new()
|
|
@@ -254,7 +285,7 @@ class Test_NonFrozen_RegistryEntries(ut.TestCase):
|
|
|
254
285
|
(HKCR, reg_progid, "", "Lib Server 1"),
|
|
255
286
|
(HKCR, rf"{reg_progid}\CLSID", "", str(reg_clsid)),
|
|
256
287
|
]
|
|
257
|
-
self.assertEqual(expected, list(
|
|
288
|
+
self.assertEqual(expected, list(InterpRegistryEntries(Cls)))
|
|
258
289
|
|
|
259
290
|
def test_reg_progid_reg_desc(self):
|
|
260
291
|
reg_clsid = GUID.create_new()
|
|
@@ -272,7 +303,7 @@ class Test_NonFrozen_RegistryEntries(ut.TestCase):
|
|
|
272
303
|
(HKCR, reg_progid, "", "description for testing"),
|
|
273
304
|
(HKCR, rf"{reg_progid}\CLSID", "", str(reg_clsid)),
|
|
274
305
|
]
|
|
275
|
-
self.assertEqual(expected, list(
|
|
306
|
+
self.assertEqual(expected, list(InterpRegistryEntries(Cls)))
|
|
276
307
|
|
|
277
308
|
def test_reg_progid_reg_novers_progid(self):
|
|
278
309
|
reg_clsid = GUID.create_new()
|
|
@@ -295,7 +326,7 @@ class Test_NonFrozen_RegistryEntries(ut.TestCase):
|
|
|
295
326
|
(HKCR, rf"{reg_novers_progid}\CurVer", "", "Lib.Server.1"),
|
|
296
327
|
(HKCR, rf"{reg_novers_progid}\CLSID", "", str(reg_clsid)),
|
|
297
328
|
]
|
|
298
|
-
self.assertEqual(expected, list(
|
|
329
|
+
self.assertEqual(expected, list(InterpRegistryEntries(Cls)))
|
|
299
330
|
|
|
300
331
|
def test_local_server(self):
|
|
301
332
|
reg_clsid = GUID.create_new()
|
|
@@ -311,7 +342,7 @@ class Test_NonFrozen_RegistryEntries(ut.TestCase):
|
|
|
311
342
|
(HKCR, clsid_sub, "", ""),
|
|
312
343
|
(HKCR, local_srv_sub, "", f"{sys.executable} {__file__}"),
|
|
313
344
|
]
|
|
314
|
-
self.assertEqual(expected, list(
|
|
345
|
+
self.assertEqual(expected, list(InterpRegistryEntries(Cls)))
|
|
315
346
|
|
|
316
347
|
def test_inproc_server(self):
|
|
317
348
|
reg_clsid = GUID.create_new()
|
|
@@ -330,7 +361,7 @@ class Test_NonFrozen_RegistryEntries(ut.TestCase):
|
|
|
330
361
|
(HKCR, inproc_srv_sub, "PythonClass", full_classname),
|
|
331
362
|
(HKCR, inproc_srv_sub, "PythonPath", os.path.dirname(__file__)),
|
|
332
363
|
]
|
|
333
|
-
self.assertEqual(expected, list(
|
|
364
|
+
self.assertEqual(expected, list(InterpRegistryEntries(Cls)))
|
|
334
365
|
|
|
335
366
|
def test_inproc_server_reg_threading(self):
|
|
336
367
|
reg_clsid = GUID.create_new()
|
|
@@ -352,7 +383,7 @@ class Test_NonFrozen_RegistryEntries(ut.TestCase):
|
|
|
352
383
|
(HKCR, inproc_srv_sub, "PythonPath", os.path.dirname(__file__)),
|
|
353
384
|
(HKCR, inproc_srv_sub, "ThreadingModel", reg_threading),
|
|
354
385
|
]
|
|
355
|
-
self.assertEqual(expected, list(
|
|
386
|
+
self.assertEqual(expected, list(InterpRegistryEntries(Cls)))
|
|
356
387
|
|
|
357
388
|
def test_reg_typelib(self):
|
|
358
389
|
reg_clsid = GUID.create_new()
|
|
@@ -367,7 +398,7 @@ class Test_NonFrozen_RegistryEntries(ut.TestCase):
|
|
|
367
398
|
(HKCR, rf"CLSID\{reg_clsid}", "", ""),
|
|
368
399
|
(HKCR, rf"CLSID\{reg_clsid}\Typelib", "", libid),
|
|
369
400
|
]
|
|
370
|
-
self.assertEqual(expected, list(
|
|
401
|
+
self.assertEqual(expected, list(InterpRegistryEntries(Cls)))
|
|
371
402
|
|
|
372
403
|
def test_all_entries(self):
|
|
373
404
|
reg_clsid = GUID.create_new()
|
|
@@ -408,34 +439,17 @@ class Test_NonFrozen_RegistryEntries(ut.TestCase):
|
|
|
408
439
|
(HKCR, inproc_srv_sub, "ThreadingModel", reg_threading),
|
|
409
440
|
(HKCR, rf"{clsid_sub}\Typelib", "", libid),
|
|
410
441
|
]
|
|
411
|
-
self.assertEqual(expected, list(
|
|
442
|
+
self.assertEqual(expected, list(InterpRegistryEntries(Cls)))
|
|
412
443
|
|
|
413
444
|
|
|
414
|
-
class
|
|
415
|
-
|
|
416
|
-
def test_local_dll(self, _sys):
|
|
417
|
-
_sys.mock_add_spec(["executable", "frozen"])
|
|
418
|
-
_sys.executable = sys.executable
|
|
419
|
-
_sys.frozen = "dll"
|
|
420
|
-
reg_clsid = GUID.create_new()
|
|
421
|
-
reg_clsctx = comtypes.CLSCTX_LOCAL_SERVER
|
|
445
|
+
class Test_FrozenRegistryEntries(ut.TestCase):
|
|
446
|
+
SERVERDLL = r"my\target\server.dll"
|
|
422
447
|
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
clsid_sub = rf"CLSID\{reg_clsid}"
|
|
428
|
-
expected = [
|
|
429
|
-
(HKCR, clsid_sub, "", ""),
|
|
430
|
-
(HKCR, rf"{clsid_sub}\LocalServer32", "", sys.executable),
|
|
431
|
-
]
|
|
432
|
-
self.assertEqual(expected, list(RegistryEntries(Cls)))
|
|
448
|
+
# We do not test the scenario where `frozen` is `'dll'` but
|
|
449
|
+
# `frozendllhandle` is `None`, as it is not a situation
|
|
450
|
+
# we anticipate.
|
|
433
451
|
|
|
434
|
-
|
|
435
|
-
def test_local_frozendllhandle(self, _sys):
|
|
436
|
-
_sys.mock_add_spec(["frozen", "frozendllhandle"])
|
|
437
|
-
_sys.frozen = "dll"
|
|
438
|
-
_sys.frozendllhandle = 1234
|
|
452
|
+
def test_local_dll(self):
|
|
439
453
|
reg_clsid = GUID.create_new()
|
|
440
454
|
reg_clsctx = comtypes.CLSCTX_LOCAL_SERVER
|
|
441
455
|
|
|
@@ -443,53 +457,30 @@ class Test_Frozen_RegistryEntries(ut.TestCase):
|
|
|
443
457
|
_reg_clsid_ = reg_clsid
|
|
444
458
|
_reg_clsctx_ = reg_clsctx
|
|
445
459
|
|
|
460
|
+
# In such cases, the server does not start because the
|
|
461
|
+
# InprocServer32/LocalServer32 keys are not registered.
|
|
446
462
|
expected = [(HKCR, rf"CLSID\{reg_clsid}", "", "")]
|
|
447
|
-
|
|
463
|
+
entries = FrozenRegistryEntries(Cls, frozen="dll", frozendllhandle=1234)
|
|
464
|
+
self.assertEqual(expected, list(entries))
|
|
448
465
|
|
|
449
|
-
|
|
450
|
-
def test_inproc_windows_exe(self, _sys):
|
|
451
|
-
_sys.mock_add_spec(["frozen"])
|
|
452
|
-
_sys.frozen = "windows_exe"
|
|
466
|
+
def test_local_windows_exe(self):
|
|
453
467
|
reg_clsid = GUID.create_new()
|
|
454
|
-
reg_clsctx = comtypes.
|
|
455
|
-
|
|
456
|
-
class Cls:
|
|
457
|
-
_reg_clsid_ = reg_clsid
|
|
458
|
-
_reg_clsctx_ = reg_clsctx
|
|
459
|
-
|
|
460
|
-
expected = [(HKCR, rf"CLSID\{reg_clsid}", "", "")]
|
|
461
|
-
self.assertEqual(expected, list(RegistryEntries(Cls)))
|
|
462
|
-
|
|
463
|
-
@mock.patch.object(register, "_get_serverdll", lambda: r"my\target\server.dll")
|
|
464
|
-
@mock.patch.object(register, "sys")
|
|
465
|
-
def test_inproc_dll_frozendllhandle_clsid_to_class(self, _sys):
|
|
466
|
-
_sys.mock_add_spec(["frozen", "frozendllhandle"])
|
|
467
|
-
_sys.frozen = "dll"
|
|
468
|
-
_sys.frozendllhandle = 1234
|
|
469
|
-
reg_clsid = GUID.create_new()
|
|
470
|
-
reg_clsctx = comtypes.CLSCTX_INPROC_SERVER
|
|
468
|
+
reg_clsctx = comtypes.CLSCTX_LOCAL_SERVER
|
|
471
469
|
|
|
472
470
|
class Cls:
|
|
473
471
|
_reg_clsid_ = reg_clsid
|
|
474
472
|
_reg_clsctx_ = reg_clsctx
|
|
475
473
|
|
|
476
|
-
clsid_sub = rf"CLSID\{reg_clsid}"
|
|
477
|
-
inproc_srv_sub = rf"{clsid_sub}\InprocServer32"
|
|
478
474
|
expected = [
|
|
479
|
-
(HKCR,
|
|
480
|
-
(HKCR,
|
|
475
|
+
(HKCR, rf"CLSID\{reg_clsid}", "", ""),
|
|
476
|
+
(HKCR, rf"CLSID\{reg_clsid}\LocalServer32", "", sys.executable),
|
|
481
477
|
]
|
|
478
|
+
self.assertEqual(
|
|
479
|
+
expected, list(FrozenRegistryEntries(Cls, frozen="windows_exe"))
|
|
480
|
+
)
|
|
482
481
|
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
self.assertEqual(expected, list(RegistryEntries(Cls)))
|
|
486
|
-
|
|
487
|
-
@mock.patch.object(register, "_get_serverdll", lambda: r"my\target\server.dll")
|
|
488
|
-
@mock.patch.object(register, "sys")
|
|
489
|
-
def test_inproc_dll(self, _sys):
|
|
490
|
-
_sys.mock_add_spec(["frozen", "modules"])
|
|
491
|
-
_sys.frozen = "dll"
|
|
492
|
-
_sys.modules = sys.modules
|
|
482
|
+
@mock.patch.object(register, "_get_serverdll", return_value=SERVERDLL)
|
|
483
|
+
def test_inproc_dll(self, get_serverdll):
|
|
493
484
|
reg_clsid = GUID.create_new()
|
|
494
485
|
reg_clsctx = comtypes.CLSCTX_INPROC_SERVER
|
|
495
486
|
|
|
@@ -499,21 +490,17 @@ class Test_Frozen_RegistryEntries(ut.TestCase):
|
|
|
499
490
|
|
|
500
491
|
clsid_sub = rf"CLSID\{reg_clsid}"
|
|
501
492
|
inproc_srv_sub = rf"{clsid_sub}\InprocServer32"
|
|
502
|
-
full_classname = f"{__name__}.Cls"
|
|
503
493
|
expected = [
|
|
504
494
|
(HKCR, clsid_sub, "", ""),
|
|
505
|
-
(HKCR, inproc_srv_sub, "",
|
|
506
|
-
(HKCR, inproc_srv_sub, "PythonClass", full_classname),
|
|
507
|
-
(HKCR, inproc_srv_sub, "PythonPath", os.path.dirname(__file__)),
|
|
495
|
+
(HKCR, inproc_srv_sub, "", self.SERVERDLL),
|
|
508
496
|
]
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
_sys.modules = sys.modules
|
|
497
|
+
|
|
498
|
+
entries = FrozenRegistryEntries(Cls, frozen="dll", frozendllhandle=1234)
|
|
499
|
+
self.assertEqual(expected, list(entries))
|
|
500
|
+
get_serverdll.assert_called_once_with(1234)
|
|
501
|
+
|
|
502
|
+
@mock.patch.object(register, "_get_serverdll", return_value=SERVERDLL)
|
|
503
|
+
def test_inproc_reg_threading(self, get_serverdll):
|
|
517
504
|
reg_clsid = GUID.create_new()
|
|
518
505
|
reg_threading = "Both"
|
|
519
506
|
reg_clsctx = comtypes.CLSCTX_INPROC_SERVER
|
|
@@ -525,12 +512,13 @@ class Test_Frozen_RegistryEntries(ut.TestCase):
|
|
|
525
512
|
|
|
526
513
|
clsid_sub = rf"CLSID\{reg_clsid}"
|
|
527
514
|
inproc_srv_sub = rf"{clsid_sub}\InprocServer32"
|
|
528
|
-
full_classname = f"{__name__}.Cls"
|
|
529
515
|
expected = [
|
|
530
516
|
(HKCR, clsid_sub, "", ""),
|
|
531
|
-
(HKCR, inproc_srv_sub, "",
|
|
532
|
-
(HKCR, inproc_srv_sub, "PythonClass", full_classname),
|
|
533
|
-
(HKCR, inproc_srv_sub, "PythonPath", os.path.dirname(__file__)),
|
|
517
|
+
(HKCR, inproc_srv_sub, "", self.SERVERDLL),
|
|
534
518
|
(HKCR, inproc_srv_sub, "ThreadingModel", reg_threading),
|
|
535
519
|
]
|
|
536
|
-
self.assertEqual(
|
|
520
|
+
self.assertEqual(
|
|
521
|
+
expected,
|
|
522
|
+
list(FrozenRegistryEntries(Cls, frozen="dll", frozendllhandle=1234)),
|
|
523
|
+
)
|
|
524
|
+
get_serverdll.assert_called_once_with(1234)
|
|
@@ -1,12 +1,11 @@
|
|
|
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, GUID, shelllink
|
|
6
5
|
import comtypes.hresult
|
|
6
|
+
from comtypes import GUID, CoCreateInstance, shelllink
|
|
7
7
|
from comtypes.persist import IPersistFile
|
|
8
8
|
|
|
9
|
-
|
|
10
9
|
CLSID_ShellLink = GUID("{00021401-0000-0000-C000-000000000046}")
|
|
11
10
|
|
|
12
11
|
|