pywin32-ctypes

0.2.3 · active · verified Sun Apr 05

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.

Warnings

Install

Imports

Quickstart

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}")

view raw JSON →