Registry / communication / pywin32-ctypes

pywin32-ctypes

JSON →
library0.2.3pypypi✓ verified 27d ago

pywin32-ctypes is a Python library that provides a partial, pure-Python reimplementation of the `pywin32` extensions, leveraging `ctypes` and optionally `cffi` for interacting with the Windows API. It aims to offer `pywin32`-like functionality without requiring compilation or specific C compilers. Currently at version 0.2.3, the project maintains an active release cadence, addressing bugs and extending its subset of `pywin32` features.

pip install pywin32-ctypes
INSTALL
IMPORT
SIG · PYWIN32-CTYPES
P
pywin32-ctypes
communicationpythonv0.2.3
Install
1.5s avg
Import
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.2.3 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 18.1MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.5s · import 0.000s · 19MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

version
from win32ctypes import version
from win32ctypes import win32api

This example demonstrates how to import and use `win32api` to load and free a library, mimicking typical `pywin32` usage for basic API calls.

import sys from win32ctypes.pywin32 import win32api # Equivalent to 'import win32api' from pywin32 # Example: Load a library as a data file try: h_module = win32api.LoadLibraryEx(sys.executable, 0, win32api.LOAD_LIBRARY_AS_DATAFILE) print(f"Successfully loaded {sys.executable} as a data file. Handle: {h_module}") win32api.FreeLibrary(h_module) print("Successfully freed the library.") except Exception as e: print(f"An error occurred: {e}")
Debug
Known issues
gotchapywin32-ctypes is a *partial* reimplementation of pywin32. It implements only a small subset of the pywin32 API, primarily for internal needs at Enthought, meaning many functions available in standard pywin32 may not exist or behave identically.
fix
Users should refer to the pywin32-ctypes documentation for the specific APIs that are implemented and their behavior.
affects: All versions
breakingVersion 0.2.1 and later of pywin32-ctypes dropped support for Python versions older than 3.6.
fix
Projects targeting Python 2.x or Python 3.3-3.5 will need to use `pywin32-ctypes<0.2.1` or upgrade their Python environment to 3.6 or newer.
affects: 0.2.1 and later
breakingpywin32-ctypes version 0.1.2 fails to install with `setuptools>=58.0.0` due to its reliance on `use_2to3`, which `setuptools` no longer supports.
fix
Upgrade to `pywin32-ctypes` version 0.2.0 or newer, which has removed `use_2to3`. Alternatively, pin `setuptools` to a version older than 58.0.0 if using `pywin32-ctypes==0.1.2`.
affects: 0.1.2
gotchaApplications packaged with PyInstaller that include `pywin32-ctypes` (especially when interacting with sensitive Windows APIs like credential management) have been reported to be flagged as malware by antivirus software or corporate security policies.
fix
Consider code signing your executables or seeking whitelisting for your application. This issue stems from how some security software perceives `ctypes`-based interactions with low-level Windows APIs.
affects: All versions
gotchaPrior to version 0.2.3, issues existed in the backend selection logic (`loal_module`), which could lead to unexpected behavior when pywin32-ctypes attempts to choose between its `ctypes` and `cffi` backends.
fix
Upgrade to `pywin32-ctypes` 0.2.3 or newer to benefit from fixes in backend selection and ensure consistent runtime behavior.
affects: <0.2.3
breakingpywin32-ctypes is designed for Windows environments. Attempting to use it on non-Windows operating systems (e.g., Linux, macOS) will result in an ImportError as it tries to import Windows-specific functions like `get_last_error`, `FormatError`, and `WinDLL` from the `ctypes` module, which are not available on other platforms.
fix
Do not use `pywin32-ctypes` on non-Windows operating systems. This library is specifically intended for Windows-based projects.
affects: All versions
breaking`pywin32-ctypes` versions prior to a fix are incompatible with Python 3.13 due to their reliance on `ctypes.get_last_error`, which was removed from Python's standard `ctypes` module in version 3.13.
fix
Use Python versions older than 3.13, or upgrade `pywin32-ctypes` to a version that addresses this compatibility issue with Python 3.13.
affects: All versions prior to a fix
Upgrade
Version history
0.2.3latest on PyPI · released Aug 14, 2024
Audit
Dependencies
cffioptionalUsed as an optional, faster backend if available.
Agent activity
44 hits · last 30 days
node
40
OpenAI (training)
1
Resources
pywin32-ctypes — pip install pywin32-ctypes · libregistry