Skip to content

Commit

Permalink
Remove unnecessary stuff from _post_coinit/misc.py.
Browse files Browse the repository at this point in the history
  • Loading branch information
junkmd committed Feb 3, 2025
1 parent 03d8d4b commit 62d91b2
Showing 1 changed file with 1 addition and 48 deletions.
49 changes: 1 addition & 48 deletions comtypes/_post_coinit/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from typing import TYPE_CHECKING, Any, Callable, Optional, Type, TypeVar, overload

from comtypes import CLSCTX_LOCAL_SERVER, CLSCTX_REMOTE_SERVER, CLSCTX_SERVER, GUID
from comtypes.GUID import REFCLSID
from comtypes._memberspec import COMMETHOD
from comtypes._post_coinit.unknwn import IUnknown

Expand Down Expand Up @@ -170,37 +171,6 @@ def CoGetClassObject(clsid, clsctx=None, pServerInfo=None, interface=None):
return p # type: ignore


ACTIVEOBJECT_STRONG = 0x0
ACTIVEOBJECT_WEAK = 0x1


def RegisterActiveObject(punk: IUnknown, clsid: GUID, flags: int) -> int:
"""Registers a pointer as the active object for its class and returns the handle."""
handle = c_ulong()
_RegisterActiveObject(punk, byref(clsid), flags, byref(handle))
return handle.value


def RevokeActiveObject(handle: int) -> None:
"""Ends a pointer's status as active."""
_RevokeActiveObject(handle, None)


@overload
def GetActiveObject(clsid: GUID, interface: None = None) -> IUnknown: ...
@overload
def GetActiveObject(clsid: GUID, interface: Type[_T_IUnknown]) -> _T_IUnknown: ...
def GetActiveObject(
clsid: GUID, interface: Optional[Type[IUnknown]] = None
) -> IUnknown:
"""Retrieves a pointer to a running object"""
p = POINTER(IUnknown)()
_GetActiveObject(byref(clsid), None, byref(p))
if interface is not None:
p = p.QueryInterface(interface) # type: ignore
return p # type: ignore


class MULTI_QI(Structure):
_fields_ = [("pIID", POINTER(GUID)), ("pItf", POINTER(c_void_p)), ("hr", HRESULT)]
if TYPE_CHECKING:
Expand Down Expand Up @@ -253,23 +223,6 @@ class _COSERVERINFO(Structure):
dwReserved2: int


_oleaut32 = OleDLL("oleaut32")

REFCLSID = POINTER(GUID)

_RegisterActiveObject = _oleaut32.RegisterActiveObject
_RegisterActiveObject.argtypes = [POINTER(IUnknown), REFCLSID, DWORD, POINTER(DWORD)]
_RegisterActiveObject.restype = HRESULT

_RevokeActiveObject = _oleaut32.RevokeActiveObject
_RevokeActiveObject.argtypes = [DWORD, LPVOID]
_RevokeActiveObject.restype = HRESULT

_GetActiveObject = _oleaut32.GetActiveObject
_GetActiveObject.argtypes = [REFCLSID, LPVOID, POINTER(POINTER(IUnknown))]
_GetActiveObject.restype = HRESULT


_ole32 = OleDLL("ole32")

COSERVERINFO = _COSERVERINFO
Expand Down

0 comments on commit 62d91b2

Please sign in to comment.