pywincffi.wintypes package

Submodules

pywincffi.wintypes.functions module

Functions

This module provides various functions for converting and using Windows types.

pywincffi.wintypes.functions.handle_from_file(file_)[source]

Converts a standard Python file object into a HANDLE object.

Warning

This function is mainly intended for internal use. Passing in a file object with an invalid file descriptor may crash your interpreter.

Parameters:file (file) – The Python file object to convert to a HANDLE object.
Raises:InputError – Raised if file_ does not appear to be a file object or is currently closed.
Return type:HANDLE
pywincffi.wintypes.functions.socket_from_object(sock)[source]

Converts a Python socket to a Windows SOCKET object.

Warning

This function is mainly intended for internal use. Passing in an invalid object may result in a crash.

Parameters:sock (socket._socketobject) – The Python socket to convert to pywincffi.wintypes.SOCKET object.
Return type:pywincffi.wintypes.SOCKET
pywincffi.wintypes.functions.wintype_to_cdata(wintype)[source]

Returns the underlying CFFI cdata object or ffi.NULL if wintype is None. Used internally in API wrappers to “convert” pywincffi’s Python types to the required CFFI cdata objects when calling CFFI functions. Example:

>>> from pywincffi.core import dist
>>> from pywincffi.kernel32 import CreateEvent
>>> from pywincffi.wintypes import wintype_to_cdata
>>> ffi, lib = dist.load()
>>> # Get an event HANDLE, using the wrapper: it's a Python HANDLE object.
>>> hEvent = CreateEvent(bManualReset=False, bInitialState=False)
>>> # Call ResetEvent directly without going through the wrapper:
>>> hEvent_cdata = wintype_to_cdata(hEvent)
>>> result = lib.ResetEvent(hEvent_cdata)
Parameters:wintype – A type derived from pywincffi.core.typesbase.CFFICDataWrapper
Returns:The underlying CFFI <cdata> object, or ffi.NULL if wintype is None.

pywincffi.wintypes.objects module

Objects

Provides wrappers around core Windows objects such as file handles, sockets, etc.

class pywincffi.wintypes.objects.HANDLE(data=None)[source]

Bases: pywincffi.wintypes.objects.WrappedObject

C_TYPE = 'HANDLE[1]'
class pywincffi.wintypes.objects.SOCKET(data=None)[source]

Bases: pywincffi.wintypes.objects.WrappedObject

Handles interaction with a SOCKET object via its cdata

C_TYPE = 'SOCKET[1]'
class pywincffi.wintypes.objects.WSAEVENT(data=None)[source]

Bases: pywincffi.wintypes.objects.HANDLE

Handles interaction with a WSAEVENT object via its cdata.

Note

This is functionally equivalent to a HANDLE object.

C_TYPE = 'WSAEVENT[1]'
class pywincffi.wintypes.objects.WrappedObject(data=None)[source]

Bases: pywincffi.core.typesbase.CFFICDataWrapper

A wrapper used by other objects in this module to share common methods and conversion.

C_TYPE = None

pywincffi.wintypes.structures module

Structures

This module provides wrappers for structures produced or required by the Windows APIs.

class pywincffi.wintypes.structures.FILETIME[source]

Bases: pywincffi.core.typesbase.CFFICDataWrapper

class pywincffi.wintypes.structures.LPWSANETWORKEVENTS[source]

Bases: pywincffi.core.typesbase.CFFICDataWrapper

iErrorCode

An array of integers containing any associated error codes

class pywincffi.wintypes.structures.OVERLAPPED[source]

Bases: pywincffi.core.typesbase.CFFICDataWrapper

hEvent
class pywincffi.wintypes.structures.PROCESS_INFORMATION[source]

Bases: pywincffi.core.typesbase.CFFICDataWrapper

hProcess

Returns a pywincffi.wintypes.objects.HANDLE instance for the hProcess attribute.

hThread

Returns a pywincffi.wintypes.objects.HANDLE instance for the hThread attribute.

class pywincffi.wintypes.structures.SECURITY_ATTRIBUTES[source]

Bases: pywincffi.core.typesbase.CFFICDataWrapper

nLength
class pywincffi.wintypes.structures.STARTUPINFO[source]

Bases: pywincffi.core.typesbase.CFFICDataWrapper

hStdError

Returns a pywincffi.wintypes.objects.HANDLE instance for the hStdError attribute.

hStdInput

Returns a pywincffi.wintypes.objects.HANDLE instance for the hStdInput attribute.

hStdOutput

Returns a pywincffi.wintypes.objects.HANDLE instance for the hStdOutput attribute.

Module contents

Windows Types Package

Provides user accessible types corresponding to the respective Windows types used across the exposed APIs.