comtypes 1.4.6__zip → 1.4.8__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.6 → comtypes-1.4.8}/CHANGES.txt +36 -0
- {comtypes-1.4.6/comtypes.egg-info → comtypes-1.4.8}/PKG-INFO +32 -38
- {comtypes-1.4.6 → comtypes-1.4.8}/README.md +30 -36
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/__init__.py +1 -1
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/_comobject.py +0 -1
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/_memberspec.py +1 -1
- comtypes-1.4.8/comtypes/_meta.py +95 -0
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/_npsupport.py +2 -1
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/_post_coinit/__init__.py +1 -0
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/_post_coinit/bstr.py +13 -6
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/_post_coinit/misc.py +20 -39
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/_post_coinit/unknwn.py +94 -69
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/automation.py +9 -15
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/client/__init__.py +21 -31
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/client/_code_cache.py +1 -0
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/client/_events.py +0 -1
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/client/_generate.py +5 -5
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/client/lazybind.py +0 -5
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/git.py +1 -0
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/hints.pyi +6 -4
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/persist.py +19 -3
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/safearray.py +2 -6
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/server/__init__.py +1 -0
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/server/register.py +1 -0
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/shelllink.py +90 -34
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/test/TestComServer.py +1 -1
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/test/TestDispServer.py +1 -1
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/test/__init__.py +0 -1
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/test/find_memleak.py +0 -1
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/test/test_agilent.py +0 -1
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/test/test_clear_cache.py +1 -0
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/test/test_client.py +9 -0
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/test/test_createwrappers.py +0 -2
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/test/test_dispinterface.py +0 -1
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/test/test_excel.py +0 -1
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/test/test_inout_args.py +1 -1
- comtypes-1.4.8/comtypes/test/test_monikers.py +70 -0
- comtypes-1.4.8/comtypes/test/test_persist.py +40 -0
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/test/test_server.py +6 -0
- comtypes-1.4.8/comtypes/test/test_shelllink.py +129 -0
- comtypes-1.4.8/comtypes/test/test_storage.py +127 -0
- comtypes-1.4.8/comtypes/test/test_stream.py +131 -0
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/test/test_typeannotator.py +1 -1
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/test/test_urlhistory.py +1 -0
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/test/test_variant.py +0 -2
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/tools/codegenerator/namespaces.py +97 -27
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/tools/codegenerator/typeannotator.py +2 -4
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/tools/tlbparser.py +33 -32
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/tools/typedesc.py +2 -2
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/typeinfo.py +42 -43
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/util.py +1 -0
- {comtypes-1.4.6 → comtypes-1.4.8/comtypes.egg-info}/PKG-INFO +32 -38
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes.egg-info/SOURCES.txt +5 -1
- comtypes-1.4.8/pyproject.toml +54 -0
- {comtypes-1.4.6 → comtypes-1.4.8}/setup.cfg +1 -1
- comtypes-1.4.6/comtypes/_meta.py +0 -70
- comtypes-1.4.6/comtypes/test/test_istream.py +0 -53
- comtypes-1.4.6/pyproject.toml +0 -3
- {comtypes-1.4.6 → comtypes-1.4.8}/LICENSE.txt +0 -0
- {comtypes-1.4.6 → comtypes-1.4.8}/MANIFEST.in +0 -0
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/GUID.py +0 -0
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/_idl_stuff.py +0 -0
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/_py_instance_method.py +0 -0
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/_safearray.py +0 -0
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/_tlib_version_checker.py +0 -0
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/clear_cache.py +0 -0
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/client/_constants.py +0 -0
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/client/dynamic.py +0 -0
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/connectionpoints.py +0 -0
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/errorinfo.py +0 -0
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/hresult.py +0 -0
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/logutil.py +0 -0
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/messageloop.py +0 -0
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/patcher.py +0 -0
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/server/automation.py +0 -0
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/server/connectionpoints.py +0 -0
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/server/inprocserver.py +0 -0
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/server/localserver.py +0 -0
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/server/w_getopt.py +0 -0
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/stream.py +0 -0
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/test/TestComServer.idl +0 -0
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/test/TestComServer.tlb +0 -0
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/test/TestDispServer.idl +0 -0
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/test/TestDispServer.tlb +0 -0
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/test/mylib.idl +0 -0
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/test/mylib.tlb +0 -0
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/test/mytypelib.idl +0 -0
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/test/runtests.py +0 -0
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/test/setup.py +0 -0
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/test/test_BSTR.py +0 -0
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/test/test_DISPPARAMS.py +0 -0
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/test/test_GUID.py +0 -0
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/test/test_QueryService.py +0 -0
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/test/test_avmc.py +0 -0
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/test/test_basic.py +0 -0
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/test/test_casesensitivity.py +0 -0
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/test/test_client_dynamic.py +0 -0
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/test/test_client_regenerate_modules.py +0 -0
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/test/test_collections.py +0 -0
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/test/test_comserver.py +0 -0
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/test/test_dict.py +0 -0
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/test/test_dispifc_records.py +0 -0
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/test/test_dispifc_safearrays.py +0 -0
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/test/test_dyndispatch.py +0 -0
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/test/test_findgendir.py +0 -0
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/test/test_getactiveobj.py +0 -0
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/test/test_ie.py +0 -0
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/test/test_ienum.py +0 -0
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/test/test_imfattributes.py +0 -0
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/test/test_jscript.js +0 -0
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/test/test_midl_safearray_create.py +0 -0
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/test/test_msscript.py +0 -0
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/test/test_npsupport.py +0 -0
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/test/test_outparam.py +0 -0
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/test/test_propputref.py +0 -0
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/test/test_pump_events.py +0 -0
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/test/test_recordinfo.py +0 -0
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/test/test_safearray.py +0 -0
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/test/test_sapi.py +0 -0
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/test/test_showevents.py +0 -0
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/test/test_subinterface.py +0 -0
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/test/test_typeinfo.py +0 -0
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/test/test_win32com_interop.py +0 -0
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/test/test_wmi.py +0 -0
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/test/test_word.py +0 -0
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/test/urlhist.tlb +0 -0
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/tools/__init__.py +0 -0
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/tools/codegenerator/__init__.py +0 -0
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/tools/codegenerator/codegenerator.py +0 -0
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/tools/codegenerator/helpers.py +0 -0
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/tools/codegenerator/modulenamer.py +0 -0
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/tools/codegenerator/packing.py +0 -0
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/tools/typedesc_base.py +0 -0
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes/viewobject.py +0 -0
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes.egg-info/dependency_links.txt +0 -0
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes.egg-info/entry_points.txt +0 -0
- {comtypes-1.4.6 → comtypes-1.4.8}/comtypes.egg-info/top_level.txt +0 -0
- {comtypes-1.4.6 → comtypes-1.4.8}/setup.py +0 -0
|
@@ -1,27 +1,40 @@
|
|
|
1
|
-
from
|
|
2
|
-
from ctypes import
|
|
1
|
+
from ctypes import c_char_p, c_int, c_short, c_wchar_p
|
|
2
|
+
from ctypes import POINTER
|
|
3
|
+
from ctypes import byref, create_string_buffer, create_unicode_buffer
|
|
3
4
|
from ctypes.wintypes import DWORD, WIN32_FIND_DATAA, WIN32_FIND_DATAW, MAX_PATH
|
|
5
|
+
from typing import Tuple, TYPE_CHECKING
|
|
6
|
+
|
|
4
7
|
from comtypes import IUnknown, GUID, COMMETHOD, HRESULT, CoClass
|
|
5
8
|
|
|
9
|
+
|
|
10
|
+
if TYPE_CHECKING:
|
|
11
|
+
from comtypes import hints # type: ignore
|
|
12
|
+
|
|
13
|
+
|
|
6
14
|
# for GetPath
|
|
7
15
|
SLGP_SHORTPATH = 0x1
|
|
8
16
|
SLGP_UNCPRIORITY = 0x2
|
|
9
17
|
SLGP_RAWPATH = 0x4
|
|
10
18
|
|
|
11
19
|
# for SetShowCmd, GetShowCmd
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
20
|
+
SW_SHOWNORMAL = 0x01
|
|
21
|
+
SW_SHOWMAXIMIZED = 0x03
|
|
22
|
+
SW_SHOWMINNOACTIVE = 0x07
|
|
16
23
|
|
|
17
24
|
# for Resolve
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
+
SLR_INVOKE_MSI = 0x0080
|
|
26
|
+
SLR_NOLINKINFO = 0x0040
|
|
27
|
+
SLR_NO_UI = 0x0001
|
|
28
|
+
SLR_NOUPDATE = 0x0008
|
|
29
|
+
SLR_NOSEARCH = 0x0010
|
|
30
|
+
SLR_NOTRACK = 0x0020
|
|
31
|
+
SLR_UPDATE = 0x0004
|
|
32
|
+
|
|
33
|
+
# for Hotkey
|
|
34
|
+
HOTKEYF_ALT = 0x04
|
|
35
|
+
HOTKEYF_CONTROL = 0x02
|
|
36
|
+
HOTKEYF_EXT = 0x08
|
|
37
|
+
HOTKEYF_SHIFT = 0x01
|
|
25
38
|
|
|
26
39
|
# fake these...
|
|
27
40
|
ITEMIDLIST = c_int
|
|
@@ -113,31 +126,53 @@ class IShellLinkA(IUnknown):
|
|
|
113
126
|
COMMETHOD([], HRESULT, "SetPath", (["in"], c_char_p, "pszFile")),
|
|
114
127
|
]
|
|
115
128
|
|
|
116
|
-
|
|
129
|
+
if TYPE_CHECKING:
|
|
130
|
+
|
|
131
|
+
def GetIDList(self) -> hints.Incomplete: ...
|
|
132
|
+
def SetIDList(self, pidl: hints.Incomplete) -> hints.Incomplete: ...
|
|
133
|
+
def SetDescription(self, pszName: bytes) -> hints.Incomplete: ...
|
|
134
|
+
def SetWorkingDirectory(self, pszDir: bytes) -> hints.Hresult: ...
|
|
135
|
+
def SetArguments(self, pszArgs: bytes) -> hints.Hresult: ...
|
|
136
|
+
@property
|
|
137
|
+
def Hotkey(self) -> int: ...
|
|
138
|
+
@Hotkey.setter
|
|
139
|
+
def Hotkey(self, pwHotkey: int) -> None: ...
|
|
140
|
+
@property
|
|
141
|
+
def ShowCmd(self) -> int: ...
|
|
142
|
+
@ShowCmd.setter
|
|
143
|
+
def ShowCmd(self, piShowCmd: int) -> None: ...
|
|
144
|
+
def SetIconLocation(self, pszIconPath: bytes, iIcon: int) -> hints.Hresult: ...
|
|
145
|
+
def SetRelativePath(
|
|
146
|
+
self, pszPathRel: bytes, dwReserved: hints.Literal[0]
|
|
147
|
+
) -> hints.Hresult: ...
|
|
148
|
+
def Resolve(self, hwnd: int, fFlags: int) -> hints.Hresult: ...
|
|
149
|
+
def SetPath(self, pszFile: bytes) -> hints.Hresult: ...
|
|
150
|
+
|
|
151
|
+
def GetPath(self, flags: int = SLGP_SHORTPATH) -> bytes:
|
|
117
152
|
buf = create_string_buffer(MAX_PATH)
|
|
118
153
|
# We're not interested in WIN32_FIND_DATA
|
|
119
|
-
self.__com_GetPath(buf, MAX_PATH, None, flags)
|
|
154
|
+
self.__com_GetPath(buf, MAX_PATH, None, flags) # type: ignore
|
|
120
155
|
return buf.value
|
|
121
156
|
|
|
122
|
-
def GetDescription(self):
|
|
157
|
+
def GetDescription(self) -> bytes:
|
|
123
158
|
buf = create_string_buffer(1024)
|
|
124
|
-
self.__com_GetDescription(buf, 1024)
|
|
159
|
+
self.__com_GetDescription(buf, 1024) # type: ignore
|
|
125
160
|
return buf.value
|
|
126
161
|
|
|
127
|
-
def GetWorkingDirectory(self):
|
|
162
|
+
def GetWorkingDirectory(self) -> bytes:
|
|
128
163
|
buf = create_string_buffer(MAX_PATH)
|
|
129
|
-
self.__com_GetWorkingDirectory(buf, MAX_PATH)
|
|
164
|
+
self.__com_GetWorkingDirectory(buf, MAX_PATH) # type: ignore
|
|
130
165
|
return buf.value
|
|
131
166
|
|
|
132
|
-
def GetArguments(self):
|
|
167
|
+
def GetArguments(self) -> bytes:
|
|
133
168
|
buf = create_string_buffer(1024)
|
|
134
|
-
self.__com_GetArguments(buf, 1024)
|
|
169
|
+
self.__com_GetArguments(buf, 1024) # type: ignore
|
|
135
170
|
return buf.value
|
|
136
171
|
|
|
137
|
-
def GetIconLocation(self):
|
|
172
|
+
def GetIconLocation(self) -> Tuple[bytes, int]:
|
|
138
173
|
iIcon = c_int()
|
|
139
174
|
buf = create_string_buffer(MAX_PATH)
|
|
140
|
-
self.__com_GetIconLocation(buf, MAX_PATH, byref(iIcon))
|
|
175
|
+
self.__com_GetIconLocation(buf, MAX_PATH, byref(iIcon)) # type: ignore
|
|
141
176
|
return buf.value, iIcon.value
|
|
142
177
|
|
|
143
178
|
|
|
@@ -226,31 +261,53 @@ class IShellLinkW(IUnknown):
|
|
|
226
261
|
COMMETHOD([], HRESULT, "SetPath", (["in"], c_wchar_p, "pszFile")),
|
|
227
262
|
]
|
|
228
263
|
|
|
229
|
-
|
|
264
|
+
if TYPE_CHECKING:
|
|
265
|
+
|
|
266
|
+
def GetIDList(self) -> hints.Incomplete: ...
|
|
267
|
+
def SetIDList(self, pidl: hints.Incomplete) -> hints.Incomplete: ...
|
|
268
|
+
def SetDescription(self, pszName: str) -> hints.Incomplete: ...
|
|
269
|
+
def SetWorkingDirectory(self, pszDir: str) -> hints.Hresult: ...
|
|
270
|
+
def SetArguments(self, pszArgs: str) -> hints.Hresult: ...
|
|
271
|
+
@property
|
|
272
|
+
def Hotkey(self) -> int: ...
|
|
273
|
+
@Hotkey.setter
|
|
274
|
+
def Hotkey(self, pwHotkey: int) -> None: ...
|
|
275
|
+
@property
|
|
276
|
+
def ShowCmd(self) -> int: ...
|
|
277
|
+
@ShowCmd.setter
|
|
278
|
+
def ShowCmd(self, piShowCmd: int) -> None: ...
|
|
279
|
+
def SetIconLocation(self, pszIconPath: str, iIcon: int) -> hints.Hresult: ...
|
|
280
|
+
def SetRelativePath(
|
|
281
|
+
self, pszPathRel: str, dwReserved: hints.Literal[0]
|
|
282
|
+
) -> hints.Hresult: ...
|
|
283
|
+
def Resolve(self, hwnd: int, fFlags: int) -> hints.Hresult: ...
|
|
284
|
+
def SetPath(self, pszFile: str) -> hints.Hresult: ...
|
|
285
|
+
|
|
286
|
+
def GetPath(self, flags: int = SLGP_SHORTPATH) -> str:
|
|
230
287
|
buf = create_unicode_buffer(MAX_PATH)
|
|
231
288
|
# We're not interested in WIN32_FIND_DATA
|
|
232
|
-
self.__com_GetPath(buf, MAX_PATH, None, flags)
|
|
289
|
+
self.__com_GetPath(buf, MAX_PATH, None, flags) # type: ignore
|
|
233
290
|
return buf.value
|
|
234
291
|
|
|
235
|
-
def GetDescription(self):
|
|
292
|
+
def GetDescription(self) -> str:
|
|
236
293
|
buf = create_unicode_buffer(1024)
|
|
237
|
-
self.__com_GetDescription(buf, 1024)
|
|
294
|
+
self.__com_GetDescription(buf, 1024) # type: ignore
|
|
238
295
|
return buf.value
|
|
239
296
|
|
|
240
|
-
def GetWorkingDirectory(self):
|
|
297
|
+
def GetWorkingDirectory(self) -> str:
|
|
241
298
|
buf = create_unicode_buffer(MAX_PATH)
|
|
242
|
-
self.__com_GetWorkingDirectory(buf, MAX_PATH)
|
|
299
|
+
self.__com_GetWorkingDirectory(buf, MAX_PATH) # type: ignore
|
|
243
300
|
return buf.value
|
|
244
301
|
|
|
245
|
-
def GetArguments(self):
|
|
302
|
+
def GetArguments(self) -> str:
|
|
246
303
|
buf = create_unicode_buffer(1024)
|
|
247
|
-
self.__com_GetArguments(buf, 1024)
|
|
304
|
+
self.__com_GetArguments(buf, 1024) # type: ignore
|
|
248
305
|
return buf.value
|
|
249
306
|
|
|
250
|
-
def GetIconLocation(self):
|
|
307
|
+
def GetIconLocation(self) -> Tuple[str, int]:
|
|
251
308
|
iIcon = c_int()
|
|
252
309
|
buf = create_unicode_buffer(MAX_PATH)
|
|
253
|
-
self.__com_GetIconLocation(buf, MAX_PATH, byref(iIcon))
|
|
310
|
+
self.__com_GetIconLocation(buf, MAX_PATH, byref(iIcon)) # type: ignore
|
|
254
311
|
return buf.value, iIcon.value
|
|
255
312
|
|
|
256
313
|
|
|
@@ -263,7 +320,6 @@ class ShellLink(CoClass):
|
|
|
263
320
|
|
|
264
321
|
|
|
265
322
|
if __name__ == "__main__":
|
|
266
|
-
|
|
267
323
|
import sys
|
|
268
324
|
import comtypes
|
|
269
325
|
from comtypes.client import CreateObject
|
|
@@ -33,6 +33,7 @@ from comtypes.gen import TestComServerLib
|
|
|
33
33
|
|
|
34
34
|
################################################################
|
|
35
35
|
|
|
36
|
+
|
|
36
37
|
# Implement the CoClass. Use the coclass from the wrapper as base
|
|
37
38
|
# class, and use DualDispMixin as base class which provides default
|
|
38
39
|
# implementations of IDispatch, IProvideClassInfo, IProvideClassInfo2
|
|
@@ -42,7 +43,6 @@ class TestComServer(
|
|
|
42
43
|
TestComServerLib.TestComServer, # the coclass from the typelib wrapper
|
|
43
44
|
comtypes.server.connectionpoints.ConnectableObjectMixin,
|
|
44
45
|
):
|
|
45
|
-
|
|
46
46
|
# The default interface from the typelib MUST be the first
|
|
47
47
|
# interface, other interfaces can follow
|
|
48
48
|
|
|
@@ -31,6 +31,7 @@ from comtypes.gen import TestDispServerLib
|
|
|
31
31
|
|
|
32
32
|
################################################################
|
|
33
33
|
|
|
34
|
+
|
|
34
35
|
# Implement the CoClass by defining a subclass of the
|
|
35
36
|
# TestDispServerLib.TestDispServer class in the wrapper file. The
|
|
36
37
|
# COMObject base class provides default implementations of the
|
|
@@ -42,7 +43,6 @@ class TestDispServer(
|
|
|
42
43
|
TestDispServerLib.TestDispServer, # the coclass from the typelib wrapper
|
|
43
44
|
comtypes.server.connectionpoints.ConnectableObjectMixin,
|
|
44
45
|
):
|
|
45
|
-
|
|
46
46
|
# The default interface from the typelib MUST be the first
|
|
47
47
|
# interface, other interfaces can follow
|
|
48
48
|
|
|
@@ -77,6 +77,15 @@ class Test_GetModule(ut.TestCase):
|
|
|
77
77
|
|
|
78
78
|
self.assertTrue(issubclass(mod.IStream, ISequentialStream))
|
|
79
79
|
|
|
80
|
+
def test_msvidctl(self):
|
|
81
|
+
with contextlib.redirect_stdout(None): # supress warnings
|
|
82
|
+
mod = comtypes.client.GetModule("msvidctl.dll")
|
|
83
|
+
from comtypes.persist import IPersist
|
|
84
|
+
from comtypes.typeinfo import IRecordInfo
|
|
85
|
+
|
|
86
|
+
self.assertIs(mod.IPersist, IPersist)
|
|
87
|
+
self.assertIs(mod.IRecordInfo, IRecordInfo)
|
|
88
|
+
|
|
80
89
|
def test_no_replacing_Patch_namespace(self):
|
|
81
90
|
# NOTE: An object named `Patch` is defined in some dll.
|
|
82
91
|
# Depending on how the namespace is defined in the static module,
|
|
@@ -278,7 +278,7 @@ class Test_ArgspecPermutations(ut.TestCase):
|
|
|
278
278
|
(orig_0th, *orig_call_args), orig_kw = orig.call_args
|
|
279
279
|
self.assertEqual(orig_kw, {})
|
|
280
280
|
self.assertIs(orig_0th, self_)
|
|
281
|
-
for (
|
|
281
|
+
for (typ, f, val), orig in zip(
|
|
282
282
|
testing_params.call_args_validators, orig_call_args
|
|
283
283
|
):
|
|
284
284
|
self.assertIsInstance(orig, typ)
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
from _ctypes import COMError
|
|
2
|
+
from ctypes import byref, POINTER
|
|
3
|
+
import contextlib
|
|
4
|
+
import unittest
|
|
5
|
+
|
|
6
|
+
import comtypes
|
|
7
|
+
from comtypes.client import GetModule, CreateObject
|
|
8
|
+
from comtypes import hresult, GUID
|
|
9
|
+
|
|
10
|
+
with contextlib.redirect_stdout(None): # supress warnings
|
|
11
|
+
GetModule("msvidctl.dll")
|
|
12
|
+
from comtypes.gen import MSVidCtlLib as msvidctl
|
|
13
|
+
from comtypes.gen.MSVidCtlLib import IBindCtx, IMoniker, IRunningObjectTable
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
MKSYS_ITEMMONIKER = 4
|
|
17
|
+
ROTFLAGS_ALLOWANYCLIENT = 1
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def _create_item_moniker(delim: str, item: str) -> IMoniker:
|
|
21
|
+
mon = POINTER(IMoniker)()
|
|
22
|
+
comtypes._ole32.CreateItemMoniker(delim, item, byref(mon))
|
|
23
|
+
return mon # type: ignore
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def _create_bctx() -> IBindCtx:
|
|
27
|
+
bctx = POINTER(IBindCtx)()
|
|
28
|
+
# The first parameter is reserved and must be 0.
|
|
29
|
+
comtypes._ole32.CreateBindCtx(0, byref(bctx))
|
|
30
|
+
return bctx # type: ignore
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def _create_rot() -> IRunningObjectTable:
|
|
34
|
+
rot = POINTER(IRunningObjectTable)()
|
|
35
|
+
# The first parameter is reserved and must be 0.
|
|
36
|
+
comtypes._ole32.GetRunningObjectTable(0, byref(rot))
|
|
37
|
+
return rot # type: ignore
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
class Test_IMoniker(unittest.TestCase):
|
|
41
|
+
def test_IsSystemMoniker(self):
|
|
42
|
+
item_id = str(GUID.create_new())
|
|
43
|
+
mon = _create_item_moniker("!", item_id)
|
|
44
|
+
self.assertEqual(mon.IsSystemMoniker(), MKSYS_ITEMMONIKER)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
class Test_IBindCtx(unittest.TestCase):
|
|
48
|
+
def test_EnumObjectParam(self):
|
|
49
|
+
bctx = _create_bctx()
|
|
50
|
+
with self.assertRaises(COMError) as err_ctx:
|
|
51
|
+
# calling `EnumObjectParam` results in a return value of E_NOTIMPL.
|
|
52
|
+
# https://learn.microsoft.com/en-us/windows/win32/api/objidl/nf-objidl-ibindctx-enumobjectparam#notes-to-callers
|
|
53
|
+
bctx.EnumObjectParam()
|
|
54
|
+
self.assertEqual(err_ctx.exception.hresult, hresult.E_NOTIMPL)
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
class Test_IRunningObjectTable(unittest.TestCase):
|
|
58
|
+
def test_register_and_revoke_item_moniker(self):
|
|
59
|
+
vidctl = CreateObject(msvidctl.MSVidCtl, interface=msvidctl.IMSVidCtl)
|
|
60
|
+
item_id = str(GUID.create_new())
|
|
61
|
+
mon = _create_item_moniker("!", item_id)
|
|
62
|
+
rot = _create_rot()
|
|
63
|
+
bctx = _create_bctx()
|
|
64
|
+
self.assertEqual(mon.IsRunning(bctx, None, None), hresult.S_FALSE)
|
|
65
|
+
dw_reg = rot.Register(ROTFLAGS_ALLOWANYCLIENT, vidctl, mon)
|
|
66
|
+
self.assertEqual(mon.IsRunning(bctx, None, None), hresult.S_OK)
|
|
67
|
+
self.assertEqual(f"!{item_id}", mon.GetDisplayName(bctx, None))
|
|
68
|
+
self.assertEqual(rot.GetObject(mon).QueryInterface(msvidctl.IMSVidCtl), vidctl)
|
|
69
|
+
rot.Revoke(dw_reg)
|
|
70
|
+
self.assertEqual(mon.IsRunning(bctx, None, None), hresult.S_FALSE)
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
import tempfile
|
|
3
|
+
import unittest as ut
|
|
4
|
+
|
|
5
|
+
from comtypes import CoCreateInstance, GUID, IPersist
|
|
6
|
+
from comtypes import persist
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
CLSID_ShellLink = GUID("{00021401-0000-0000-C000-000000000046}")
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class Test_IPersist(ut.TestCase):
|
|
13
|
+
def test_GetClassID(self):
|
|
14
|
+
p = CoCreateInstance(CLSID_ShellLink).QueryInterface(IPersist)
|
|
15
|
+
self.assertEqual(p.GetClassID(), CLSID_ShellLink)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class Test_IPersistFile(ut.TestCase):
|
|
19
|
+
def setUp(self):
|
|
20
|
+
td = tempfile.TemporaryDirectory()
|
|
21
|
+
self.addCleanup(td.cleanup)
|
|
22
|
+
self.tmp_dir = Path(td.name)
|
|
23
|
+
|
|
24
|
+
def _create_pf(self) -> persist.IPersistFile:
|
|
25
|
+
return CoCreateInstance(CLSID_ShellLink).QueryInterface(persist.IPersistFile)
|
|
26
|
+
|
|
27
|
+
def test_load(self):
|
|
28
|
+
pf = self._create_pf()
|
|
29
|
+
tgt_file = (self.tmp_dir / "tgt.txt").resolve()
|
|
30
|
+
tgt_file.touch()
|
|
31
|
+
pf.Load(str(tgt_file), persist.STGM_DIRECT)
|
|
32
|
+
self.assertEqual(pf.GetCurFile(), str(tgt_file))
|
|
33
|
+
|
|
34
|
+
def test_save(self):
|
|
35
|
+
pf = self._create_pf()
|
|
36
|
+
tgt_file = self.tmp_dir / "tgt.txt"
|
|
37
|
+
self.assertFalse(tgt_file.exists())
|
|
38
|
+
pf.Save(str(tgt_file), True)
|
|
39
|
+
self.assertEqual(pf.GetCurFile(), str(tgt_file))
|
|
40
|
+
self.assertTrue(tgt_file.exists())
|
|
@@ -125,6 +125,7 @@ try:
|
|
|
125
125
|
)
|
|
126
126
|
# implementation
|
|
127
127
|
Name = "foo"
|
|
128
|
+
|
|
128
129
|
# test
|
|
129
130
|
def test_Name(self):
|
|
130
131
|
p = wrap(self.create())
|
|
@@ -137,6 +138,7 @@ try:
|
|
|
137
138
|
itf.add(
|
|
138
139
|
"[id(101)] HRESULT MixedInOut([in] int a, [out] int *b, [in] int c, [out] int *d);"
|
|
139
140
|
)
|
|
141
|
+
|
|
140
142
|
# implementation
|
|
141
143
|
def MixedInOut(self, a, c):
|
|
142
144
|
return a + 1, c + 1
|
|
@@ -151,6 +153,7 @@ try:
|
|
|
151
153
|
itf.add(
|
|
152
154
|
"[id(102)] HRESULT MultiInOutArgs([in, out] int *pa, [in, out] int *pb);"
|
|
153
155
|
)
|
|
156
|
+
|
|
154
157
|
# implementation
|
|
155
158
|
def MultiInOutArgs(self, pa, pb):
|
|
156
159
|
return pa[0] * 3, pb[0] * 4
|
|
@@ -174,6 +177,7 @@ try:
|
|
|
174
177
|
################
|
|
175
178
|
# definition
|
|
176
179
|
itf.add("HRESULT MultiInOutArgs3([out] int *pa, [out] int *pb);")
|
|
180
|
+
|
|
177
181
|
# implementation
|
|
178
182
|
def MultiInOutArgs3(self):
|
|
179
183
|
return 42, 43
|
|
@@ -186,6 +190,7 @@ try:
|
|
|
186
190
|
################
|
|
187
191
|
# definition
|
|
188
192
|
itf.add("HRESULT MultiInOutArgs4([out] int *pa, [in, out] int *pb);")
|
|
193
|
+
|
|
189
194
|
# implementation
|
|
190
195
|
def MultiInOutArgs4(self, pb):
|
|
191
196
|
return pb[0] + 3, pb[0] + 4
|
|
@@ -238,6 +243,7 @@ try:
|
|
|
238
243
|
# Test events.
|
|
239
244
|
itf.add("""HRESULT DoSomething();""")
|
|
240
245
|
outgoing.add("""[id(103)] HRESULT OnSomething();""")
|
|
246
|
+
|
|
241
247
|
# implementation
|
|
242
248
|
def DoSomething(self):
|
|
243
249
|
"Implement the DoSomething method"
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
import tempfile
|
|
3
|
+
import unittest as ut
|
|
4
|
+
|
|
5
|
+
from comtypes import CoCreateInstance, GUID, shelllink
|
|
6
|
+
import comtypes.hresult
|
|
7
|
+
from comtypes.persist import IPersistFile
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
CLSID_ShellLink = GUID("{00021401-0000-0000-C000-000000000046}")
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class Test_IShellLinkA(ut.TestCase):
|
|
14
|
+
def setUp(self):
|
|
15
|
+
td = tempfile.TemporaryDirectory()
|
|
16
|
+
self.addCleanup(td.cleanup)
|
|
17
|
+
self.tmp_dir = Path(td.name)
|
|
18
|
+
self.src_file = (self.tmp_dir / "src.txt").resolve()
|
|
19
|
+
self.src_file.touch()
|
|
20
|
+
|
|
21
|
+
def _create_shortcut(self) -> shelllink.IShellLinkA:
|
|
22
|
+
return CoCreateInstance(CLSID_ShellLink, interface=shelllink.IShellLinkA)
|
|
23
|
+
|
|
24
|
+
def test_set_and_get_path(self):
|
|
25
|
+
shortcut = self._create_shortcut()
|
|
26
|
+
pf = shortcut.QueryInterface(IPersistFile)
|
|
27
|
+
self.assertEqual(pf.IsDirty(), comtypes.hresult.S_FALSE)
|
|
28
|
+
shortcut.SetPath(str(self.src_file).encode("utf-8"))
|
|
29
|
+
self.assertEqual(pf.IsDirty(), comtypes.hresult.S_OK)
|
|
30
|
+
self.assertEqual(
|
|
31
|
+
shortcut.GetPath(shelllink.SLGP_UNCPRIORITY),
|
|
32
|
+
str(self.src_file).encode("utf-8"),
|
|
33
|
+
)
|
|
34
|
+
lnk_file = (self.tmp_dir / "new.lnk").resolve()
|
|
35
|
+
self.assertFalse(lnk_file.exists())
|
|
36
|
+
pf.Save(str(lnk_file), True)
|
|
37
|
+
self.assertTrue(lnk_file.exists())
|
|
38
|
+
self.assertEqual(pf.GetCurFile(), str(lnk_file))
|
|
39
|
+
|
|
40
|
+
def test_set_and_get_working_directory(self):
|
|
41
|
+
shortcut = self._create_shortcut()
|
|
42
|
+
shortcut.SetWorkingDirectory(str(self.tmp_dir).encode("utf-8"))
|
|
43
|
+
self.assertEqual(
|
|
44
|
+
shortcut.GetWorkingDirectory(), str(self.tmp_dir).encode("utf-8")
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
def test_set_and_get_arguments(self):
|
|
48
|
+
shortcut = self._create_shortcut()
|
|
49
|
+
shortcut.SetArguments(b"-f")
|
|
50
|
+
self.assertEqual(shortcut.GetArguments(), b"-f")
|
|
51
|
+
|
|
52
|
+
def test_set_and_get_hotkey(self):
|
|
53
|
+
hotkey = shelllink.HOTKEYF_ALT | shelllink.HOTKEYF_CONTROL
|
|
54
|
+
shortcut = self._create_shortcut()
|
|
55
|
+
shortcut.Hotkey = hotkey
|
|
56
|
+
self.assertEqual(shortcut.Hotkey, hotkey)
|
|
57
|
+
|
|
58
|
+
def test_set_and_get_showcmd(self):
|
|
59
|
+
shortcut = self._create_shortcut()
|
|
60
|
+
shortcut.ShowCmd = shelllink.SW_SHOWMAXIMIZED
|
|
61
|
+
self.assertEqual(shortcut.ShowCmd, shelllink.SW_SHOWMAXIMIZED)
|
|
62
|
+
|
|
63
|
+
def test_set_and_get_icon_location(self):
|
|
64
|
+
shortcut = self._create_shortcut()
|
|
65
|
+
shortcut.SetIconLocation(str(self.src_file).encode("utf-8"), 1)
|
|
66
|
+
icon_path, index = shortcut.GetIconLocation()
|
|
67
|
+
self.assertEqual(icon_path, str(self.src_file).encode("utf-8"))
|
|
68
|
+
self.assertEqual(index, 1)
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
class Test_IShellLinkW(ut.TestCase):
|
|
72
|
+
def setUp(self):
|
|
73
|
+
td = tempfile.TemporaryDirectory()
|
|
74
|
+
self.addCleanup(td.cleanup)
|
|
75
|
+
self.tmp_dir = Path(td.name)
|
|
76
|
+
self.src_file = (self.tmp_dir / "src.txt").resolve()
|
|
77
|
+
self.src_file.touch()
|
|
78
|
+
|
|
79
|
+
def _create_shortcut(self) -> shelllink.IShellLinkW:
|
|
80
|
+
return CoCreateInstance(CLSID_ShellLink, interface=shelllink.IShellLinkW)
|
|
81
|
+
|
|
82
|
+
def test_set_and_get_path(self):
|
|
83
|
+
shortcut = self._create_shortcut()
|
|
84
|
+
pf = shortcut.QueryInterface(IPersistFile)
|
|
85
|
+
self.assertEqual(pf.IsDirty(), comtypes.hresult.S_FALSE)
|
|
86
|
+
shortcut.SetPath(str(self.src_file))
|
|
87
|
+
self.assertEqual(pf.IsDirty(), comtypes.hresult.S_OK)
|
|
88
|
+
self.assertEqual(
|
|
89
|
+
shortcut.GetPath(shelllink.SLGP_UNCPRIORITY),
|
|
90
|
+
str(self.src_file),
|
|
91
|
+
)
|
|
92
|
+
lnk_file = (self.tmp_dir / "new.lnk").resolve()
|
|
93
|
+
self.assertFalse(lnk_file.exists())
|
|
94
|
+
pf.Save(str(lnk_file), True)
|
|
95
|
+
self.assertTrue(lnk_file.exists())
|
|
96
|
+
self.assertEqual(pf.GetCurFile(), str(lnk_file))
|
|
97
|
+
|
|
98
|
+
def test_set_and_get_description(self):
|
|
99
|
+
shortcut = self._create_shortcut()
|
|
100
|
+
shortcut.SetDescription("sample")
|
|
101
|
+
self.assertEqual(shortcut.GetDescription(), "sample")
|
|
102
|
+
|
|
103
|
+
def test_set_and_get_working_directory(self):
|
|
104
|
+
shortcut = self._create_shortcut()
|
|
105
|
+
shortcut.SetWorkingDirectory(str(self.tmp_dir))
|
|
106
|
+
self.assertEqual(shortcut.GetWorkingDirectory(), str(self.tmp_dir))
|
|
107
|
+
|
|
108
|
+
def test_set_and_get_arguments(self):
|
|
109
|
+
shortcut = self._create_shortcut()
|
|
110
|
+
shortcut.SetArguments("-f")
|
|
111
|
+
self.assertEqual(shortcut.GetArguments(), "-f")
|
|
112
|
+
|
|
113
|
+
def test_set_and_get_hotkey(self):
|
|
114
|
+
hotkey = shelllink.HOTKEYF_ALT | shelllink.HOTKEYF_CONTROL
|
|
115
|
+
shortcut = self._create_shortcut()
|
|
116
|
+
shortcut.Hotkey = hotkey
|
|
117
|
+
self.assertEqual(shortcut.Hotkey, hotkey)
|
|
118
|
+
|
|
119
|
+
def test_set_and_get_showcmd(self):
|
|
120
|
+
shortcut = self._create_shortcut()
|
|
121
|
+
shortcut.ShowCmd = shelllink.SW_SHOWMAXIMIZED
|
|
122
|
+
self.assertEqual(shortcut.ShowCmd, shelllink.SW_SHOWMAXIMIZED)
|
|
123
|
+
|
|
124
|
+
def test_set_and_get_icon_location(self):
|
|
125
|
+
shortcut = self._create_shortcut()
|
|
126
|
+
shortcut.SetIconLocation(str(self.src_file), 1)
|
|
127
|
+
icon_path, index = shortcut.GetIconLocation()
|
|
128
|
+
self.assertEqual(icon_path, str(self.src_file))
|
|
129
|
+
self.assertEqual(index, 1)
|