win32api

A module, encapsulating the Windows Win32 API.

Functions

BeginUpdateResource(filename, delete) Get a handle that can be used by the UpdateResource().
EndUpdateResource(handle, discard) End the update resource of the handle.
EnumResourceLanguages(hModule, lpType, lpName) List languages of a resource module.
EnumResourceNames(hModule, resType) Enumerates all the resources of the specified type within a module.
EnumResourceTypes(hModule) Enumerates resource types within a module.
FreeLibrary(hModule) Free the loaded dynamic-link library (DLL) module.
GetSystemDirectory() Get the System directory.
GetTickCount() The number of milliseconds that have elapsed since startup
GetWindowsDirectory() Get the Windows directory.
LoadLibraryEx(fileName, handle, flags) Loads the specified DLL, and returns the handle.
LoadResource(hModule, type, name[, language]) Find and Load a resource component.
UpdateResource(handle, type, name, data[, …]) Update a resource.


win32ctypes.pywin32.win32api.BeginUpdateResource(filename, delete)[source]

Get a handle that can be used by the UpdateResource().

Parameters:
  • fileName (unicode) – The filename of the module to load.
  • delete (bool) – When true all existing resources are deleted
Returns:

result (hModule) – Handle of the resource.

win32ctypes.pywin32.win32api.EndUpdateResource(handle, discard)[source]

End the update resource of the handle.

Parameters:
  • handle (hModule) – The handle of the resource as it is returned by BeginUpdateResource()
  • discard (bool) – When True all writes are discarded.
win32ctypes.pywin32.win32api.EnumResourceLanguages(hModule, lpType, lpName)[source]

List languages of a resource module.

Parameters:
  • hModule (handle) – Handle to the resource module.
  • lpType (str or int) – The type or id of resource to enumerate.
  • lpName (str or int) – The type or id of resource to enumerate.
Returns:

resource_languages (list) – List of the resource language ids.

win32ctypes.pywin32.win32api.EnumResourceNames(hModule, resType)[source]

Enumerates all the resources of the specified type within a module.

Parameters:
  • hModule (handle) – The handle to the module.
  • resType (str or int) – The type or id of resource to enumerate.
Returns:

resource_names (list) – The list of resource names (unicode strings) of the specific resource type in the module.

win32ctypes.pywin32.win32api.EnumResourceTypes(hModule)[source]

Enumerates resource types within a module.

Parameters:hModule (handle) – The handle to the module.
Returns:resource_types (list) – The list of resource types in the module.
win32ctypes.pywin32.win32api.FreeLibrary(hModule)[source]

Free the loaded dynamic-link library (DLL) module.

If necessary, decrements its reference count.

Parameters:handle (hModule) – The handle to the library as returned by the LoadLibrary function.
win32ctypes.pywin32.win32api.GetSystemDirectory()[source]

Get the System directory.

Returns:result (str) – The path to the System directory.
win32ctypes.pywin32.win32api.GetTickCount()[source]

The number of milliseconds that have elapsed since startup

Returns:counts (int) – The millisecond counts since system startup.
win32ctypes.pywin32.win32api.GetWindowsDirectory()[source]

Get the Windows directory.

Returns:result (str) – The path to the Windows directory.
win32ctypes.pywin32.win32api.LoadLibraryEx(fileName, handle, flags)[source]

Loads the specified DLL, and returns the handle.

Parameters:
  • fileName (unicode) – The filename of the module to load.
  • handle (int) – Reserved, always zero.
  • flags (int) – The action to be taken when loading the module.
Returns:

handle (hModule) – The handle of the loaded module

win32ctypes.pywin32.win32api.LoadResource(hModule, type, name, language=0)[source]

Find and Load a resource component.

Parameters:
  • handle (hModule) – The handle of the module containing the resource. Use None for current process executable.
  • type (str or int) – The type of resource to load.
  • name (str or int) – The name or Id of the resource to load.
  • language (int) – Language to use, default is LANG_NEUTRAL.
Returns:

resource (bytes) – The byte string blob of the resource

win32ctypes.pywin32.win32api.UpdateResource(handle, type, name, data, language=0)[source]

Update a resource.

Parameters:
  • handle (hModule) – The handle of the resource file as returned by BeginUpdateResource().
  • type (str or int) – The type of resource to update.
  • name (str or int) – The name or Id of the resource to update.
  • data (bytes) –

    A bytes like object is expected.

    Note

    PyWin32 version 219, on Python 2.7, can handle unicode inputs. However, the data are stored as bytes and it is not really possible to convert the information back into the original unicode string. To be consistent with the Python 3 behaviour of PyWin32, we raise an error if the input cannot be converted to bytes.

  • language (int) – Language to use, default is LANG_NEUTRAL.