diff --git a/comtypes/_post_coinit/guid.py b/comtypes/GUID.py similarity index 97% rename from comtypes/_post_coinit/guid.py rename to comtypes/GUID.py index d319c0c82..1f89cb78f 100644 --- a/comtypes/_post_coinit/guid.py +++ b/comtypes/GUID.py @@ -1,3 +1,5 @@ +"""comtypes.GUID module""" + from ctypes import oledll, windll from ctypes import byref, c_byte, c_ushort, c_ulong, c_wchar_p, Structure from typing import Any, TYPE_CHECKING @@ -28,6 +30,8 @@ def binary(obj: "GUID") -> bytes: class GUID(Structure): + """Globally unique identifier structure.""" + _fields_ = [("Data1", DWORD), ("Data2", WORD), ("Data3", WORD), ("Data4", BYTE * 8)] def __init__(self, name=None): diff --git a/comtypes/__init__.py b/comtypes/__init__.py index e508dd413..cfc87dba0 100644 --- a/comtypes/__init__.py +++ b/comtypes/__init__.py @@ -35,6 +35,7 @@ else: _CData = _SimpleCData.__mro__[:-1][-1] +from comtypes.GUID import GUID from comtypes import patcher # noqa from comtypes._npsupport import interop as npsupport # noqa from comtypes._tlib_version_checker import _check_version # noqa @@ -69,6 +70,8 @@ class ReturnHRESULT(Exception): # class IDLWarning(UserWarning): # "Warn about questionable type information" +_GUID = GUID +IID = GUID DWORD = c_ulong wireHWND = c_ulong @@ -189,10 +192,7 @@ def CoUninitialize(): ################################################################ from comtypes._post_coinit.bstr import BSTR # noqa -from comtypes._post_coinit.guid import GUID -_GUID = GUID -IID = GUID ################################################################ # IPersist is a trivial interface, which allows to ask an object about diff --git a/comtypes/_post_coinit/misc.py b/comtypes/_post_coinit/misc.py index 3db9d7c63..b2a99f2e6 100644 --- a/comtypes/_post_coinit/misc.py +++ b/comtypes/_post_coinit/misc.py @@ -15,11 +15,11 @@ if TYPE_CHECKING: from comtypes import hints as hints # noqa # type: ignore -from comtypes._memberspec import COMMETHOD +from comtypes import GUID from comtypes import CLSCTX_SERVER, CLSCTX_LOCAL_SERVER, CLSCTX_REMOTE_SERVER from comtypes import _ole32, oledll, DWORD +from comtypes._memberspec import COMMETHOD from comtypes._post_coinit.unknwn import IUnknown -from comtypes._post_coinit.guid import GUID def _is_object(obj): diff --git a/comtypes/_post_coinit/unknwn.py b/comtypes/_post_coinit/unknwn.py index 75bc6b0b0..04f823809 100644 --- a/comtypes/_post_coinit/unknwn.py +++ b/comtypes/_post_coinit/unknwn.py @@ -7,11 +7,10 @@ from typing import Optional from typing import List, Type -from comtypes import _ole32_nohresult, com_interface_registry +from comtypes import GUID, _ole32_nohresult, com_interface_registry from comtypes._memberspec import ComMemberGenerator, DispMemberGenerator from comtypes._memberspec import STDMETHOD, _ComMemberSpec, _DispMemberSpec from comtypes._post_coinit import _cominterface_meta_patcher as _meta_patch -from comtypes._post_coinit.guid import GUID from comtypes._post_coinit.instancemethod import instancemethod logger = logging.getLogger(__name__)