-
-
Notifications
You must be signed in to change notification settings - Fork 100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Avoid modifying shared DLL objects #735
Labels
good first issue
Good for newcomers
Comments
+1. Feel free to open PRs. |
moi15moi
added a commit
to moi15moi/comtypes
that referenced
this issue
Jan 12, 2025
Partially fix enthought#735 Also, changed IUnknown to ICreateTypeLib2 because CreateTypeLib2 doesn't take IUnknown as a parameter
moi15moi
added a commit
to moi15moi/comtypes
that referenced
this issue
Jan 12, 2025
Partially fix enthought#735 I needed to use a try except because, now, _QueryPathOfRegTypeLib return a HRESULT and not a c_int
moi15moi
added a commit
to moi15moi/comtypes
that referenced
this issue
Jan 12, 2025
Partially fix enthought#735
moi15moi
added a commit
to moi15moi/comtypes
that referenced
this issue
Jan 12, 2025
Partially fix enthought#735 Also, I removed the check to detect if LoadTypeLibEx exist. It is available since Windows 2000, so there isn't any reason to check for it's existence
This was referenced Jan 25, 2025
This was
linked to
pull requests
Jan 25, 2025
What about |
Have you tried this approach? +_oleaut32 = WinDLL("oleaut32")
+
+_SysFreeString = _oleaut32.SysFreeString
+
+
class BSTR(_SimpleCData):
"""The windows BSTR data type"""
@@ -18,9 +23,7 @@ class BSTR(_SimpleCData):
self._needsfree = True
return self.value
- def __del__(
- self, _free: Callable[["BSTR"], Any] = windll.oleaut32.SysFreeString
- ) -> None:
+ def __del__(self, _free: Callable[["BSTR"], Any] = _SysFreeString) -> None:
# Free the string if self owns the memory
# or if instructed by __ctypes_from_outparam__.
if self._b_base_ is None or self._needsfree:
@@ -35,3 +38,7 @@ class BSTR(_SimpleCData):
# right thing, it doesn't ensure that SysFreeString is called
# on destruction.
return cls(value)
+
+
+_SysFreeString.argtypes = [BSTR]
+_SysFreeString.restype = None |
This was
unlinked from
pull requests
Jan 26, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Currently,
comtypes
modifies shared DLL objects. Below are examples where such modifications occur:_comobject.py
, lines 80–83_safearray.py
, lines 49–103automation.py
, lines 586–588As noted in this comment, it is preferable to use
ctypes.WinDLL
instead ofctypes.windll
. This approach avoids modifying shared DLL objects and ensures better isolation.The text was updated successfully, but these errors were encountered: