{"library":"pywin32-ctypes","title":"pywin32-ctypes","description":"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.","status":"active","version":"0.2.3","language":"en","source_language":"en","source_url":"https://github.com/enthought/pywin32-ctypes","tags":["windows","win32","ctypes","ffi","pywin32","api"],"install":[{"cmd":"pip install pywin32-ctypes","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Used as an optional, faster backend if available.","package":"cffi","optional":true}],"imports":[{"symbol":"win32api","correct":"from win32ctypes.pywin32 import win32api"},{"symbol":"win32cred","correct":"from win32ctypes.pywin32 import win32cred"},{"note":"pywin32-ctypes provides its own compatibility layer under `win32ctypes.pywin32` and is not a direct drop-in replacement for all pywin32 modules.","wrong":"import win32api","symbol":"pywintypes","correct":"from win32ctypes.pywin32 import pywintypes"}],"quickstart":{"code":"import sys\nfrom win32ctypes.pywin32 import win32api\n\n# Equivalent to 'import win32api' from pywin32\n\n# Example: Load a library as a data file\ntry:\n    h_module = win32api.LoadLibraryEx(sys.executable, 0, win32api.LOAD_LIBRARY_AS_DATAFILE)\n    print(f\"Successfully loaded {sys.executable} as a data file. Handle: {h_module}\")\n    win32api.FreeLibrary(h_module)\n    print(\"Successfully freed the library.\")\nexcept Exception as e:\n    print(f\"An error occurred: {e}\")","lang":"python","description":"This example demonstrates how to import and use `win32api` to load and free a library, mimicking typical `pywin32` usage for basic API calls."},"warnings":[{"fix":"Users should refer to the pywin32-ctypes documentation for the specific APIs that are implemented and their behavior.","message":"pywin32-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.","severity":"gotcha","affected_versions":"All versions"},{"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.","message":"Version 0.2.1 and later of pywin32-ctypes dropped support for Python versions older than 3.6.","severity":"breaking","affected_versions":"0.2.1 and later"},{"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`.","message":"pywin32-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.","severity":"breaking","affected_versions":"0.1.2"},{"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.","message":"Applications 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.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Upgrade to `pywin32-ctypes` 0.2.3 or newer to benefit from fixes in backend selection and ensure consistent runtime behavior.","message":"Prior 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.","severity":"gotcha","affected_versions":"<0.2.3"}],"env_vars":null,"last_verified":"2026-04-05T00:00:00.000Z","next_check":"2026-07-04T00:00:00.000Z"}