{"id":24839139,"url":"https://github.com/winand/com_interfaces","last_synced_at":"2026-04-25T16:33:58.354Z","repository":{"id":66676113,"uuid":"575567676","full_name":"Winand/com_interfaces","owner":"Winand","description":"Declare and use Windows COM interfaces","archived":false,"fork":false,"pushed_at":"2023-02-12T10:37:49.000Z","size":39,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-26T04:34:57.379Z","etag":null,"topics":["component-object-model","interfaces","windows"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Winand.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-12-07T20:03:30.000Z","updated_at":"2022-12-09T10:52:14.000Z","dependencies_parsed_at":null,"dependency_job_id":"458da960-f0de-4db9-920a-1cd71ad8fe22","html_url":"https://github.com/Winand/com_interfaces","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/Winand/com_interfaces","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Winand%2Fcom_interfaces","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Winand%2Fcom_interfaces/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Winand%2Fcom_interfaces/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Winand%2Fcom_interfaces/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Winand","download_url":"https://codeload.github.com/Winand/com_interfaces/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Winand%2Fcom_interfaces/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32269462,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-25T09:15:33.318Z","status":"ssl_error","status_checked_at":"2026-04-25T09:15:31.997Z","response_time":59,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["component-object-model","interfaces","windows"],"created_at":"2025-01-31T06:36:50.888Z","updated_at":"2026-04-25T16:33:58.340Z","avatar_url":"https://github.com/Winand.png","language":"Python","readme":"**com-interfaces** package provides functionality for declaring Windows COM interfaces,\ninstantiating COM objects and accessing them through interfaces.\n\nA COM interface is described using class with methods. All COM interfaces are\ninherited from `IUnknown` interface.\nAn interface has `@interface` decorator and each COM method declaration has\n`@method(index=...)` decorator where `index` is an index of that method in COM interface.\nE.g. IUnknown::QueryInterface has index 0, AddRef - index 1, Release - index 2.\n\n`@method` saves index and arguments in a `__com_func__` variable of a method. Then\n`@interface` collects all methods containing that variable into `__func_table__` dict\nof a class. At runtime `IUnknown.__init__` creates an instance of a object\n(if object pointer is not passed in arguments) and replaces all declarations\nwith generated methods which call methods of that object. So if `__init__` is\noverriden then `super().__init__` should be called.\n\nExample of a COM method declaration:\n```\n@interface\nclass IExample(IUnknown):\n    @method(index=5)\n    def Load(self, pszFileName: DT.LPCOLESTR, dwMode: DT.DWORD):\n        ...\n```\nArgument type hint may be a `Union`. Only the first type is used for COM method\ninitialization. So you can use `Union[c_wchar_p, str]` to pass string w/o linting error.\nOptionally you may raise `NotImplementedError` in COM method declaration so you never call\nthose stub methods in runtime accidentally, e.g. in case of not initializing a method\n(missing `@method` decorator, `IUnknown.__init__` not called etc.).\n\nAlternatively COM methods can be described in `__methods__` dict of a class:\n```\n@interface\nclass IExample(IUnknown):\n    __methods__ = {\n        \"Method1\": {'index': 1, 'args': {\"hwnd\": DT.HWND}},\n        \"Method2\": {'index': 5, 'args': (HWND, INT)},\n        \"Method3\": {'index': 6},\n    }\n```\nBut this is not recommended because those methods are not recognized by linter.\n\n# IID and CLSID in Component Object Model ([COM](https://learn.microsoft.com/en-us/windows/win32/com/component-object-model--com--portal))\nIID is an interface identificator and [CLSID](https://learn.microsoft.com/en-us/windows/win32/com/clsid-key-hklm)\nidentifies COM class objects. IID should be specified for any interface.\nCLSID is needed to instantiate an object which implements that interface.\n\nIID and optionally CLSID are specified as str arguments of `@interface` decorator:\n```\n@interface(\"{000214F9-0000-0000-C000-000000000046}\", clsid=\"{00021401-0000-0000-C000-000000000046}\")\nclass IShellLink(IUnknown):\n    ...\n```\nAlternatively they can be specifid as `iid` and `clsid` variables of type `Guid` in class body:\n```\n@interface\nclass IPersistFile(IUnknown):\n    clsid = Guid(\"{00021401-0000-0000-C000-000000000046}\")\n    iid = Guid(\"{0000010b-0000-0000-C000-000000000046}\")\n```\n\n# IUnknown\nIn addition to `QueryInterface`, `AddRef` and `Release` methods `IUnknown` class\nhas `query_interface(IID: type[T]) -\u003e T` helper method, which returns an instance\nof a queried interface class.\n\n# Examples\n`com_interfaces.interfaces` contains several examples of COM interfaces inherited\nfrom `IUnknown`: `IPersistFile`, `IShellLink`, `ITaskBarList3`.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwinand%2Fcom_interfaces","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwinand%2Fcom_interfaces","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwinand%2Fcom_interfaces/lists"}