comtypes 1.4.15__tar.gz → 1.4.16__tar.gz

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.
Files changed (167) hide show
  1. {comtypes-1.4.15 → comtypes-1.4.16}/CHANGES.txt +19 -0
  2. {comtypes-1.4.15/comtypes.egg-info → comtypes-1.4.16}/PKG-INFO +1 -1
  3. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/__init__.py +1 -1
  4. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/client/lazybind.py +1 -5
  5. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/logutil.py +16 -5
  6. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/shelllink.py +24 -7
  7. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/test/__init__.py +0 -28
  8. comtypes-1.4.16/comtypes/test/gdi_helper.py +202 -0
  9. comtypes-1.4.16/comtypes/test/monikers_helper.py +73 -0
  10. comtypes-1.4.16/comtypes/test/test_bctx.py +143 -0
  11. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/test/test_client.py +34 -1
  12. comtypes-1.4.16/comtypes/test/test_client_dynamic.py +138 -0
  13. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/test/test_comobject.py +57 -2
  14. comtypes-1.4.16/comtypes/test/test_connectionpoints.py +128 -0
  15. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/test/test_getactiveobj.py +10 -0
  16. comtypes-1.4.16/comtypes/test/test_git.py +177 -0
  17. comtypes-1.4.16/comtypes/test/test_logutil.py +257 -0
  18. comtypes-1.4.16/comtypes/test/test_moniker.py +583 -0
  19. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/test/test_rot.py +31 -1
  20. comtypes-1.4.16/comtypes/test/test_server_automation.py +135 -0
  21. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/test/test_shelllink.py +79 -0
  22. comtypes-1.4.16/comtypes/test/test_storage.py +329 -0
  23. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/test/test_stream.py +1 -175
  24. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/test/test_subinterface.py +2 -9
  25. comtypes-1.4.16/comtypes/test/test_typeinfo_create.py +449 -0
  26. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/test/test_viewobject.py +39 -0
  27. comtypes-1.4.16/comtypes/test/time_structs_helper.py +39 -0
  28. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/typeinfo.py +2 -8
  29. {comtypes-1.4.15 → comtypes-1.4.16/comtypes.egg-info}/PKG-INFO +1 -1
  30. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes.egg-info/SOURCES.txt +7 -0
  31. comtypes-1.4.15/comtypes/test/monikers_helper.py +0 -31
  32. comtypes-1.4.15/comtypes/test/test_bctx.py +0 -66
  33. comtypes-1.4.15/comtypes/test/test_client_dynamic.py +0 -67
  34. comtypes-1.4.15/comtypes/test/test_moniker.py +0 -68
  35. comtypes-1.4.15/comtypes/test/test_storage.py +0 -289
  36. {comtypes-1.4.15 → comtypes-1.4.16}/LICENSE.txt +0 -0
  37. {comtypes-1.4.15 → comtypes-1.4.16}/MANIFEST.in +0 -0
  38. {comtypes-1.4.15 → comtypes-1.4.16}/README.md +0 -0
  39. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/GUID.py +0 -0
  40. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/_comobject.py +0 -0
  41. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/_memberspec.py +0 -0
  42. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/_meta.py +0 -0
  43. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/_npsupport.py +0 -0
  44. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/_post_coinit/__init__.py +0 -0
  45. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/_post_coinit/_cominterface_meta_patcher.py +0 -0
  46. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/_post_coinit/activeobj.py +0 -0
  47. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/_post_coinit/bstr.py +0 -0
  48. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/_post_coinit/instancemethod.py +0 -0
  49. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/_post_coinit/misc.py +0 -0
  50. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/_post_coinit/unknwn.py +0 -0
  51. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/_safearray.py +0 -0
  52. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/_tlib_version_checker.py +0 -0
  53. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/_vtbl.py +0 -0
  54. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/automation.py +0 -0
  55. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/clear_cache.py +0 -0
  56. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/client/__init__.py +0 -0
  57. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/client/_activeobj.py +0 -0
  58. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/client/_code_cache.py +0 -0
  59. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/client/_constants.py +0 -0
  60. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/client/_create.py +0 -0
  61. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/client/_events.py +0 -0
  62. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/client/_generate.py +0 -0
  63. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/client/_managing.py +0 -0
  64. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/client/dynamic.py +0 -0
  65. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/connectionpoints.py +0 -0
  66. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/errorinfo.py +0 -0
  67. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/git.py +0 -0
  68. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/hints.pyi +0 -0
  69. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/hresult.py +0 -0
  70. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/malloc.py +0 -0
  71. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/messageloop.py +0 -0
  72. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/patcher.py +0 -0
  73. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/persist.py +0 -0
  74. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/safearray.py +0 -0
  75. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/server/__init__.py +0 -0
  76. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/server/automation.py +0 -0
  77. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/server/connectionpoints.py +0 -0
  78. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/server/inprocserver.py +0 -0
  79. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/server/localserver.py +0 -0
  80. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/server/register.py +0 -0
  81. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/server/w_getopt.py +0 -0
  82. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/stream.py +0 -0
  83. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/test/TestComServer.idl +0 -0
  84. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/test/TestComServer.py +0 -0
  85. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/test/TestComServer.tlb +0 -0
  86. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/test/TestDispServer.idl +0 -0
  87. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/test/TestDispServer.py +0 -0
  88. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/test/TestDispServer.tlb +0 -0
  89. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/test/find_memleak.py +0 -0
  90. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/test/mylib.idl +0 -0
  91. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/test/mylib.tlb +0 -0
  92. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/test/mytypelib.idl +0 -0
  93. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/test/runtests.py +0 -0
  94. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/test/setup.py +0 -0
  95. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/test/test_BSTR.py +0 -0
  96. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/test/test_DISPPARAMS.py +0 -0
  97. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/test/test_GUID.py +0 -0
  98. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/test/test_QueryService.py +0 -0
  99. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/test/test_agilent.py +0 -0
  100. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/test/test_avmc.py +0 -0
  101. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/test/test_basic.py +0 -0
  102. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/test/test_casesensitivity.py +0 -0
  103. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/test/test_classfactory.py +0 -0
  104. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/test/test_clear_cache.py +0 -0
  105. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/test/test_client_regenerate_modules.py +0 -0
  106. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/test/test_collections.py +0 -0
  107. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/test/test_comserver.py +0 -0
  108. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/test/test_createwrappers.py +0 -0
  109. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/test/test_dict.py +0 -0
  110. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/test/test_dispifc_records.py +0 -0
  111. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/test/test_dispifc_safearrays.py +0 -0
  112. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/test/test_dispinterface.py +0 -0
  113. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/test/test_dyndispatch.py +0 -0
  114. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/test/test_errorinfo.py +0 -0
  115. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/test/test_eventinterface.py +0 -0
  116. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/test/test_excel.py +0 -0
  117. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/test/test_findgendir.py +0 -0
  118. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/test/test_hresult.py +0 -0
  119. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/test/test_ienum.py +0 -0
  120. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/test/test_imfattributes.py +0 -0
  121. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/test/test_inout_args.py +0 -0
  122. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/test/test_jscript.js +0 -0
  123. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/test/test_malloc.py +0 -0
  124. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/test/test_messageloop.py +0 -0
  125. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/test/test_midl_safearray_create.py +0 -0
  126. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/test/test_msscript.py +0 -0
  127. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/test/test_npsupport.py +0 -0
  128. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/test/test_outparam.py +0 -0
  129. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/test/test_persist.py +0 -0
  130. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/test/test_pump_events.py +0 -0
  131. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/test/test_puredispatch.py +0 -0
  132. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/test/test_recordinfo.py +0 -0
  133. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/test/test_safearray.py +0 -0
  134. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/test/test_sapi.py +0 -0
  135. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/test/test_server.py +0 -0
  136. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/test/test_server_register.py +0 -0
  137. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/test/test_showevents.py +0 -0
  138. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/test/test_typeannotator.py +0 -0
  139. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/test/test_typeinfo.py +0 -0
  140. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/test/test_urlhistory.py +0 -0
  141. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/test/test_util.py +0 -0
  142. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/test/test_variant.py +0 -0
  143. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/test/test_variant_outparam.py +0 -0
  144. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/test/test_w_getopt.py +0 -0
  145. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/test/test_win32com_interop.py +0 -0
  146. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/test/test_word.py +0 -0
  147. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/test/urlhist.tlb +0 -0
  148. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/tools/__init__.py +0 -0
  149. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/tools/codegenerator/__init__.py +0 -0
  150. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/tools/codegenerator/codegenerator.py +0 -0
  151. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/tools/codegenerator/comments.py +0 -0
  152. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/tools/codegenerator/heads.py +0 -0
  153. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/tools/codegenerator/helpers.py +0 -0
  154. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/tools/codegenerator/modulenamer.py +0 -0
  155. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/tools/codegenerator/namespaces.py +0 -0
  156. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/tools/codegenerator/packing.py +0 -0
  157. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/tools/codegenerator/typeannotator.py +0 -0
  158. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/tools/tlbparser.py +0 -0
  159. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/tools/typedesc.py +0 -0
  160. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/tools/typedesc_base.py +0 -0
  161. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/util.py +0 -0
  162. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes/viewobject.py +0 -0
  163. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes.egg-info/dependency_links.txt +0 -0
  164. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes.egg-info/entry_points.txt +0 -0
  165. {comtypes-1.4.15 → comtypes-1.4.16}/comtypes.egg-info/top_level.txt +0 -0
  166. {comtypes-1.4.15 → comtypes-1.4.16}/pyproject.toml +0 -0
  167. {comtypes-1.4.15 → comtypes-1.4.16}/setup.cfg +0 -0
@@ -1,6 +1,25 @@
1
1
  Comtypes CHANGELOG
2
2
  ==================
3
3
 
4
+ Release 1.4.16
5
+ --------------
6
+ * Decompose ``IStorage`` tests and enhance coverage. By @junkmd.
7
+ * Enhance tests verifying custom ``COMObject``s raise errors. By @junkmd.
8
+ * Refactor ``shelllink.py`` for ``ITEMIDLIST`` structure. By @junkmd.
9
+ * Fix a code path in ``logutil.NTDebugHandler``. By @junkmd.
10
+ * Add a deprecation decorator to ``logutil.setup_logging``. By @junkmd.
11
+ * Add tests for connection point interfaces. By @junkmd.
12
+ * Add tests for ``IGlobalInterfaceTable`` marshaling. By @junkmd.
13
+ * Remove outdated Python 2.3 compatibility. By @junkmd.
14
+ * Remove unused test utilities. By @junkmd.
15
+ * Extract time utility test helpers. By @junkmd.
16
+ * Add ``CreateTypeLib`` and ``ICreateTypeInfo`` tests. By @junkmd.
17
+ * Add tests for ``VARIANTEnumerator``. By @junkmd.
18
+ * Enhance tests for moniker, bind context and running object table. By @junkmd.
19
+ * Introduce GDI test helper module and tests for ``IViewObject.Draw``. By @junkmd.
20
+ * Unify COM descriptor release logic in ``ITypeComp.Bind``. By @junkmd.
21
+ * Enhance dynamic dispatch and ``client`` testing. By @junkmd.
22
+
4
23
  Release 1.4.15
5
24
  --------------
6
25
  * Fix ``TYPE_E_ELEMENTNOTFOUND`` HRESULT constant value. By @junkmd.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: comtypes
3
- Version: 1.4.15
3
+ Version: 1.4.16
4
4
  Summary: Pure Python COM package
5
5
  Author-email: Thomas Heller <theller@python.net>
6
6
  License-Expression: MIT
@@ -1,5 +1,5 @@
1
1
  # comtypes version numbers follow semver (http://semver.org/) and PEP 440
2
- __version__ = "1.4.15"
2
+ __version__ = "1.4.16"
3
3
 
4
4
  try:
5
5
  from _ctypes import COMError # noqa
@@ -159,11 +159,7 @@ class Dispatch:
159
159
  def caller(*args):
160
160
  return self._comobj._invoke(descr.memid, descr.invkind, 0, *args)
161
161
 
162
- try:
163
- caller.__name__ = name
164
- except TypeError:
165
- # In Python 2.3, __name__ is readonly
166
- pass
162
+ caller.__name__ = name
167
163
  return caller
168
164
 
169
165
  def __setattr__(self, name, value):
@@ -1,5 +1,7 @@
1
1
  # logutil.py
2
+ import functools
2
3
  import logging
4
+ import warnings
3
5
  from ctypes import WinDLL
4
6
  from ctypes.wintypes import LPCSTR, LPCWSTR
5
7
 
@@ -18,19 +20,28 @@ class NTDebugHandler(logging.Handler):
18
20
  def emit(
19
21
  self,
20
22
  record,
21
- writeA=_OutputDebugStringA,
22
23
  writeW=_OutputDebugStringW,
23
24
  ):
24
25
  text = self.format(record)
25
- if isinstance(text, str):
26
- writeA(text + "\n")
27
- else:
28
- writeW(text + "\n")
26
+ writeW(text + "\n")
29
27
 
30
28
 
31
29
  logging.NTDebugHandler = NTDebugHandler
32
30
 
33
31
 
32
+ def deprecated(reason: str):
33
+ def decorator(func):
34
+ @functools.wraps(func)
35
+ def wrapper(*args, **kwargs):
36
+ warnings.warn(reason, category=DeprecationWarning, stacklevel=2)
37
+ return func(*args, **kwargs)
38
+
39
+ return wrapper
40
+
41
+ return decorator
42
+
43
+
44
+ @deprecated("Deprecated. See https://github.com/enthought/comtypes/issues/920.")
34
45
  def setup_logging(*pathnames):
35
46
  import configparser
36
47
 
@@ -1,5 +1,6 @@
1
1
  from ctypes import (
2
2
  POINTER,
3
+ Structure,
3
4
  byref,
4
5
  c_char_p,
5
6
  c_int,
@@ -8,12 +9,21 @@ from ctypes import (
8
9
  create_string_buffer,
9
10
  create_unicode_buffer,
10
11
  )
11
- from ctypes.wintypes import DWORD, MAX_PATH, WIN32_FIND_DATAA, WIN32_FIND_DATAW
12
+ from ctypes.wintypes import (
13
+ BYTE,
14
+ DWORD,
15
+ MAX_PATH,
16
+ USHORT,
17
+ WIN32_FIND_DATAA,
18
+ WIN32_FIND_DATAW,
19
+ )
12
20
  from typing import TYPE_CHECKING, Literal
13
21
 
14
22
  from comtypes import COMMETHOD, GUID, HRESULT, CoClass, IUnknown
15
23
 
16
24
  if TYPE_CHECKING:
25
+ from ctypes import _Pointer
26
+
17
27
  from comtypes import hints # type: ignore
18
28
 
19
29
 
@@ -42,8 +52,15 @@ HOTKEYF_CONTROL = 0x02
42
52
  HOTKEYF_EXT = 0x08
43
53
  HOTKEYF_SHIFT = 0x01
44
54
 
45
- # fake these...
46
- ITEMIDLIST = c_int
55
+
56
+ class SHITEMID(Structure):
57
+ _fields_ = [("cb", USHORT), ("abID", BYTE * 1)]
58
+
59
+
60
+ class ITEMIDLIST(Structure):
61
+ _fields_ = [("mkid", SHITEMID)]
62
+
63
+
47
64
  LPITEMIDLIST = LPCITEMIDLIST = POINTER(ITEMIDLIST)
48
65
 
49
66
 
@@ -134,8 +151,8 @@ class IShellLinkA(IUnknown):
134
151
 
135
152
  if TYPE_CHECKING:
136
153
 
137
- def GetIDList(self) -> hints.Incomplete: ...
138
- def SetIDList(self, pidl: hints.Incomplete) -> hints.Incomplete: ...
154
+ def GetIDList(self) -> _Pointer[ITEMIDLIST]: ...
155
+ def SetIDList(self, pidl: _Pointer[ITEMIDLIST]) -> hints.Hresult: ...
139
156
  def SetDescription(self, pszName: bytes) -> hints.Incomplete: ...
140
157
  def SetWorkingDirectory(self, pszDir: bytes) -> hints.Hresult: ...
141
158
  def SetArguments(self, pszArgs: bytes) -> hints.Hresult: ...
@@ -269,8 +286,8 @@ class IShellLinkW(IUnknown):
269
286
 
270
287
  if TYPE_CHECKING:
271
288
 
272
- def GetIDList(self) -> hints.Incomplete: ...
273
- def SetIDList(self, pidl: hints.Incomplete) -> hints.Incomplete: ...
289
+ def GetIDList(self) -> _Pointer[ITEMIDLIST]: ...
290
+ def SetIDList(self, pidl: _Pointer[ITEMIDLIST]) -> hints.Hresult: ...
274
291
  def SetDescription(self, pszName: str) -> hints.Incomplete: ...
275
292
  def SetWorkingDirectory(self, pszDir: str) -> hints.Hresult: ...
276
293
  def SetArguments(self, pszArgs: str) -> hints.Hresult: ...
@@ -37,37 +37,9 @@ class ResourceDenied(Exception):
37
37
  """
38
38
 
39
39
 
40
- def is_resource_enabled(resource):
41
- """Test whether a resource is enabled.
42
-
43
- If the caller's module is __main__ then automatically return True."""
44
- if sys._getframe().f_back.f_globals.get("__name__") == "__main__":
45
- return True
46
- result = use_resources is not None and (
47
- resource in use_resources or "*" in use_resources
48
- )
49
- if not result:
50
- _unavail[resource] = None
51
- return result
52
-
53
-
54
40
  _unavail = {}
55
41
 
56
42
 
57
- def requires(resource, msg=None):
58
- """Raise ResourceDenied if the specified resource is not available.
59
-
60
- If the caller's module is __main__ then automatically return True."""
61
- # see if the caller's module is __main__ - if so, treat as if
62
- # the resource was set
63
- if sys._getframe().f_back.f_globals.get("__name__") == "__main__":
64
- return
65
- if not is_resource_enabled(resource):
66
- if msg is None:
67
- msg = f"Use of the `{resource}` resource not enabled"
68
- raise ResourceDenied(msg)
69
-
70
-
71
43
  def find_package_modules(package, mask):
72
44
  import fnmatch
73
45
 
@@ -0,0 +1,202 @@
1
+ import contextlib
2
+ from collections.abc import Iterator
3
+ from ctypes import POINTER, Structure, WinDLL, byref, c_void_p, sizeof
4
+ from ctypes.wintypes import (
5
+ BOOL,
6
+ DWORD,
7
+ HANDLE,
8
+ HDC,
9
+ HGDIOBJ,
10
+ HWND,
11
+ INT,
12
+ LONG,
13
+ UINT,
14
+ WORD,
15
+ )
16
+ from typing import Optional
17
+
18
+ BI_RGB = 0 # No compression
19
+ DIB_RGB_COLORS = 0
20
+
21
+ _user32 = WinDLL("user32")
22
+
23
+ _GetDC = _user32.GetDC
24
+ _GetDC.argtypes = (HWND,)
25
+ _GetDC.restype = HDC
26
+
27
+ _ReleaseDC = _user32.ReleaseDC
28
+ _ReleaseDC.argtypes = (HWND, HDC)
29
+ _ReleaseDC.restype = INT
30
+
31
+ _gdi32 = WinDLL("gdi32")
32
+
33
+ _CreateCompatibleDC = _gdi32.CreateCompatibleDC
34
+ _CreateCompatibleDC.argtypes = (HDC,)
35
+ _CreateCompatibleDC.restype = HDC
36
+
37
+ _DeleteDC = _gdi32.DeleteDC
38
+ _DeleteDC.argtypes = (HDC,)
39
+ _DeleteDC.restype = BOOL
40
+
41
+ _SelectObject = _gdi32.SelectObject
42
+ _SelectObject.argtypes = (HDC, HGDIOBJ)
43
+ _SelectObject.restype = HGDIOBJ
44
+
45
+ _DeleteObject = _gdi32.DeleteObject
46
+ _DeleteObject.argtypes = (HGDIOBJ,)
47
+ _DeleteObject.restype = BOOL
48
+
49
+ _GdiFlush = _gdi32.GdiFlush
50
+ _GdiFlush.argtypes = []
51
+ _GdiFlush.restype = BOOL
52
+
53
+
54
+ class BITMAPINFOHEADER(Structure):
55
+ _fields_ = [
56
+ ("biSize", DWORD),
57
+ ("biWidth", LONG),
58
+ ("biHeight", LONG),
59
+ ("biPlanes", WORD),
60
+ ("biBitCount", WORD),
61
+ ("biCompression", DWORD),
62
+ ("biSizeImage", DWORD),
63
+ ("biXPelsPerMeter", LONG),
64
+ ("biYPelsPerMeter", LONG),
65
+ ("biClrUsed", DWORD),
66
+ ("biClrImportant", DWORD),
67
+ ]
68
+
69
+
70
+ class BITMAPINFO(Structure):
71
+ _fields_ = [
72
+ ("bmiHeader", BITMAPINFOHEADER),
73
+ ("bmiColors", DWORD * 1), # Placeholder for color table, not used for 32bpp
74
+ ]
75
+
76
+
77
+ _CreateDIBSection = _gdi32.CreateDIBSection
78
+ _CreateDIBSection.argtypes = (
79
+ HDC,
80
+ POINTER(BITMAPINFO),
81
+ UINT, # DIB_RGB_COLORS
82
+ POINTER(c_void_p), # lplpBits
83
+ HANDLE, # hSection
84
+ DWORD, # dwOffset
85
+ )
86
+ _CreateDIBSection.restype = HGDIOBJ
87
+
88
+
89
+ @contextlib.contextmanager
90
+ def get_dc(hwnd: Optional[int]) -> Iterator[int]:
91
+ """Context manager to get and release a device context (DC)."""
92
+ dc = _GetDC(hwnd)
93
+ assert dc, "Failed to get device context."
94
+ try:
95
+ yield dc
96
+ finally:
97
+ # Release the device context
98
+ _ReleaseDC(hwnd, dc)
99
+
100
+
101
+ @contextlib.contextmanager
102
+ def create_compatible_dc(hdc: Optional[int]) -> Iterator[int]:
103
+ """Context manager to create and delete a compatible device context."""
104
+ mem_dc = _CreateCompatibleDC(hdc)
105
+ assert mem_dc, "Failed to create compatible memory DC."
106
+ try:
107
+ yield mem_dc
108
+ finally:
109
+ _DeleteDC(mem_dc)
110
+
111
+
112
+ @contextlib.contextmanager
113
+ def create_dib_section(
114
+ hdc: int, bmi: BITMAPINFO, usage: int, hsection: int, dwoffset: int
115
+ ) -> Iterator[tuple[int, int]]:
116
+ """Context manager to create and manage a DIB section.
117
+
118
+ This function creates a device-independent bitmap (DIB) that applications
119
+ can write to directly. It provides a handle to the DIB and a pointer
120
+ address to its bitmap bits.
121
+ """
122
+ bits = c_void_p()
123
+ try:
124
+ hbm = _CreateDIBSection(
125
+ hdc,
126
+ byref(bmi),
127
+ usage,
128
+ byref(bits),
129
+ hsection,
130
+ dwoffset,
131
+ )
132
+ assert hbm, "Failed to create DIB section."
133
+ assert bits.value, "Failed to get the bitmap's bit value."
134
+ yield hbm, bits.value
135
+ finally:
136
+ _DeleteObject(hbm)
137
+
138
+
139
+ @contextlib.contextmanager
140
+ def select_object(hdc: int, obj: int) -> Iterator[int]:
141
+ """Context manager to select a GDI object into a device context and restore
142
+ the original.
143
+ """
144
+ old_obj = _SelectObject(hdc, obj)
145
+ assert old_obj, "Failed to select object into DC."
146
+ try:
147
+ yield obj
148
+ finally:
149
+ _SelectObject(hdc, old_obj)
150
+
151
+
152
+ def create_24bitmap_info(width: int, height: int) -> BITMAPINFO:
153
+ """Creates a BITMAPINFO structure for a 24bpp BGR DIB section."""
154
+ bmi = BITMAPINFO()
155
+ bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER)
156
+ bmi.bmiHeader.biWidth = width
157
+ bmi.bmiHeader.biHeight = -height # Negative for top-down DIB
158
+ bmi.bmiHeader.biPlanes = 1
159
+ bmi.bmiHeader.biBitCount = 24
160
+ bmi.bmiHeader.biCompression = BI_RGB
161
+ # width*height pixels * 3 bytes/pixel (BGR)
162
+ bmi.bmiHeader.biSizeImage = width * height * 3
163
+ return bmi
164
+
165
+
166
+ @contextlib.contextmanager
167
+ def create_image_rendering_dc(
168
+ hwnd: int,
169
+ width: int,
170
+ height: int,
171
+ usage: int = DIB_RGB_COLORS,
172
+ hsection: int = 0,
173
+ dwoffset: int = 0,
174
+ ) -> Iterator[tuple[int, int, BITMAPINFO, int]]:
175
+ """Context manager to create a device context for off-screen image rendering.
176
+
177
+ This sets up a memory device context (DC) with a DIB section, allowing
178
+ GDI operations to render into a memory buffer.
179
+
180
+ Args:
181
+ hwnd: Handle to the window (0 for desktop).
182
+ width: Width of the image buffer.
183
+ height: Height of the image buffer.
184
+ usage: The type of DIB. Default is DIB_RGB_COLORS (0).
185
+ hsection: A handle to a file-mapping object. If NULL (0), the system
186
+ allocates memory for the DIB.
187
+ dwoffset: The offset from the beginning of the file-mapping object
188
+ specified by `hsection` to where the DIB bitmap begins.
189
+
190
+ Yields:
191
+ A tuple containing:
192
+ - mem_dc: The handle to the memory device context.
193
+ - bits: Pointer address to the pixel data of the DIB section.
194
+ - bmi: The structure describing the DIB section.
195
+ - hbm: The handle to the created DIB section bitmap.
196
+ """
197
+ # Get a screen DC to use as a reference for creating a compatible DC
198
+ with get_dc(hwnd) as screen_dc, create_compatible_dc(screen_dc) as mem_dc:
199
+ bmi = create_24bitmap_info(width, height)
200
+ with create_dib_section(mem_dc, bmi, usage, hsection, dwoffset) as (hbm, bits):
201
+ with select_object(mem_dc, hbm):
202
+ yield mem_dc, bits, bmi, hbm
@@ -0,0 +1,73 @@
1
+ from ctypes import HRESULT, POINTER, OleDLL, c_wchar_p
2
+ from ctypes.wintypes import DWORD
3
+
4
+ from comtypes import GUID, IUnknown
5
+
6
+ # https://learn.microsoft.com/en-us/windows/win32/api/objidl/ne-objidl-mksys
7
+ MKSYS_GENERICCOMPOSITE = 1
8
+ MKSYS_FILEMONIKER = 2
9
+ MKSYS_ANTIMONIKER = 3
10
+ MKSYS_ITEMMONIKER = 4
11
+ MKSYS_POINTERMONIKER = 5
12
+ MKSYS_CLASSMONIKER = 7
13
+ MKSYS_OBJREFMONIKER = 8
14
+
15
+ CLSID_CompositeMoniker = GUID("{00000309-0000-0000-c000-000000000046}")
16
+ CLSID_FileMoniker = GUID("{00000303-0000-0000-C000-000000000046}")
17
+ CLSID_AntiMoniker = GUID("{00000305-0000-0000-c000-000000000046}")
18
+ CLSID_ItemMoniker = GUID("{00000304-0000-0000-c000-000000000046}")
19
+ CLSID_PointerMoniker = GUID("{00000306-0000-0000-c000-000000000046}")
20
+ CLSID_ClassMoniker = GUID("{0000031A-0000-0000-C000-000000000046}")
21
+ CLSID_ObjrefMoniker = GUID("{00000327-0000-0000-c000-000000000046}")
22
+
23
+ ROTFLAGS_ALLOWANYCLIENT = 1
24
+
25
+ LPOLESTR = LPCOLESTR = c_wchar_p
26
+
27
+ _ole32 = OleDLL("ole32")
28
+
29
+ _CreateGenericComposite = _ole32.CreateGenericComposite
30
+ _CreateGenericComposite.argtypes = [
31
+ POINTER(IUnknown), # pmkFirst
32
+ POINTER(IUnknown), # pmkRest
33
+ POINTER(POINTER(IUnknown)), # ppmkComposite
34
+ ]
35
+ _CreateGenericComposite.restype = HRESULT
36
+
37
+ _CreateFileMoniker = _ole32.CreateFileMoniker
38
+ _CreateFileMoniker.argtypes = [LPCOLESTR, POINTER(POINTER(IUnknown))]
39
+ _CreateFileMoniker.restype = HRESULT
40
+
41
+ _CreateAntiMoniker = _ole32.CreateAntiMoniker
42
+ _CreateAntiMoniker.argtypes = [POINTER(POINTER(IUnknown))]
43
+ _CreateAntiMoniker.restype = HRESULT
44
+
45
+ _CreateItemMoniker = _ole32.CreateItemMoniker
46
+ _CreateItemMoniker.argtypes = [LPCOLESTR, LPCOLESTR, POINTER(POINTER(IUnknown))]
47
+ _CreateItemMoniker.restype = HRESULT
48
+
49
+ _CreatePointerMoniker = _ole32.CreatePointerMoniker
50
+ _CreatePointerMoniker.argtypes = [POINTER(IUnknown), POINTER(POINTER(IUnknown))]
51
+ _CreatePointerMoniker.restype = HRESULT
52
+
53
+ _CreateClassMoniker = _ole32.CreateClassMoniker
54
+ _CreateClassMoniker.argtypes = [POINTER(GUID), POINTER(POINTER(IUnknown))]
55
+ _CreateClassMoniker.restype = HRESULT
56
+
57
+ _CreateObjrefMoniker = _ole32.CreateObjrefMoniker
58
+ _CreateObjrefMoniker.argtypes = [POINTER(IUnknown), POINTER(POINTER(IUnknown))]
59
+ _CreateObjrefMoniker.restype = HRESULT
60
+
61
+ _CreateBindCtx = _ole32.CreateBindCtx
62
+ _CreateBindCtx.argtypes = [DWORD, POINTER(POINTER(IUnknown))]
63
+ _CreateBindCtx.restype = HRESULT
64
+
65
+ _GetRunningObjectTable = _ole32.GetRunningObjectTable
66
+ _GetRunningObjectTable.argtypes = [DWORD, POINTER(POINTER(IUnknown))]
67
+ _GetRunningObjectTable.restype = HRESULT
68
+
69
+ # Common COM Errors from Moniker/Binding Context operations
70
+ MK_E_NOINVERSE = -2147221012 # 0x800401EC
71
+ MK_E_NEEDGENERIC = -2147221022 # 0x800401E2
72
+ MK_E_SYNTAX = -2147221020 # 0x800401E4
73
+ MK_E_UNAVAILABLE = -2147221021 # 0x800401E3
@@ -0,0 +1,143 @@
1
+ import contextlib
2
+ import unittest
3
+ from _ctypes import COMError
4
+ from ctypes import POINTER, byref, sizeof
5
+
6
+ from comtypes import GUID, hresult, tagBIND_OPTS2
7
+ from comtypes.client import CreateObject, GetModule
8
+ from comtypes.test.monikers_helper import (
9
+ ROTFLAGS_ALLOWANYCLIENT,
10
+ _CreateBindCtx,
11
+ _CreateItemMoniker,
12
+ _GetRunningObjectTable,
13
+ )
14
+
15
+ with contextlib.redirect_stdout(None): # supress warnings
16
+ GetModule("msvidctl.dll")
17
+ from comtypes.gen import MSVidCtlLib as msvidctl
18
+ from comtypes.gen.MSVidCtlLib import IBindCtx, IMoniker, IRunningObjectTable
19
+
20
+
21
+ def _create_item_moniker(delim: str, item: str) -> IMoniker:
22
+ mon = POINTER(IMoniker)()
23
+ _CreateItemMoniker(delim, item, byref(mon))
24
+ return mon # type: ignore
25
+
26
+
27
+ def _create_bctx() -> IBindCtx:
28
+ bctx = POINTER(IBindCtx)()
29
+ # The first parameter is reserved and must be 0.
30
+ _CreateBindCtx(0, byref(bctx))
31
+ return bctx # type: ignore
32
+
33
+
34
+ def _create_rot() -> IRunningObjectTable:
35
+ rot = POINTER(IRunningObjectTable)()
36
+ # The first parameter is reserved and must be 0.
37
+ _GetRunningObjectTable(0, byref(rot))
38
+ return rot # type: ignore
39
+
40
+
41
+ class Test_EnumObjectParam(unittest.TestCase):
42
+ def test_cannot_call(self):
43
+ bctx = _create_bctx()
44
+ with self.assertRaises(COMError) as cm:
45
+ # calling `EnumObjectParam` results in a return value of E_NOTIMPL.
46
+ # https://learn.microsoft.com/en-us/windows/win32/api/objidl/nf-objidl-ibindctx-enumobjectparam#notes-to-callers
47
+ bctx.EnumObjectParam()
48
+ self.assertEqual(cm.exception.hresult, hresult.E_NOTIMPL)
49
+
50
+
51
+ class Test_GetRunningObjectTable(unittest.TestCase):
52
+ def test_returns_rot(self):
53
+ vidctl = CreateObject(msvidctl.MSVidCtl, interface=msvidctl.IMSVidCtl)
54
+ item_id = str(GUID.create_new())
55
+ mon = _create_item_moniker("!", item_id)
56
+ bctx = _create_bctx()
57
+ # Before registering: should NOT be running
58
+ rot_from_bctx = bctx.GetRunningObjectTable()
59
+ self.assertIsInstance(rot_from_bctx, IRunningObjectTable)
60
+ rot_from_func = _create_rot()
61
+ dw_reg = rot_from_func.Register(ROTFLAGS_ALLOWANYCLIENT, vidctl, mon)
62
+ # After registering: should be running
63
+ self.assertEqual(rot_from_bctx.IsRunning(mon), hresult.S_OK)
64
+ rot_from_func.Revoke(dw_reg)
65
+ # After revoking: should NOT be running again
66
+ self.assertEqual(rot_from_bctx, rot_from_func)
67
+
68
+
69
+ class Test_Register_Revoke_Release_ObjectBound(unittest.TestCase):
70
+ def test_register_and_revoke(self):
71
+ bctx = _create_bctx()
72
+ vidctl = CreateObject(msvidctl.MSVidCtl, interface=msvidctl.IMSVidCtl)
73
+ # Binds the object to the bind context, ensuring it stays alive during
74
+ # the binding operation.
75
+ hr = bctx.RegisterObjectBound(vidctl)
76
+ self.assertEqual(hr, hresult.S_OK)
77
+ # At this point, `bctx` holds a reference to `vidctl`.
78
+ # Unlike `RegisterObjectParam`, there is no public API to retrieve
79
+ # objects registered via `RegisterObjectBound` from `IBindCtx`.
80
+ # Therefore, direct testing of `vidctl`'s accessibility via `bctx`
81
+ # after binding (similar to `GetObjectParam`) is not possible.
82
+ # Releases the reference to the object previously registered.
83
+ hr = bctx.RevokeObjectBound(vidctl)
84
+ self.assertEqual(hr, hresult.S_OK)
85
+ # `bctx` holds a reference to `vidctl` again.
86
+ # Releases all object references currently held by the bind context.
87
+ bctx.RegisterObjectBound(vidctl)
88
+ hr = bctx.ReleaseBoundObjects()
89
+ self.assertEqual(hr, hresult.S_OK)
90
+
91
+
92
+ class Test_Get_Register_Revoke_ObjectParam(unittest.TestCase):
93
+ def test_get_and_register_and_revoke(self):
94
+ bctx = _create_bctx()
95
+ key = str(GUID.create_new())
96
+ vidctl = CreateObject(msvidctl.MSVidCtl, interface=msvidctl.IMSVidCtl)
97
+ # `GetObjectParam` should fail as it's NOT registered yet
98
+ with self.assertRaises(COMError) as cm:
99
+ bctx.GetObjectParam(key)
100
+ self.assertEqual(cm.exception.hresult, hresult.E_FAIL)
101
+ # Register object
102
+ hr = bctx.RegisterObjectParam(key, vidctl)
103
+ self.assertEqual(hr, hresult.S_OK)
104
+ # `GetObjectParam` should succeed now
105
+ ret_obj = bctx.GetObjectParam(key)
106
+ self.assertEqual(ret_obj.QueryInterface(msvidctl.IMSVidCtl), vidctl)
107
+ # Revoke object
108
+ hr = bctx.RevokeObjectParam(key)
109
+ self.assertEqual(hr, hresult.S_OK)
110
+ # `GetObjectParam` should fail again after revoke
111
+ with self.assertRaises(COMError) as cm:
112
+ bctx.GetObjectParam(key)
113
+ self.assertEqual(cm.exception.hresult, hresult.E_FAIL)
114
+
115
+
116
+ class Test_Set_Get_BindOptions(unittest.TestCase):
117
+ def test_set_get_bind_options(self):
118
+ bctx = _create_bctx()
119
+ # Create an instance of `BIND_OPTS2` and set some values.
120
+ # In comtypes, instances of Structure subclasses like `tagBIND_OPTS2`
121
+ # can be passed directly as arguments where COM methods expect a
122
+ # pointer to the structure.
123
+ hr = bctx.RemoteSetBindOptions(
124
+ tagBIND_OPTS2(
125
+ cbStruct=sizeof(tagBIND_OPTS2),
126
+ grfFlags=0x11223344,
127
+ grfMode=0x55667788,
128
+ dwTickCountDeadline=12345,
129
+ )
130
+ )
131
+ self.assertEqual(hr, hresult.S_OK)
132
+ # Create a new instance for retrieval.
133
+ # The `cbStruct` field is crucial in COM as it indicates the size of
134
+ # the structure to the COM component, allowing it to handle different
135
+ # versions of the structure (for backward and forward compatibility).
136
+ # https://learn.microsoft.com/en-us/windows/win32/api/objidl/nf-objidl-ibindctx-getbindoptions#notes-to-callers
137
+ bind_opts = tagBIND_OPTS2(cbStruct=sizeof(tagBIND_OPTS2))
138
+ ret = bctx.RemoteGetBindOptions(bind_opts)
139
+ self.assertIsInstance(ret, tagBIND_OPTS2)
140
+ self.assertEqual(bind_opts.cbStruct, sizeof(tagBIND_OPTS2))
141
+ self.assertEqual(bind_opts.grfFlags, 0x11223344)
142
+ self.assertEqual(bind_opts.grfMode, 0x55667788)
143
+ self.assertEqual(bind_opts.dwTickCountDeadline, 12345)
@@ -9,7 +9,8 @@ from comtypes import CLSCTX_INPROC_SERVER, COSERVERINFO
9
9
 
10
10
  # create the typelib wrapper and import it
11
11
  comtypes.client.GetModule("scrrun.dll")
12
- from comtypes.gen import Scripting
12
+ comtypes.client.GetModule("wbemdisp.tlb")
13
+ from comtypes.gen import Scripting, WbemScripting
13
14
 
14
15
 
15
16
  class Test_GetModule(ut.TestCase):
@@ -218,6 +219,38 @@ class Test_CreateObject(ut.TestCase):
218
219
  self.assertIsInstance(iuia.GetRootElement(), POINTER(IUIAutomationElement))
219
220
  self.assertIsInstance(iuia.GetRootElement(), IUIAutomationElement)
220
221
 
222
+ def test_raises_valueerror_if_takes_dynamic_true_and_interface(self):
223
+ with self.assertRaises(ValueError):
224
+ comtypes.client.CreateObject(
225
+ "Scripting.Dictionary",
226
+ interface=Scripting.IDictionary,
227
+ dynamic=True, # type: ignore
228
+ )
229
+
230
+
231
+ class Test_CoGetObject(ut.TestCase):
232
+ def test_returns_interface_pointer(self):
233
+ wmi = comtypes.client.CoGetObject(
234
+ "winmgmts:", interface=WbemScripting.ISWbemServices
235
+ )
236
+ self.assertIsInstance(wmi, WbemScripting.ISWbemServices)
237
+ disks = wmi.InstancesOf("Win32_LogicalDisk")
238
+ self.assertGreaterEqual(len(disks), 0)
239
+
240
+ def test_returns_dynamic_dispatch_object(self):
241
+ wmi = comtypes.client.CoGetObject("winmgmts:", dynamic=True)
242
+ self.assertIsInstance(wmi, comtypes.client.lazybind.Dispatch)
243
+ disks = wmi.InstancesOf("Win32_LogicalDisk")
244
+ self.assertGreaterEqual(disks.Count, 0)
245
+
246
+ def test_raises_valueerror_if_takes_dynamic_true_and_interface(self):
247
+ with self.assertRaises(ValueError):
248
+ comtypes.client.CoGetObject(
249
+ "winmgmts:",
250
+ interface=WbemScripting.ISWbemServices, # type: ignore
251
+ dynamic=True, # type: ignore
252
+ )
253
+
221
254
 
222
255
  class Test_Constants(ut.TestCase):
223
256
  def test_punk(self):