Skip to content

Commit

Permalink
Fix broken unregistration of 64bit type libraries (second attempt) (#678
Browse files Browse the repository at this point in the history
)

* Fix broken unregistration of 64bit type libraries

The UnRegisterTypeLib function currently always assume 32bit type libraries (SYS_WIN32) if called without explicit `syskind` argument. This is currently the case when UnRegisterTypeLib is called implicitly from comtypes.server.register.UseCommandLine, since the `_reg_typelib_` field only contains the first 3 libID , wVerMajor and wVerMinor arguments.

Propose to fix the problem by updating the hardcoding to SYS_WIN64 for 64bit Python and SYS_WIN32 for 32bit Python installations.

* Reformatting UnRegisterTypeLib arguments in accordance with auto-formatter suggestion.
  • Loading branch information
forderud authored Dec 3, 2024
1 parent b05b80b commit 17d37b6
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion comtypes/typeinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,11 @@ def LoadTypeLib(szFile: str) -> ITypeLib:


def UnRegisterTypeLib(
libID: str, wVerMajor: int, wVerMinor: int, lcid: int = 0, syskind: int = SYS_WIN32
libID: str,
wVerMajor: int,
wVerMinor: int,
lcid: int = 0,
syskind: int = (SYS_WIN64 if is_64_bit else SYS_WIN32),
) -> int:
"""Unregister a registered type library"""
return _oleaut32.UnRegisterTypeLib(
Expand Down

0 comments on commit 17d37b6

Please sign in to comment.