2006-06-12 17:56:48 -03:00
|
|
|
######################################################################
|
|
|
|
# This file should be kept compatible with Python 2.3, see PEP 291. #
|
|
|
|
######################################################################
|
2006-03-08 15:56:54 -04:00
|
|
|
|
2006-06-13 05:56:14 -03:00
|
|
|
# The most useful windows datatypes
|
2006-03-08 15:56:54 -04:00
|
|
|
from ctypes import *
|
|
|
|
|
|
|
|
BYTE = c_byte
|
2006-06-13 05:56:14 -03:00
|
|
|
WORD = c_ushort
|
|
|
|
DWORD = c_ulong
|
|
|
|
|
2006-06-13 06:40:14 -03:00
|
|
|
WCHAR = c_wchar
|
|
|
|
UINT = c_uint
|
|
|
|
|
|
|
|
DOUBLE = c_double
|
|
|
|
|
2006-06-13 05:56:14 -03:00
|
|
|
BOOLEAN = BYTE
|
|
|
|
BOOL = c_long
|
2006-06-13 06:40:14 -03:00
|
|
|
|
|
|
|
from ctypes import _SimpleCData
|
|
|
|
class VARIANT_BOOL(_SimpleCData):
|
|
|
|
_type_ = "v"
|
|
|
|
def __repr__(self):
|
|
|
|
return "%s(%r)" % (self.__class__.__name__, self.value)
|
2006-03-08 15:56:54 -04:00
|
|
|
|
|
|
|
ULONG = c_ulong
|
|
|
|
LONG = c_long
|
|
|
|
|
2006-06-13 05:56:14 -03:00
|
|
|
# in the windows header files, these are structures.
|
2006-06-13 06:40:14 -03:00
|
|
|
_LARGE_INTEGER = LARGE_INTEGER = c_longlong
|
|
|
|
_ULARGE_INTEGER = ULARGE_INTEGER = c_ulonglong
|
2006-03-08 15:56:54 -04:00
|
|
|
|
2006-06-13 05:56:14 -03:00
|
|
|
LPCOLESTR = LPOLESTR = OLESTR = c_wchar_p
|
|
|
|
LPCWSTR = LPWSTR = c_wchar_p
|
|
|
|
LPCSTR = LPSTR = c_char_p
|
|
|
|
|
2007-01-11 17:23:12 -04:00
|
|
|
# WPARAM is defined as UINT_PTR (unsigned type)
|
|
|
|
# LPARAM is defined as LONG_PTR (signed type)
|
2007-01-11 17:18:56 -04:00
|
|
|
if sizeof(c_long) == sizeof(c_void_p):
|
|
|
|
WPARAM = c_ulong
|
|
|
|
LPARAM = c_long
|
|
|
|
elif sizeof(c_longlong) == sizeof(c_void_p):
|
|
|
|
WPARAM = c_ulonglong
|
|
|
|
LPARAM = c_longlong
|
2006-06-13 05:56:14 -03:00
|
|
|
|
|
|
|
ATOM = WORD
|
|
|
|
LANGID = WORD
|
|
|
|
|
|
|
|
COLORREF = DWORD
|
|
|
|
LGRPID = DWORD
|
|
|
|
LCTYPE = DWORD
|
|
|
|
|
|
|
|
LCID = DWORD
|
2006-03-08 15:56:54 -04:00
|
|
|
|
2006-06-13 05:56:14 -03:00
|
|
|
################################################################
|
|
|
|
# HANDLE types
|
2007-01-11 17:18:56 -04:00
|
|
|
HANDLE = c_void_p # in the header files: void *
|
2006-03-08 15:56:54 -04:00
|
|
|
|
2006-06-13 05:56:14 -03:00
|
|
|
HACCEL = HANDLE
|
|
|
|
HBITMAP = HANDLE
|
|
|
|
HBRUSH = HANDLE
|
|
|
|
HCOLORSPACE = HANDLE
|
2006-03-08 15:56:54 -04:00
|
|
|
HDC = HANDLE
|
2006-06-13 05:56:14 -03:00
|
|
|
HDESK = HANDLE
|
|
|
|
HDWP = HANDLE
|
|
|
|
HENHMETAFILE = HANDLE
|
|
|
|
HFONT = HANDLE
|
|
|
|
HGDIOBJ = HANDLE
|
|
|
|
HGLOBAL = HANDLE
|
|
|
|
HHOOK = HANDLE
|
|
|
|
HICON = HANDLE
|
2006-03-08 15:56:54 -04:00
|
|
|
HINSTANCE = HANDLE
|
|
|
|
HKEY = HANDLE
|
2006-06-13 05:56:14 -03:00
|
|
|
HKL = HANDLE
|
|
|
|
HLOCAL = HANDLE
|
2006-03-08 15:56:54 -04:00
|
|
|
HMENU = HANDLE
|
2006-06-13 05:56:14 -03:00
|
|
|
HMETAFILE = HANDLE
|
|
|
|
HMODULE = HANDLE
|
|
|
|
HMONITOR = HANDLE
|
|
|
|
HPALETTE = HANDLE
|
|
|
|
HPEN = HANDLE
|
|
|
|
HRGN = HANDLE
|
|
|
|
HRSRC = HANDLE
|
|
|
|
HSTR = HANDLE
|
|
|
|
HTASK = HANDLE
|
|
|
|
HWINSTA = HANDLE
|
|
|
|
HWND = HANDLE
|
|
|
|
SC_HANDLE = HANDLE
|
|
|
|
SERVICE_STATUS_HANDLE = HANDLE
|
2006-03-08 15:56:54 -04:00
|
|
|
|
2006-06-13 05:56:14 -03:00
|
|
|
################################################################
|
|
|
|
# Some important structure definitions
|
2006-03-08 15:56:54 -04:00
|
|
|
|
|
|
|
class RECT(Structure):
|
|
|
|
_fields_ = [("left", c_long),
|
|
|
|
("top", c_long),
|
|
|
|
("right", c_long),
|
|
|
|
("bottom", c_long)]
|
2006-06-13 05:56:14 -03:00
|
|
|
tagRECT = _RECTL = RECTL = RECT
|
|
|
|
|
|
|
|
class _SMALL_RECT(Structure):
|
|
|
|
_fields_ = [('Left', c_short),
|
|
|
|
('Top', c_short),
|
|
|
|
('Right', c_short),
|
|
|
|
('Bottom', c_short)]
|
|
|
|
SMALL_RECT = _SMALL_RECT
|
|
|
|
|
|
|
|
class _COORD(Structure):
|
|
|
|
_fields_ = [('X', c_short),
|
|
|
|
('Y', c_short)]
|
2006-03-08 15:56:54 -04:00
|
|
|
|
|
|
|
class POINT(Structure):
|
|
|
|
_fields_ = [("x", c_long),
|
|
|
|
("y", c_long)]
|
2006-06-13 05:56:14 -03:00
|
|
|
tagPOINT = _POINTL = POINTL = POINT
|
2006-03-08 15:56:54 -04:00
|
|
|
|
|
|
|
class SIZE(Structure):
|
|
|
|
_fields_ = [("cx", c_long),
|
|
|
|
("cy", c_long)]
|
2006-06-13 05:56:14 -03:00
|
|
|
tagSIZE = SIZEL = SIZE
|
2006-03-08 15:56:54 -04:00
|
|
|
|
|
|
|
def RGB(red, green, blue):
|
|
|
|
return red + (green << 8) + (blue << 16)
|
|
|
|
|
|
|
|
class FILETIME(Structure):
|
|
|
|
_fields_ = [("dwLowDateTime", DWORD),
|
|
|
|
("dwHighDateTime", DWORD)]
|
2006-06-13 05:56:14 -03:00
|
|
|
_FILETIME = FILETIME
|
2006-03-08 15:56:54 -04:00
|
|
|
|
|
|
|
class MSG(Structure):
|
|
|
|
_fields_ = [("hWnd", HWND),
|
|
|
|
("message", c_uint),
|
|
|
|
("wParam", WPARAM),
|
|
|
|
("lParam", LPARAM),
|
|
|
|
("time", DWORD),
|
|
|
|
("pt", POINT)]
|
2006-06-13 05:56:14 -03:00
|
|
|
tagMSG = MSG
|
2006-03-08 15:56:54 -04:00
|
|
|
MAX_PATH = 260
|
|
|
|
|
|
|
|
class WIN32_FIND_DATAA(Structure):
|
|
|
|
_fields_ = [("dwFileAttributes", DWORD),
|
|
|
|
("ftCreationTime", FILETIME),
|
|
|
|
("ftLastAccessTime", FILETIME),
|
|
|
|
("ftLastWriteTime", FILETIME),
|
|
|
|
("nFileSizeHigh", DWORD),
|
|
|
|
("nFileSizeLow", DWORD),
|
|
|
|
("dwReserved0", DWORD),
|
|
|
|
("dwReserved1", DWORD),
|
|
|
|
("cFileName", c_char * MAX_PATH),
|
|
|
|
("cAlternameFileName", c_char * 14)]
|
|
|
|
|
|
|
|
class WIN32_FIND_DATAW(Structure):
|
|
|
|
_fields_ = [("dwFileAttributes", DWORD),
|
|
|
|
("ftCreationTime", FILETIME),
|
|
|
|
("ftLastAccessTime", FILETIME),
|
|
|
|
("ftLastWriteTime", FILETIME),
|
|
|
|
("nFileSizeHigh", DWORD),
|
|
|
|
("nFileSizeLow", DWORD),
|
|
|
|
("dwReserved0", DWORD),
|
|
|
|
("dwReserved1", DWORD),
|
|
|
|
("cFileName", c_wchar * MAX_PATH),
|
|
|
|
("cAlternameFileName", c_wchar * 14)]
|
2006-06-14 06:20:11 -03:00
|
|
|
|
|
|
|
__all__ = ['ATOM', 'BOOL', 'BOOLEAN', 'BYTE', 'COLORREF', 'DOUBLE',
|
|
|
|
'DWORD', 'FILETIME', 'HACCEL', 'HANDLE', 'HBITMAP', 'HBRUSH',
|
|
|
|
'HCOLORSPACE', 'HDC', 'HDESK', 'HDWP', 'HENHMETAFILE', 'HFONT',
|
|
|
|
'HGDIOBJ', 'HGLOBAL', 'HHOOK', 'HICON', 'HINSTANCE', 'HKEY',
|
|
|
|
'HKL', 'HLOCAL', 'HMENU', 'HMETAFILE', 'HMODULE', 'HMONITOR',
|
|
|
|
'HPALETTE', 'HPEN', 'HRGN', 'HRSRC', 'HSTR', 'HTASK', 'HWINSTA',
|
|
|
|
'HWND', 'LANGID', 'LARGE_INTEGER', 'LCID', 'LCTYPE', 'LGRPID',
|
|
|
|
'LONG', 'LPARAM', 'LPCOLESTR', 'LPCSTR', 'LPCWSTR', 'LPOLESTR',
|
|
|
|
'LPSTR', 'LPWSTR', 'MAX_PATH', 'MSG', 'OLESTR', 'POINT',
|
|
|
|
'POINTL', 'RECT', 'RECTL', 'RGB', 'SC_HANDLE',
|
|
|
|
'SERVICE_STATUS_HANDLE', 'SIZE', 'SIZEL', 'SMALL_RECT', 'UINT',
|
|
|
|
'ULARGE_INTEGER', 'ULONG', 'VARIANT_BOOL', 'WCHAR',
|
|
|
|
'WIN32_FIND_DATAA', 'WIN32_FIND_DATAW', 'WORD', 'WPARAM', '_COORD',
|
|
|
|
'_FILETIME', '_LARGE_INTEGER', '_POINTL', '_RECTL', '_SMALL_RECT',
|
|
|
|
'_ULARGE_INTEGER', 'tagMSG', 'tagPOINT', 'tagRECT', 'tagSIZE']
|